2023-05-01 16:23:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-09-15 20:59:49 +00:00
|
|
|
CC=$1
|
2023-05-01 16:23:47 +00:00
|
|
|
|
2023-09-15 20:59:49 +00:00
|
|
|
build_number="0"
|
|
|
|
build_commit="unknown"
|
|
|
|
build_compiler="unknown"
|
|
|
|
build_target="unknown"
|
|
|
|
|
|
|
|
if out=$(git rev-list --count HEAD); then
|
|
|
|
# git is broken on WSL so we need to strip extra newlines
|
|
|
|
build_number=$(printf '%s' "$out" | tr -d '\n')
|
|
|
|
fi
|
|
|
|
|
|
|
|
if out=$(git rev-parse --short HEAD); then
|
|
|
|
build_commit=$(printf '%s' "$out" | tr -d '\n')
|
|
|
|
fi
|
|
|
|
|
|
|
|
if out=$($CC --version | head -1); then
|
|
|
|
build_compiler=$out
|
2023-05-01 16:23:47 +00:00
|
|
|
fi
|
|
|
|
|
2023-09-15 20:59:49 +00:00
|
|
|
if out=$($CC -dumpmachine); then
|
|
|
|
build_target=$out
|
2023-05-01 16:23:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "#ifndef BUILD_INFO_H"
|
|
|
|
echo "#define BUILD_INFO_H"
|
2023-09-15 20:59:49 +00:00
|
|
|
echo
|
|
|
|
echo "#define BUILD_NUMBER $build_number"
|
|
|
|
echo "#define BUILD_COMMIT \"$build_commit\""
|
|
|
|
echo "#define BUILD_COMPILER \"$build_compiler\""
|
|
|
|
echo "#define BUILD_TARGET \"$build_target\""
|
|
|
|
echo
|
2023-05-01 16:23:47 +00:00
|
|
|
echo "#endif // BUILD_INFO_H"
|