From 2c4652d409c3d31467d3bacd6bbf4d068fdfba45 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 21 Oct 2024 05:36:23 -0700 Subject: [PATCH] Only copy headers to release dir if contents changed --- makefile | 3 ++- makefile.ver | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/makefile b/makefile index 4d66bd06ad4..d1a29c5ef68 100644 --- a/makefile +++ b/makefile @@ -1053,7 +1053,8 @@ $(CORE.incdirs): _release_c_h define .release.dd $3: $2 -$2: $1 ; $(value mkdir)$(value cpy) +$2: $1 ; $(value mkdir) + @if [ ! -f $2 ] || ! cmp -s $1 $2; then $(value cpy); fi $(if $(filter %library_version_info.h,$2),+$(daalmake) -f makefile update_headers_version) $(if $(USECPUS.out.defs.filter),$(if $(filter %daal_kernel_defines.h,$2),$(USECPUS.out.defs.filter) $2; rm -rf $(subst .h,.h.bak,$2))) endef diff --git a/makefile.ver b/makefile.ver index 5dfffa784b3..05d85cc60a6 100644 --- a/makefile.ver +++ b/makefile.ver @@ -59,11 +59,20 @@ $(VERSION_DATA_FILE): | $(WORKDIR)/. @bash -c 'echo "$$DAAL_VERSION_DATA"' > $@ # update public headers in release directory with actual version data +# copy file only if the result is different from the previous run +# to avoid interference with incremental builds update_headers_version: - @file=$(RELEASEDIR.include)/services/library_version_info.h && mark="#define __INTEL_DAAL" && \ - sed $(sed.-b) $(sed.-i) -e "s/_DAAL_BUILD_DATE.*/_DAAL_BUILD_DATE $(BUILD)$(sed.eol)/" \ - -e "s/\($${mark}__\).*/\1 $(MAJOR)$(sed.eol)/;s/\($${mark}_MINOR__\).*/\1 $(MINOR)$(sed.eol)/" \ - -e "s/\($${mark}_MAJOR_BINARY__\).*/\1 $(MAJORBINARY)$(sed.eol)/;s/\($${mark}_MINOR_BINARY__\).*/\1 $(MINORBINARY)$(sed.eol)/" \ - -e "s/\($${mark}_UPDATE__\).*/\1 $(UPDATE)$(sed.eol)/" \ - -e "s/\($${mark}_STATUS__\).*/\1 \"$(STATUS)\"$(sed.eol)/" $$file && \ - rm -f $$file.bak + @file=$(RELEASEDIR.include)/services/library_version_info.h && \ + tempfile=$${file}.tmp && \ + mark="#define __INTEL_DAAL" && \ + sed $(sed.-b) $(sed.-i) -e "s/_DAAL_BUILD_DATE.*/_DAAL_BUILD_DATE $(BUILD)$(sed.eol)/" \ + -e "s/\($${mark}__\).*/\1 $(MAJOR)$(sed.eol)/;s/\($${mark}_MINOR__\).*/\1 $(MINOR)$(sed.eol)/" \ + -e "s/\($${mark}_MAJOR_BINARY__\).*/\1 $(MAJORBINARY)$(sed.eol)/;s/\($${mark}_MINOR_BINARY__\).*/\1 $(MINORBINARY)$(sed.eol)/" \ + -e "s/\($${mark}_UPDATE__\).*/\1 $(UPDATE)$(sed.eol)/" \ + -e "s/\($${mark}_STATUS__\).*/\1 \"$(STATUS)\"$(sed.eol)/" $$file > $$tempfile && \ + if [ ! -f $$file ] || ! cmp -s $$tempfile $$file; then \ + # echo "Updating $$file with new version data."; \ + mv $$tempfile $$file; \ + else \ + rm $$tempfile; \ + fi