Skip to content

Commit a9ecebc

Browse files
committed
TMP: stamp version.h from $SOLO5_VERSION for tarball pins (#642)
Carried so the macOS e2e can tar-pin solo5; the real change is #642. Drop once that lands.
1 parent 4a60437 commit a9ecebc

3 files changed

Lines changed: 20 additions & 19 deletions

File tree

opam/solo5-cross-aarch64.opam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ dev-repo: "git+https://github.com/solo5/solo5.git"
1212
build: [
1313
["env" "TARGET_CC=aarch64-linux-gnu-gcc" "TARGET_LD=aarch64-linux-gnu-ld" "TARGET_OBJCOPY=aarch64-linux-gnu-objcopy" "./configure.sh" "--prefix=%{prefix}%"] {os != "macos"}
1414
["env" "TARGET_CC=clang -target aarch64-linux-gnu" "TARGET_LD=ld.lld" "TARGET_OBJCOPY=llvm-objcopy" "./configure.sh" "--prefix=%{prefix}%"] {os = "macos"}
15-
[make "V=1"]
15+
["env" "SOLO5_VERSION=%{version}%" make "V=1"]
1616
]
1717
install: [
18-
[make "V=1" "install-toolchain"]
19-
[make "V=1" "install-headers"] {os = "macos"}
18+
["env" "SOLO5_VERSION=%{version}%" make "V=1" "install-toolchain"]
19+
["env" "SOLO5_VERSION=%{version}%" make "V=1" "install-headers"] {os = "macos"}
2020
]
2121
depends: [
2222
"conf-pkg-config" {build & os = "linux"}

opam/solo5.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ license: "ISC"
1111
dev-repo: "git+https://github.com/solo5/solo5.git"
1212
build: [
1313
["./configure.sh" "--prefix=%{prefix}%"]
14-
[make "V=1"]
14+
["env" "SOLO5_VERSION=%{version}%" make "V=1"]
1515
]
16-
install: [make "V=1" "install"]
16+
install: ["env" "SOLO5_VERSION=%{version}%" make "V=1" "install"]
1717
depends: [
1818
"conf-pkg-config" {build & os = "linux"}
1919
"conf-libseccomp" {build & os = "linux"}

scripts/gen_version_h.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,35 @@ die ()
1010
[ $# -ne 1 ] && exit 1
1111
VERSION_H="$1"
1212

13-
# If we are being run from a release tarball, then a version.h.distrib must
14-
# be present, and we always use that as our source of truth. Allow ./.git
15-
# to be a file to support git worktrees.
16-
if [ ! -d "./.git" -a ! -f "./.git" ]; then
17-
if [ ! -f "${VERSION_H}.distrib" ]; then
18-
die "${VERSION_H}.distrib: Not found, and we are not in a Git tree"
19-
fi
13+
# Determine the version, in order of precedence:
14+
# 1. "git describe" in a real checkout (allow ./.git to be a file for worktrees)
15+
# 2. version.h.distrib shipped in a release tarball
16+
# 3. $SOLO5_VERSION for an exported snapshot (e.g. an opam tarball pin) that has
17+
# neither a Git tree nor a version.h.distrib
18+
if [ -d "./.git" -o -f "./.git" ]; then
19+
VERSION="$(git -C . describe --dirty --tags --always)" ||
20+
die "Could not determine Git version"
21+
elif [ -f "${VERSION_H}.distrib" ]; then
2022
cp "${VERSION_H}.distrib" "${VERSION_H}" || die
2123
exit 0
24+
elif [ -n "${SOLO5_VERSION}" ]; then
25+
VERSION="${SOLO5_VERSION}"
26+
else
27+
die "not a Git tree, ${VERSION_H}.distrib not found, and SOLO5_VERSION unset"
2228
fi
2329

24-
# Otherwise, use "git describe" to get the exact version of this tree, and
25-
# generate a version.h from it.
26-
GIT_VERSION="$(git -C . describe --dirty --tags --always)" ||
27-
die "Could not determine Git version"
28-
2930
cat <<EOM >${VERSION_H}.tmp || die
3031
/* Automatically generated, do not edit */
3132
3233
#ifndef __VERSION_H__
3334
#define __VERSION_H__
3435
35-
#define SOLO5_VERSION "${GIT_VERSION}"
36+
#define SOLO5_VERSION "${VERSION}"
3637
3738
#endif
3839
EOM
3940

40-
# Only touch the target file if it does not exist yet or Git version differs.
41+
# Only touch the target file if it does not exist yet or the version differs.
4142
if [ -f ${VERSION_H} ] && diff -q ${VERSION_H} ${VERSION_H}.tmp >/dev/null; then
4243
rm ${VERSION_H}.tmp || die
4344
else

0 commit comments

Comments
 (0)