]> xenbits.xensource.com Git - xtf.git/commitdiff
build: Add move-if-changed helper
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 26 Jul 2016 15:33:43 +0000 (15:33 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 26 Jul 2016 20:37:23 +0000 (21:37 +0100)
And use it in preference to repeated opencoding

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
build/common.mk
build/gen.mk

index 52721d8545c71cc1f65a2de570edead338e2b427..32afce5bba0ddda2a31696e119eb8967194ef2cd 100644 (file)
@@ -104,3 +104,6 @@ endef
 
 $(foreach env,$(ALL_ENVIRONMENTS),$(eval $(call PERENV_setup,$(env))))
 
+define move-if-changed
+       if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi
+endef
index aeac2a6b2e78ae376e782191879cc5b115c2e899..6d3db2f60a033037e118d0a44db23f08d9a3a69e 100644 (file)
@@ -27,7 +27,7 @@ build: test-info.json
 
 test-info.json: $(ROOT)/build/mkinfo.py FORCE
        @$(PYTHON) $< $@.tmp "$(NAME)" "$(CATEGORY)" "$(TEST-ENVS)"
-       @if ! cmp -s $@ $@.tmp; then mv -f $@.tmp $@; else rm -f $@.tmp; fi
+       @$(call move-if-changed,$@.tmp,$@)
 
 .PHONY: install install-each-env
 install: install-each-env test-info.json
@@ -56,7 +56,7 @@ test-$(1)-$(NAME).cfg: $$(cfg-$(1)) FORCE
                -e "s/@@ENV@@/$(1)/g" \
                -e "s!@@XTFDIR@@!$$(xtfdir)!g" \
                > $$@.tmp
-       @if ! cmp -s $$@ $$@.tmp; then mv -f $$@.tmp $$@; else rm -f $$@.tmp; fi
+       @$(call move-if-changed,$$@.tmp,$$@)
 
 -include $$(link-$(1):%.lds=%.d)
 -include $$(DEPS-$(1):%.o=%.d)