Commit dae2cdd4 authored by Benoit Rat's avatar Benoit Rat

at91boot: update building with git version

Git revision can refer to the at91bootstrap repo itself used to generate
the patches (in this case .git exist) or to a parent repo (wr-switch-sw)
that we used with patches (In this case we need to pass git value using
exported variable) because no .git folder when creating the
at91bootstrap folder.
parent c464c489
......@@ -15,6 +15,10 @@ dirname="at91bootstrap-3-3.0"
tarname="$dirname.tar.gz"
wrs_download $tarname
#Export git version to the children call so that it can be use by Makefile
export WRS_GIT_USER="$(cd ${WRS_BASE_DIR} && git config --get user.name)"
export WRS_GIT_REV="$(cd ${WRS_BASE_DIR} && git describe --always --dirty=+)"
mkdir -p $WRS_OUTPUT_DIR/build || wrs_die "mkdir build"
mkdir -p $WRS_OUTPUT_DIR/images || wrs_die "mkdir images"
......
......@@ -48,16 +48,16 @@ index 6216632..88dfffc 100644
all: PrintFlags gen_bin ChkFileSize
+## If not git is found
+ifeq ($(shell git status -s | grep -v "fatal*"),)
+## Git revision can refer to the at91bootstrap repo itself (in this case .git exist) or to a parent repo (wr-switch-sw) that we used with patch (In this case we need to pass git value using exported variable).
+ifneq (.git,$(wildcard .git))
+version.c: $(SOBJS-y) $(COBJS-y)
+ @echo "/**" > $@
+ @echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
+ @echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
+ @echo "**/" >> $@
+ @echo " * File automatically generated by Makefile (DO NOT MODIFY)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
+ @echo " * \textern const char build_time[];\n * \textern const char git_user[];\n * \textren const char git_revision[];\n * " >> $@
+ @echo " * GIT values given by exported shell variable\n**/" >> $@
+ @echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
+ @echo "const char git_user[] = \"$(shell id -nu)\";" >> $@
+ @echo "const char git_revision[] = \"\";" >> $@
+ @echo "const char git_user[] = \"$(shell echo ${WRS_GIT_USER})\";" >> $@
+ @echo "const char git_revision[] = \"$(shell echo ${WRS_GIT_REV})\";" >> $@
+ @echo "" >> $@
+else
+version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index Makefile
......@@ -67,7 +67,7 @@ index 6216632..88dfffc 100644
+ @echo "**/" >> $@
+ @echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
+ @echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; else echo ''; fi;)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git describe --always --dirty=+)\";" >> $@
+ @echo "" >> $@
+endif
+
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment