51 lines
1.5 KiB
Bash
Executable file
51 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
DIR=$(dirname $0)
|
|
|
|
TARGET=$1
|
|
shift
|
|
OUTPUT=$1
|
|
shift
|
|
CMD="$*"
|
|
|
|
VERSION_DIR=../version/${TARGET}
|
|
mkdir -p "${VERSION_DIR}"
|
|
|
|
BUILD_VERSION=$(( $(cat "${VERSION_DIR}"/build || echo 0) + 1 ))
|
|
echo ${BUILD_VERSION} > "${VERSION_DIR}"/build
|
|
|
|
VERSION_MAJOR=0
|
|
VERSION_MINOR=1
|
|
|
|
COMMIT=$(git rev-parse HEAD)
|
|
AUTHOR=$(git show --format="%aE" "${COMMIT}" | head -n1 | awk '{print $1}')
|
|
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
|
#COMMIT_MESSAGE=$(git log --format=%B -n 1 ${COMMIT})
|
|
|
|
#version := $(subst -, ,$(shell git describe --long --dirty --tags))
|
|
#COMMIT := $(strip $(word 3, $(version)))
|
|
#COMMITS_PAST := $(strip $(word 2, $(version)))
|
|
#DIRTY := $(strip $(word 4, $(version)))
|
|
#ifneq ($(COMMITS_PAST), 0)
|
|
# BUILD_INFO_COMMITS := "."$(COMMITS_PAST)
|
|
#endif
|
|
#ifneq ($(DIRTY),)
|
|
# BUILD_INFO_DIRTY :="+"
|
|
#endif
|
|
|
|
#export BUILD_TAG :=$(strip $(word 1, $(version)))
|
|
#export BUILD_INFO := $(COMMIT)$(BUILD_INFO_COMMITS)$(BUILD_INFO_DIRTY)
|
|
|
|
#GIT_COMMIT=$(git describe --long --dirty --tags)
|
|
BUILD_MACHINE=$(whoami)@$(hostname)
|
|
BUILD_DATE=$(date +'%Y-%m-%d_%H:%M:%S')
|
|
|
|
echo "${TARGET}" ${VERSION_MAJOR}.${VERSION_MINOR}.${BUILD_VERSION}
|
|
${CMD} -c ${DIR}/build_version.c -o "${OUTPUT}" -DFIATLUX_FILENAME=\""${TARGET}"\"\
|
|
-DFIATLUX_VERSION_MAJOR=0 -DFIATLUX_VERSION_MINOR=1 -DFIATLUX_BUILD_NUM=${BUILD_VERSION} \
|
|
-DFIATLUX_GIT_COMMIT=\""${COMMIT}"\" -DFIATLUX_GIT_BRANCH=\""${BRANCH_NAME}"\" -DFIATLUX_GIT_AUTHOR=\""${AUTHOR}"\" \
|
|
-DFIATLUX_BUILD_DATE=\""${BUILD_DATE}"\" -DFIATLUX_BUILD_MACHINE=\""${BUILD_MACHINE}"\" \
|
|
-DFIATLUX_BUILD_CMD=\""${CMD}"\"
|
|
|