mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-02 01:16:50 +00:00
Makefile: create and apply patches to generated sources
In order to enable changing the generated C configuration files manually, this patch introduces the target `diffconfig` to the build system. After generating the configuration files, a developer can manually modify these sources (which are placed under build/configs) and invoke `make diffconfig` to generate a patch that shows the made differences. Such patches can be registered to a build by invoking the `applydiffconfig` target. The build system will always apply them whenever the configuration files are regenerated. A typical workflow to create a patch is as follows. # The pre_build target relies on generated configuration files hypervisor$ make BOARD=xxx SCENARIO=yyy pre_build (manually edit files under build/configs/boards and build/configs/scenarios) hypervisor$ make diffconfig # Patch generated to build/config.patch hypervisor$ cp build/config.patch /path/to/patch The following steps apply apply the patch to another build. hypervisor$ make BOARD=xxx SCENARIO=yyy defconfig hypervisor$ make applydiffconfig PATCH=/path/to/patch-file-or-directory hypervisor$ make After any patch is registered for a build, the configuration files will be automatically regenerated the next time `make` is invoked. To show a list of registered patches for generated configuration files, invoke `make applydiffconfig` without specifying `PATCH`. v2: * Add target `applydiffconfig` which accepts a PATCH variable to register an arbitrary patch file or a directory containing patch file(s) for a build. `.config_patches` is no longer used. Tracked-On: #5644 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
@@ -125,6 +125,11 @@ HV_UNIFIED_XML := $(HV_CONFIG_DIR)/unified.xml
|
||||
HV_CONFIG_H := $(HV_OBJDIR)/include/config.h
|
||||
HV_CONFIG_MK := $(HV_CONFIG_DIR)/config.mk
|
||||
HV_CONFIG_TIMESTAMP := $(HV_CONFIG_DIR)/.timestamp
|
||||
HV_DIFFCONFIG_LIST := $(HV_CONFIG_DIR)/.diffconfig
|
||||
|
||||
HV_CONFIG_A_DIR := $(HV_OBJDIR)/a # Directory containing generated configuration sources for diffconfig
|
||||
HV_CONFIG_B_DIR := $(HV_OBJDIR)/b # Directory containing edited configuration sources for diffconfig
|
||||
HV_CONFIG_DIFF := $(HV_OBJDIR)/config.patch # Patch encoding differences between generated and edited config. sources
|
||||
|
||||
# Backward-compatibility for RELEASE=(0|1)
|
||||
ifdef RELEASE
|
||||
@@ -226,7 +231,7 @@ $(HV_CONFIG_H): $(HV_UNIFIED_XML)
|
||||
@xsltproc -o $@ --xinclude --xincludestyle $(HV_CONFIG_XFORM_DIR)/config.h.xsl $<
|
||||
@echo "$@ generated"
|
||||
|
||||
$(HV_CONFIG_TIMESTAMP): $(HV_UNIFIED_XML) | $(HV_CONFIG_DIR)
|
||||
$(HV_CONFIG_TIMESTAMP): $(HV_UNIFIED_XML) ${HV_DIFFCONFIG_LIST} | $(HV_CONFIG_DIR)
|
||||
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(HV_BOARD_XML) $(HV_SCENARIO_XML) $(HV_CONFIG_DIR)
|
||||
@touch $@
|
||||
|
||||
@@ -240,6 +245,38 @@ showconfig:
|
||||
@echo "- SCENARIO = $(SCENARIO)"
|
||||
@echo "- RELEASE = $(RELEASE)"
|
||||
|
||||
diffconfig:
|
||||
@rm -rf $(HV_CONFIG_A_DIR) $(HV_CONFIG_B_DIR)
|
||||
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(BOARD_FILE) $(HV_CONFIG_XML) $(HV_CONFIG_A_DIR)
|
||||
@cd $(HV_CONFIG_DIR) && find . -name '*.c' -or -name '*.h' -or -name '*.config' | while read f; do \
|
||||
nf=$(HV_CONFIG_B_DIR)/$${f}; mkdir -p `dirname $${nf}` && cp $${f} $${nf}; \
|
||||
done
|
||||
@cd $(HV_OBJDIR) && git diff --no-index --no-prefix a/ b/ > $(HV_CONFIG_DIFF) || true
|
||||
@echo "Diff on generated configuration files is available at $(HV_CONFIG_DIFF)."
|
||||
@echo "To make a patch effective, use `applydiffconfig PATCH=/path/to/patch` to register it to a build."
|
||||
|
||||
applydiffconfig:
|
||||
ifdef PATCH
|
||||
ifneq ($(realpath $(PATCH)),)
|
||||
@echo $(realpath $(PATCH)) >> ${HV_DIFFCONFIG_LIST}
|
||||
@echo "${PATCH} is registered for build directory ${HV_OBJDIR}."
|
||||
@echo "Registered patches will be applied the next time 'make' is invoked."
|
||||
@echo "To unregister a patch, remove it from ${HV_DIFFCONFIG_LIST}."
|
||||
else
|
||||
@echo "${PATCH}: No such file or directory"
|
||||
endif
|
||||
else
|
||||
@echo "No patch file or directory is specified"
|
||||
@echo "Try 'make applydiffconfig PATCH=/path/to/patch' to register patches for generated configuration files."
|
||||
ifneq ($(realpath $(HV_DIFFCONFIG_LIST)),)
|
||||
@echo "Registers patches:"
|
||||
@cat $(HV_DIFFCONFIG_LIST)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(HV_DIFFCONFIG_LIST):
|
||||
@touch $@
|
||||
|
||||
menuconfig:
|
||||
@echo "To tweak the configurations, run $(HV_CONFIG_TOOL_DIR)/config_app/app.py using python3 and load $(HV_SCENARIO_XML) in the web browser."
|
||||
|
||||
|
Reference in New Issue
Block a user