diff --git a/git_commit.sh b/git_commit.sh new file mode 100755 index 0000000..7526608 --- /dev/null +++ b/git_commit.sh @@ -0,0 +1,41 @@ +#/usr/bin/env bash + +STUID=ysyx_22040000 +STUNAME=李心杨 + +TRACER=tracer-ysyx +GITFLAGS="-q --author=$TRACER --no-verify --allow-empty" + +WORK_BRANCH=$(git rev-parse --abbrev-ref HEAD) +WORK_INDEX=.git/index.${WORK_BRANCH} +TRACER_BRANCH=$TRACER + +LOCK_DIR=.git/ + +git_soft_checkout () { + git checkout --detach -q && git reset --soft $1 -q -- && git checkout $1 -q -- ; +} + +git_commit () { + # create tracer branch if not existent + git branch $TRACER_BRANCH -q 2>/dev/null || true + # backup git index + cp -a .git/index $WORK_INDEX + # switch to tracer branch + git_soft_checkout "$TRACER_BRANCH" + # add files to commit + git add . -A --ignore-errors + # generate commit msg, commit changes in tracer branch + printf "> $1 \n $STUID $STUNAME \n $(uname -a) \n $(uptime)\n" | git commit -F - $GITFLAGS + git_soft_checkout "$WORK_BRANCH" + mv $WORK_INDEX .git/index +} + +git_commit $1 + +if [ $? -eq 0 ]; then + echo "[OK] Git commit track" +else + echo "[FAIL] Git commit track" && false +fi + diff --git a/npc/CMakeLists.txt b/npc/CMakeLists.txt index 94616a8..b4621bb 100644 --- a/npc/CMakeLists.txt +++ b/npc/CMakeLists.txt @@ -4,6 +4,11 @@ project(npc) set (CMAKE_CXX_STANDARD 11) cmake_policy(SET CMP0144 NEW) +execute_process( + COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "configure(npc)" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. +) + find_package(SDL2 REQUIRED) find_package(SDL2_image REQUIRED) @@ -70,3 +75,16 @@ add_dependencies(V${TOPMODULE} ChiselBuild) enable_testing() add_test(NAME V${TOPMODULE} COMMAND V${TOPMODULE}) + +# -- Add build tracking +add_custom_command( + TARGET V${TOPMODULE}_nvboard PRE_BUILD + COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}_nvboard" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. +) + +add_custom_command( + TARGET V${TOPMODULE} PRE_BUILD + COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. +)