mirror of
https://github.com/urbit/vere.git
synced 2024-08-16 07:10:46 +03:00
f7a75b51f0
This adds a macro "vere_library" which supports our concepts of debug and release builds, and gives finer-grained control over which copts/linkopts are passed and when. Takes advantage of bazel's "compilation_mode={dbg,opt}" to control debug/optimized builds.
215 lines
4.3 KiB
Python
215 lines
4.3 KiB
Python
load("//bazel:common_settings.bzl", "string_flag")
|
|
exports_files(["PACE"])
|
|
|
|
#
|
|
# OS-CPU CONFIG SETTINGS
|
|
#
|
|
|
|
config_setting(
|
|
name = "linux_aarch64",
|
|
constraint_values = [
|
|
"@platforms//os:linux",
|
|
"@platforms//cpu:aarch64",
|
|
],
|
|
)
|
|
|
|
config_setting(
|
|
name = "linux_x86_64",
|
|
constraint_values = [
|
|
"@platforms//os:linux",
|
|
"@platforms//cpu:x86_64",
|
|
],
|
|
)
|
|
|
|
config_setting(
|
|
name = "macos_aarch64",
|
|
constraint_values = [
|
|
"@platforms//os:macos",
|
|
"@platforms//cpu:aarch64",
|
|
],
|
|
)
|
|
|
|
config_setting(
|
|
name = "macos_x86_64",
|
|
constraint_values = [
|
|
"@platforms//os:macos",
|
|
"@platforms//cpu:x86_64",
|
|
],
|
|
)
|
|
|
|
#
|
|
# CONFIGS DETAILING WHEN TO ENABLE CERTAIN FEATURES BY DEFAULT.
|
|
# CHANGES BEHAVIOR OF //bazel/common_settings.bzl:vere_library.
|
|
#
|
|
|
|
config_setting(
|
|
name = "thinlto",
|
|
constraint_values = [
|
|
"@platforms//os:macos",
|
|
],
|
|
values = {
|
|
"compilation_mode": "opt"
|
|
}
|
|
)
|
|
|
|
config_setting(
|
|
name = "lto",
|
|
constraint_values = [
|
|
"@platforms//os:linux",
|
|
],
|
|
values = {
|
|
"compilation_mode": "opt"
|
|
}
|
|
)
|
|
|
|
config_setting(
|
|
name = "debug",
|
|
values = {
|
|
"compilation_mode": "dbg"
|
|
}
|
|
)
|
|
|
|
#
|
|
# COMPILERS
|
|
#
|
|
|
|
# Version flag for clang.
|
|
string_flag(
|
|
name = "clang_version",
|
|
# macOS uses `clang-14.0.3` by default.
|
|
build_setting_default = "14.0.3",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Version flag for gcc.
|
|
string_flag(
|
|
name = "gcc_version",
|
|
# musl-cross-make uses `gcc-9.4.0` by default.
|
|
build_setting_default = "9.4.0",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
#
|
|
# PLATFORMS
|
|
#
|
|
# A platform takes one of two formats: `<compiler>-<os>-<cpu>` or `<os>-<cpu>`
|
|
# if the compiler is unspecified.
|
|
|
|
# Linux aarch64 platform with unspecified compiler.
|
|
platform(
|
|
name = "linux-aarch64",
|
|
constraint_values = [
|
|
"@platforms//os:linux",
|
|
"@platforms//cpu:aarch64",
|
|
],
|
|
)
|
|
|
|
# Linux x86_64 platform with unspecified compiler.
|
|
platform(
|
|
name = "linux-x86_64",
|
|
constraint_values = [
|
|
"@platforms//os:linux",
|
|
"@platforms//cpu:x86_64",
|
|
],
|
|
)
|
|
|
|
# Linux x86_64 platform with gcc.
|
|
platform(
|
|
name = "gcc-linux-x86_64",
|
|
constraint_values = [
|
|
":gcc",
|
|
"@platforms//os:linux",
|
|
"@platforms//cpu:x86_64",
|
|
],
|
|
)
|
|
|
|
platform(
|
|
name = "macos-aarch64",
|
|
constraint_values = [
|
|
"@platforms//os:macos",
|
|
"@platforms//cpu:aarch64",
|
|
],
|
|
)
|
|
|
|
platform(
|
|
name = "clang-macos-aarch64",
|
|
constraint_values = [
|
|
":clang",
|
|
"@platforms//os:macos",
|
|
"@platforms//cpu:aarch64",
|
|
],
|
|
)
|
|
|
|
platform(
|
|
name = "macos-x86_64",
|
|
constraint_values = [
|
|
"@platforms//os:macos",
|
|
"@platforms//cpu:x86_64",
|
|
],
|
|
)
|
|
|
|
platform(
|
|
name = "clang-macos-x86_64",
|
|
constraint_values = [
|
|
":clang",
|
|
"@platforms//os:macos",
|
|
"@platforms//cpu:x86_64",
|
|
],
|
|
)
|
|
|
|
# Produce the `U3_VERE_PACE` macro.
|
|
genrule(
|
|
name = "pace_hdr",
|
|
srcs = ["PACE"],
|
|
outs = ["pace.h"],
|
|
cmd = """
|
|
echo '#ifndef URBIT_PACE_H' > $@
|
|
echo '#define URBIT_PACE_H' >> $@
|
|
printf '#define U3_VERE_PACE "%s"\n' $$(cat $< | tr -d '\n') >> $@
|
|
echo '#endif' >> $@
|
|
""",
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
genrule(
|
|
name = "version_str",
|
|
srcs = [
|
|
# Bazel warns dependency checking directories is unsound, but there's no
|
|
# apparent way around depending on .git if we want to run git commands.
|
|
".git",
|
|
"PACE",
|
|
"VERSION",
|
|
],
|
|
outs = ["version"],
|
|
cmd = """
|
|
version_num=$$(cat $(execpath VERSION) | tr -d '\n')
|
|
commit_sha=$$(git rev-parse --short HEAD)
|
|
if [ $$(tr -d '\n' < $(execpath PACE)) == "live" ]; then
|
|
version="$$version_num"
|
|
else
|
|
version="$$version_num-$$commit_sha"
|
|
fi
|
|
echo -n $$version > $@
|
|
""",
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
# Produce the `URBIT_VERSION` macro.
|
|
genrule(
|
|
name = "version_hdr",
|
|
srcs = [":version_str"],
|
|
outs = ["version.h"],
|
|
cmd = """
|
|
echo '#ifndef URBIT_VERSION_H' > $@
|
|
echo '#define URBIT_VERSION_H' >> $@
|
|
printf '#define URBIT_VERSION "%s"\n' $$(cat $< | tr -d '\n') >> $@
|
|
echo '#endif' >> $@
|
|
""",
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
alias(
|
|
name = "urbit",
|
|
actual = "//pkg/vere:urbit",
|
|
)
|