blob: 47e6612bab3ba1ac5b9f47f2a8a5716e4459e488 [file] [log] [blame]
Joey Armstrongee4d8262023-08-22 15:19:19 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
17
18include $(ONF_MAKEDIR)/patches/help.mk
19
20patch-gather-args += --exclude=Makefile
21patch-gather-args += --exclude-dir=vault
22patch-gather-args += --exclude-dir=makefiles
23patch-gather-args += --exclude-dir=staging
24patch-gather-args += --exclude-dir=patches
25
26# patch-gather-args += -e 'from collections import'
27patch-gather-args += '-e' 'from collections import Mapping'
28patch-gather-args += '-e' 'from collections import MutableMapping'
29
30# Defined by [Mm]akefile or makefiles/virtualenv.mk
31venv-name ?= $(error $(MAKE) venv-name= is required)
32
33PATCH_PATH ?= $(error $(MAKE) PATCH_PATH= is required)
34
35## -----------------------------------------------------------------------
36## -----------------------------------------------------------------------
37patch-gather:
38 grep -r $(patch-gather-args)
39
40## -----------------------------------------------------------------------
41## -----------------------------------------------------------------------
42patch-diff:
43 $(HIDE)diff -qr staging $(venv-name) \
44 | awk '{print "# diff -Naur "$$2" "$$4}' \
45 | tee $@.log
46
47## -----------------------------------------------------------------------
48## -----------------------------------------------------------------------
49patch-create:
50 mkdir -p patches/$(PATCH_PATH)
51 diff -Naur staging/$(PATCH_PATH) $(venv-name)/$(PATCH_PATH) | tee patches/$(PATCH_PATH)/patch
52 exit 1
53
54## -----------------------------------------------------------------------
55## -----------------------------------------------------------------------
56patch-init:
57 find "$(venv-name)" -name '__pycache__' -type d -print0 \
58 | xargs -I'{}' --null --no-run-if-empty $(RM) -r {}
59 mkdir -p staging
60 rsync -rv --checksum "$(venv-name)/." "staging/."
61 @echo "Modify files beneath staging/ to create a patch source"
62
63# [SEE ALSO]
64# ---------------------------------------------------------------------------
65# https://bobbyhadz.com/blog/python-importerror-cannot-import-name-mapping-from-collections
66# ---------------------------------------------------------------------------
67# [EOF]