build: Unbreak Meson build on FreeBSD (#3549)

* generateVersion.sh: move cp(1) flags before arguments

POSIX and BSD cp(1) don't support flags after arguments e.g.,

cp: -fr is not a directory

* generateVersion.sh: switch to sed(1) -i for better compatibility

On BSDs awk is usually The One True Awk thus doesn't support `-i inplace`.

awk: unknown option -i ignored
awk: can't open file {sub(/@HASH@/,"1234567890abcdef")}1
 source line number 1
This commit is contained in:
Jan Beich 2023-10-11 18:38:34 +00:00 committed by GitHub
parent 34455844e9
commit 0cf3d5b39a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,14 +1,14 @@
#!/bin/sh #!/bin/sh
cp ./src/version.h.in ./src/version.h -fr cp -fr ./src/version.h.in ./src/version.h
HASH=$(git rev-parse HEAD) HASH=$(git rev-parse HEAD)
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
MESSAGE=$(git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g') MESSAGE=$(git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g')
DIRTY=$(git diff-index --quiet HEAD -- || echo \"dirty\") DIRTY=$(git diff-index --quiet HEAD -- || echo dirty)
TAG=$(git describe --tags) TAG=$(git describe --tags)
awk -i inplace "{sub(/@HASH@/,\"${HASH}\")}1" ./src/version.h sed -i -e "s#@HASH@#${HASH}#" ./src/version.h
awk -i inplace "{sub(/@BRANCH@/,\"${BRANCH}\")}1" ./src/version.h sed -i -e "s#@BRANCH@#${BRANCH}#" ./src/version.h
awk -i inplace "{sub(/@MESSAGE@/,\"${MESSAGE}\")}1" ./src/version.h sed -i -e "s#@MESSAGE@#${MESSAGE}#" ./src/version.h
awk -i inplace "{sub(/@DIRTY@/,\"${DIRTY}\")}1" ./src/version.h sed -i -e "s#@DIRTY@#${DIRTY}#" ./src/version.h
awk -i inplace "{sub(/@TAG@/,\"${TAG}\")}1" ./src/version.h sed -i -e "s#@TAG@#${TAG}#" ./src/version.h