blob: 7aa581a1d71131df7b662def7703207186f67808 [file] [log] [blame]
Joey Armstrong83874cc2022-11-26 09:40:08 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong9fadcbe2024-01-17 19:00:37 -05003# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrong83874cc2022-11-26 09:40:08 -05004#
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
Joey Armstrong04cdd9f2023-06-09 15:18:23 -040018include $(ONF_MAKEDIR)/patches/help.mk
Joey Armstrong83874cc2022-11-26 09:40:08 -050019
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
Joey Armstrong04cdd9f2023-06-09 15:18:23 -040030# 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## -----------------------------------------------------------------------
Joey Armstrong83874cc2022-11-26 09:40:08 -050037patch-gather:
38 grep -r $(patch-gather-args)
39
Joey Armstrong04cdd9f2023-06-09 15:18:23 -040040## -----------------------------------------------------------------------
41## -----------------------------------------------------------------------
Joey Armstrong83874cc2022-11-26 09:40:08 -050042patch-diff:
Joey Armstrong04cdd9f2023-06-09 15:18:23 -040043 $(HIDE)diff -qr staging $(venv-name) \
Joey Armstrong83874cc2022-11-26 09:40:08 -050044 | awk '{print "# diff -Naur "$$2" "$$4}' \
45 | tee $@.log
46
Joey Armstrong04cdd9f2023-06-09 15:18:23 -040047## -----------------------------------------------------------------------
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
Joey Armstrong83874cc2022-11-26 09:40:08 -050063# [SEE ALSO]
64# ---------------------------------------------------------------------------
65# https://bobbyhadz.com/blog/python-importerror-cannot-import-name-mapping-from-collections
66# ---------------------------------------------------------------------------
67# [EOF]