blob: 47e6612bab3ba1ac5b9f47f2a8a5716e4459e488 [file] [log] [blame]
Joey Armstrong36592e32022-11-28 09:00:28 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong8388b7f2023-01-23 11:20:04 -05003# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrong36592e32022-11-28 09:00:28 -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 Armstrong449ce7a2023-07-18 18:32:24 -040018include $(ONF_MAKEDIR)/patches/help.mk
Joey Armstrong36592e32022-11-28 09:00:28 -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 Armstrong4de98b72023-02-09 14:51:38 -050030# Defined by [Mm]akefile or makefiles/virtualenv.mk
31venv-name ?= $(error $(MAKE) venv-name= is required)
32
Joey Armstrong36592e32022-11-28 09:00:28 -050033PATCH_PATH ?= $(error $(MAKE) PATCH_PATH= is required)
34
35## -----------------------------------------------------------------------
36## -----------------------------------------------------------------------
37patch-gather:
38 grep -r $(patch-gather-args)
39
40## -----------------------------------------------------------------------
41## -----------------------------------------------------------------------
42patch-diff:
Joey Armstrong4de98b72023-02-09 14:51:38 -050043 $(HIDE)diff -qr staging $(venv-name) \
Joey Armstrong36592e32022-11-28 09:00:28 -050044 | awk '{print "# diff -Naur "$$2" "$$4}' \
45 | tee $@.log
46
47## -----------------------------------------------------------------------
48## -----------------------------------------------------------------------
49patch-create:
50 mkdir -p patches/$(PATCH_PATH)
Joey Armstrong4de98b72023-02-09 14:51:38 -050051 diff -Naur staging/$(PATCH_PATH) $(venv-name)/$(PATCH_PATH) | tee patches/$(PATCH_PATH)/patch
Joey Armstrong36592e32022-11-28 09:00:28 -050052 exit 1
53
54## -----------------------------------------------------------------------
55## -----------------------------------------------------------------------
56patch-init:
Joey Armstrong4de98b72023-02-09 14:51:38 -050057 find "$(venv-name)" -name '__pycache__' -type d -print0 \
Joey Armstrong36592e32022-11-28 09:00:28 -050058 | xargs -I'{}' --null --no-run-if-empty $(RM) -r {}
59 mkdir -p staging
Joey Armstrong4de98b72023-02-09 14:51:38 -050060 rsync -rv --checksum "$(venv-name)/." "staging/."
Joey Armstrong36592e32022-11-28 09:00:28 -050061 @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]