Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions opam/solo5-cross-aarch64.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ license: "ISC"
dev-repo: "git+https://github.com/solo5/solo5.git"
build: [
["env" "TARGET_CC=aarch64-linux-gnu-gcc" "TARGET_LD=aarch64-linux-gnu-ld" "TARGET_OBJCOPY=aarch64-linux-gnu-objcopy" "./configure.sh" "--prefix=%{prefix}%"]
[make "V=1"]
["env" "SOLO5_VERSION=%{version}%" make "V=1"]
]
install: [make "V=1" "install-toolchain"]
install: ["env" "SOLO5_VERSION=%{version}%" make "V=1" "install-toolchain"]
depends: [
"conf-pkg-config" {build & os = "linux"}
"conf-libseccomp" {build & os = "linux"}
Expand Down
4 changes: 2 additions & 2 deletions opam/solo5.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ license: "ISC"
dev-repo: "git+https://github.com/solo5/solo5.git"
build: [
["./configure.sh" "--prefix=%{prefix}%"]
[make "V=1"]
["env" "SOLO5_VERSION=%{version}%" make "V=1"]
]
install: [make "V=1" "install"]
install: ["env" "SOLO5_VERSION=%{version}%" make "V=1" "install"]
depends: [
"conf-pkg-config" {build & os = "linux"}
"conf-libseccomp" {build & os = "linux"}
Expand Down
29 changes: 15 additions & 14 deletions scripts/gen_version_h.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,35 @@ die ()
[ $# -ne 1 ] && exit 1
VERSION_H="$1"

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

# Otherwise, use "git describe" to get the exact version of this tree, and
# generate a version.h from it.
GIT_VERSION="$(git -C . describe --dirty --tags --always)" ||
die "Could not determine Git version"

cat <<EOM >${VERSION_H}.tmp || die
/* Automatically generated, do not edit */

#ifndef __VERSION_H__
#define __VERSION_H__

#define SOLO5_VERSION "${GIT_VERSION}"
#define SOLO5_VERSION "${VERSION}"

#endif
EOM

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