Added script to generate C header with git repo url and rev info.

This commit is contained in:
Matthew Budd 2020-07-11 17:48:14 -04:00
parent 889250b720
commit 9fc2d905de
1 changed files with 25 additions and 0 deletions

25
scripts/genGitHdr.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
OUTPUT_DIR=$1;
FILE="fceux_gitrev.h"
TMP_FILE="/tmp/$FILE";
GIT_URL=`git config --get remote.origin.url`;
GIT_REV=`git rev-parse HEAD`;
echo "// fceux_gitrev.h -- DO NOT EDIT: This file is auto-generated at build" >| $TMP_FILE;
echo "#define FCEUX_GIT_URL \"$GIT_URL\" " >> $TMP_FILE;
echo "#define FCEUX_GIT_REV \"$GIT_REV\" " >> $TMP_FILE;
if [ -e $OUTPUT_DIR/$FILE ]; then
diff $TMP_FILE $OUTPUT_DIR/$FILE
if [ $? != 0 ]; then
echo 'File Differs';
mv -f $TMP_FILE $OUTPUT_DIR/$FILE
fi
else
mv -f $TMP_FILE $OUTPUT_DIR/$FILE
fi