extract version from defs.bzl; gate buildhash on optimized build
This commit is contained in:
parent
7cd2e9618f
commit
c179a2b45b
2
.bazelrc
2
.bazelrc
@ -1,7 +1,5 @@
|
||||
common --enable_platform_specific_config
|
||||
common --experimental_repository_cache_hardlinks
|
||||
#common --symlink_prefix=.bazel/
|
||||
#common --experimental_no_product_name_out_symlink
|
||||
|
||||
# specify python path on Windows for pyo3 compile
|
||||
build:windows --action_env="PYTHON_SYS_EXECUTABLE=c:\\python\\python.exe"
|
||||
|
21
BUILD.bazel
21
BUILD.bazel
@ -1,8 +1,22 @@
|
||||
config_setting(
|
||||
name = "release",
|
||||
values = {
|
||||
"compilation_mode": "opt",
|
||||
},
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "buildinfo_gen",
|
||||
name = "buildinfo",
|
||||
srcs = ["//:defs.bzl"],
|
||||
outs = ["buildinfo.txt"],
|
||||
cmd = "grep STABLE_ bazel-out/stable-status.txt > $@",
|
||||
cmd = select({
|
||||
"release": "$(location //scripts:buildinfo) $(location //:defs.bzl) bazel-out/stable-status.txt release > $@",
|
||||
"//conditions:default": "$(location //scripts:buildinfo) $(location //:defs.bzl) bazel-out/stable-status.txt devel > $@",
|
||||
}),
|
||||
stamp = 1,
|
||||
tools = [
|
||||
"//scripts:buildinfo",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
@ -11,3 +25,6 @@ alias(
|
||||
actual = "//ts:tsconfig.json",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
# for version info
|
||||
exports_files(["defs.bzl"])
|
||||
|
7
scripts/BUILD.bazel
Normal file
7
scripts/BUILD.bazel
Normal file
@ -0,0 +1,7 @@
|
||||
py_binary(
|
||||
name = "buildinfo",
|
||||
srcs = ["buildinfo.py"],
|
||||
data = ["//:defs.bzl"],
|
||||
stamp = 1,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
23
scripts/buildinfo.py
Normal file
23
scripts/buildinfo.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
defs_file = sys.argv[1]
|
||||
stamp_file = sys.argv[2]
|
||||
release_mode = sys.argv[3] == "release"
|
||||
|
||||
version_re = re.compile('anki_version = "(.*)"')
|
||||
|
||||
# extract version number from defs.bzl
|
||||
for line in open(defs_file).readlines():
|
||||
if ver := version_re.match(line):
|
||||
print(f"STABLE_VERSION {ver.group(1)}")
|
||||
|
||||
for line in open(stamp_file).readlines():
|
||||
if line.startswith("STABLE_BUILDHASH"):
|
||||
if release_mode:
|
||||
print(line.strip())
|
||||
else:
|
||||
# if not in release mode, map buildhash to a consistent value
|
||||
print("STABLE_BUILDHASH dev")
|
@ -1,8 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "STABLE_VERSION 2.1.36"
|
||||
if [ "$ANKI_RELEASE" != "" ]; then
|
||||
echo "STABLE_BUILDHASH $(git rev-parse --short=8 HEAD || echo nogit)"
|
||||
else
|
||||
echo "STABLE_BUILDHASH dev"
|
||||
fi
|
||||
echo "STABLE_BUILDHASH $(git rev-parse --short=8 HEAD || echo nogit)"
|
||||
|
Loading…
Reference in New Issue
Block a user