Alexander Couzens has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/51362 )
Change subject: util/genbuild_h: add support to print SOURCE_DATE_EPOCH ......................................................................
util/genbuild_h: add support to print SOURCE_DATE_EPOCH
To use SOURCE_DATE_EPOCH for the kernel build, extend genbuild_h. genbuild_h already calculates a source_date_epoch timestamp. Add arguments for genbuild_h:
-e - output SOURCE_DATE_EPOCH timestamp -g <xcompile> - output genbuild.h
Change-Id: Iaa79d3e7df8101a1ba1b37a361d8992f7eab2d52 Signed-off-by: Alexander Couzens lynxis@fe80.eu --- M Makefile.inc M util/genbuild_h/genbuild_h.sh 2 files changed, 49 insertions(+), 27 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/51362/1
diff --git a/Makefile.inc b/Makefile.inc index f46de46..3175957 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -528,7 +528,7 @@ # Report new `build.ht` as dependency if `build.h` differs. build_h_check := \ export $(foreach exp,$(build_h_exports),$(exp)="$($(exp))"); \ - util/genbuild_h/genbuild_h.sh $(xcompile) \ + util/genbuild_h/genbuild_h.sh -g $(xcompile) \ >$(build_h)t 2>/dev/null; \ cmp -s $(build_h)t $(build_h) >/dev/null 2>&1 || echo $(build_h)t
diff --git a/util/genbuild_h/genbuild_h.sh b/util/genbuild_h/genbuild_h.sh index b82a74b..e340749 100755 --- a/util/genbuild_h/genbuild_h.sh +++ b/util/genbuild_h/genbuild_h.sh @@ -10,13 +10,27 @@ export LC_ALL=C export TZ=UTC0
-XCOMPILE=$1 +MODE=$1 +XCOMPILE=$2
-if [ -z "$XCOMPILE" ] || [ "$1" = "--help" ]; then - echo "usage: $0 <xcompile>" >&2 +usage() { + cat >&2 <<EOF +usage: $0 [-g <xcompile>] [-e] + +-e - output SOURCE_DATE_EPOCH timestamp +-g <xcompile> - output genbuild.h +EOF exit 1 +} + +# poor mans getopt +if [ "$MODE" != "-g" ] && [ "$MODE" != "-e" ] ; then + usage +elif [ "$MODE" = "-g" ] && [ -z "$XCOMPILE" ] ; then + usage fi
+ # $1: format string get_git_head_data() { LANG= git log --no-show-signature -1 --format="format:$1" 2>/dev/null || \ @@ -47,29 +61,37 @@ esac }
-IASL=util/crossgcc/xgcc/bin/iasl -eval $(grep ^IASL:= "$XCOMPILE" 2>/dev/null | sed s,:=,=,) +case "$MODE" in + "-e") + printf "$DATE\n" + ;; + "-g") + IASL=util/crossgcc/xgcc/bin/iasl + eval $(grep ^IASL:= "$XCOMPILE" 2>/dev/null | sed s,:=,=,)
-#Print out the information that goes into build.h -printf "/* build system definitions (autogenerated) */\n" -printf "#ifndef __BUILD_H\n" -printf "#define __BUILD_H\n\n" -printf "#define COREBOOT_VERSION %s\n" ""$KERNELVERSION"" + #Print out the information that goes into build.h + printf "/* build system definitions (autogenerated) */\n" + printf "#ifndef __BUILD_H\n" + printf "#define __BUILD_H\n\n" + printf "#define COREBOOT_VERSION %s\n" ""$KERNELVERSION""
-#See if the build is running in a git repo and the git command is available -printf "/* timesource: $TIMESOURCE */\n" -printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n" -printf "#define COREBOOT_ORIGIN_GIT_REVISION "$GITREV"\n" + #See if the build is running in a git repo and the git command is available + printf "/* timesource: $TIMESOURCE */\n" + printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n" + printf "#define COREBOOT_ORIGIN_GIT_REVISION "$GITREV"\n"
-printf "#define COREBOOT_EXTRA_VERSION "%s"\n" "$COREBOOT_EXTRA_VERSION" -printf "#define COREBOOT_MAJOR_VERSION %d\n#define COREBOOT_MINOR_VERSION %d\n" `git describe --match [0-9].[0-9]* | sed 's/([0-9]).([0-9]+).*/\1 \2/'` -printf "#define COREBOOT_BUILD "$(our_date "$DATE")"\n" -printf "#define COREBOOT_BUILD_YEAR_BCD 0x$(our_date "$DATE" +%y)\n" -printf "#define COREBOOT_BUILD_MONTH_BCD 0x$(our_date "$DATE" +%m)\n" -printf "#define COREBOOT_BUILD_DAY_BCD 0x$(our_date "$DATE" +%d)\n" -printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x$(our_date "$DATE" +%w)\n" -printf "#define COREBOOT_DMI_DATE "$(our_date "$DATE" +%m/%d/%Y)"\n" -printf "\n" -printf "#define COREBOOT_COMPILE_TIME "$(our_date "$DATE" +%T)"\n" -printf "#define ASL_VERSION 0x%d\n" `$IASL -v | grep version | sed 's/.*version //'` -printf "#endif\n" + printf "#define COREBOOT_EXTRA_VERSION "%s"\n" "$COREBOOT_EXTRA_VERSION" + printf "#define COREBOOT_MAJOR_VERSION %d\n#define COREBOOT_MINOR_VERSION %d\n" `git describe --match [0-9].[0-9]* | sed 's/([0-9]).([0-9]+).*/\1 \2/'` + printf "#define COREBOOT_BUILD "$(our_date "$DATE")"\n" + printf "#define COREBOOT_BUILD_YEAR_BCD 0x$(our_date "$DATE" +%y)\n" + printf "#define COREBOOT_BUILD_MONTH_BCD 0x$(our_date "$DATE" +%m)\n" + printf "#define COREBOOT_BUILD_DAY_BCD 0x$(our_date "$DATE" +%d)\n" + printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x$(our_date "$DATE" +%w)\n" + printf "#define COREBOOT_DMI_DATE "$(our_date "$DATE" +%m/%d/%Y)"\n" + printf "\n" + printf "#define COREBOOT_COMPILE_TIME "$(our_date "$DATE" +%T)"\n" + printf "#define ASL_VERSION 0x%d\n" `$IASL -v | grep version | sed 's/.*version //'` + printf "#endif\n" + ;; +esac +