Skip to content

Commit

Permalink
fix: Use a cmake-style configure for version stamp files.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 4, 2025
1 parent 04d4150 commit 722a058
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 27 deletions.
3 changes: 1 addition & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module(

# https://github.com/bazelbuild/platforms/releases
bazel_dep(name = "platforms", version = "0.0.10")

bazel_dep(name = "rules_license", version = "1.0.0")

# https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/curl
Expand All @@ -22,6 +21,6 @@ bazel_dep(name = "protobuf", version = "28.3")
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "4f28899228fb3ad0126897876f147ca15026151e",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)
2 changes: 1 addition & 1 deletion ci-tools
2 changes: 1 addition & 1 deletion hs-github-tools
2 changes: 1 addition & 1 deletion jvm-toxcore-c
Submodule jvm-toxcore-c updated 261 files
2 changes: 1 addition & 1 deletion qtox
Submodule qtox updated 629 files
9 changes: 5 additions & 4 deletions tools/built/src/home/.config/home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
then lib.removeSuffix "\n" (builtins.readFile tokenFile)
else "";

ASAN_OPTIONS = "color=always:detect_leaks=1:strict_string_checks=1:check_initialization_order=1:strict_init_order=1";
ASAN_OPTIONS = "color=always:detect_leaks=1:strict_string_checks=1:check_initialization_order=1:strict_init_order=1:external_symbolizer_path=${pkgs.llvm}/bin/llvm-symbolizer";
LSAN_OPTIONS = "report_objects=1";
MSAN_OPTIONS = "color=always";
TSAN_OPTIONS = "color=always,history_size=7,force_seq_cst_atomics=1";
UBSAN_OPTIONS = "color=always,print_stacktrace=1";
MSAN_OPTIONS = "color=always:external_symbolizer_path=${pkgs.llvm}/bin/llvm-symbolizer";
TSAN_OPTIONS = "color=always,history_size=7,force_seq_cst_atomics=1:external_symbolizer_path=${pkgs.llvm}/bin/llvm-symbolizer";
UBSAN_OPTIONS = "color=always,print_stacktrace=1:external_symbolizer_path=${pkgs.llvm}/bin/llvm-symbolizer";
};
home.sessionPath = [
"${config.home.homeDirectory}/.bin"
Expand All @@ -30,6 +30,7 @@
clang-tools # C++ code formatting
connect # for ssh proxy via tor
gdb # debugger for C code
github-cli # utilities for dealing with GitHub repos
gnupg # for signing git commits
go # for vscode to understand Go
haskell-language-server # for vscode to understand Haskell
Expand Down
19 changes: 8 additions & 11 deletions tools/project/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,11 @@ def workspace(projects, name = "workspace"):
tags = ["no-cross", "haskell"],
)

def mkstamp(name, hdr=None):
if hdr:
native.genrule(
name = name,
outs = [hdr],
cmd = """$(location //tools/project:mkstamp_c.sh) %s >$@""" % native.package_name(),
srcs = ["//tools/project:mkstamp_c.sh"],
stamp = True,
)
else:
fail("mkstamp requires a `hdr` argument")
def mkstamp(name, src, out):
native.genrule(
name = name,
outs = [out],
cmd = """$(location //tools/project:mkstamp_c.sh) %s $(location %s) >'$@'""" % (native.package_name(), src),
srcs = ["//tools/project:mkstamp_c.sh", src],
stamp = True,
)
4 changes: 2 additions & 2 deletions tools/project/mkstamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ REPOS=(c-toxcore qtox)
for repo in "${REPOS[@]}"; do
cd "$repo"
REPO="$(echo "$repo" | tr 'a-z-' 'A-Z_')"
echo "STABLE_${REPO}_GIT_DESCRIBE_EXACT" "$(git describe --exact-match --tags HEAD 2>/dev/null || echo 'Nightly')"
echo "STABLE_${REPO}_GIT_DESCRIBE" "$(git describe --tags 2>/dev/null || echo 'Nightly')"
echo "STABLE_${REPO}_GIT_DESCRIBE_EXACT" "$(git describe --tags --match 'v*' --exact-match HEAD 2>/dev/null || echo 'Nightly')"
echo "STABLE_${REPO}_GIT_DESCRIBE" "$(git describe --tags --match 'v*' 2>/dev/null || echo 'Nightly')"
echo "STABLE_${REPO}_GIT_VERSION" "$(git rev-parse HEAD 2>/dev/null || echo 'build without git')"
cd -
done
25 changes: 24 additions & 1 deletion tools/project/mkstamp_c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,28 @@

set -eu

# Usage: mkstamp_c.sh <repo> version.cpp.in > version.cpp
#
# For each of the STABLE_{REPO}_* variables, do a search/replace in the input
# file, replacing the variable name with the value. Variable names in the input
# are e.g. @GIT_VERSION@.

REPO="$(echo "$1" | cut -d/ -f1 | tr 'a-z-' 'A-Z_')"
grep "^STABLE_${REPO}_" bazel-out/stable-status.txt | sed -Ee "s/^STABLE_${REPO}_([^ ]+) (.*)/#define \\1 \"\\2\"/"
INPUT="$2"

# First make a map of all the variables and their values.
declare -A STABLE

while read -r line; do
if [[ "$line" =~ ^STABLE_${REPO}_([A-Z_]+)\ (.*) ]]; then
STABLE["${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}"
fi
done <bazel-out/stable-status.txt

# Then do the search/replace.
while IFS= read -r line; do
for key in "${!STABLE[@]}"; do
line="${line//@${key}@/${STABLE[$key]}}"
done
echo "$line"
done <"$INPUT"
2 changes: 1 addition & 1 deletion toxins
Submodule toxins updated 2 files
+9 −3 .astylerc
+9 −8 echobot/echobot.c

0 comments on commit 722a058

Please sign in to comment.