2023-01-09 20:42:51 +03:00
|
|
|
load("//bazel:common_settings.bzl", "string_flag")
|
2023-03-13 18:58:40 +03:00
|
|
|
exports_files(["PACE"])
|
2023-01-09 20:42:51 +03:00
|
|
|
|
2023-01-09 19:28:47 +03:00
|
|
|
#
|
|
|
|
# OS-CPU CONFIG SETTINGS
|
|
|
|
#
|
|
|
|
|
|
|
|
config_setting(
|
2023-01-09 22:52:35 +03:00
|
|
|
name = "linux_aarch64",
|
2023-01-09 19:28:47 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:linux",
|
2023-01-09 22:52:35 +03:00
|
|
|
"@platforms//cpu:aarch64",
|
2023-01-09 19:28:47 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
2023-01-09 20:42:51 +03:00
|
|
|
name = "linux_x86_64",
|
2023-01-09 19:28:47 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:linux",
|
|
|
|
"@platforms//cpu:x86_64",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
2023-01-09 22:52:35 +03:00
|
|
|
name = "macos_aarch64",
|
2023-01-09 19:28:47 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:macos",
|
2023-01-09 22:52:35 +03:00
|
|
|
"@platforms//cpu:aarch64",
|
2023-01-09 19:28:47 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
2023-01-09 20:42:51 +03:00
|
|
|
name = "macos_x86_64",
|
2023-01-09 19:28:47 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:macos",
|
|
|
|
"@platforms//cpu:x86_64",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-06-23 00:53:13 +03:00
|
|
|
#
|
|
|
|
# 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"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-01-09 19:28:47 +03:00
|
|
|
#
|
2023-01-09 20:42:51 +03:00
|
|
|
# COMPILERS
|
2023-01-09 19:28:47 +03:00
|
|
|
#
|
|
|
|
|
2023-01-09 20:42:51 +03:00
|
|
|
# Version flag for clang.
|
|
|
|
string_flag(
|
|
|
|
name = "clang_version",
|
2024-01-04 22:23:01 +03:00
|
|
|
# macOS uses `clang-15.0.0` by default.
|
|
|
|
build_setting_default = "15.0.0",
|
2023-01-09 20:42:51 +03:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Version flag for gcc.
|
|
|
|
string_flag(
|
|
|
|
name = "gcc_version",
|
2023-01-09 21:54:11 +03:00
|
|
|
# musl-cross-make uses `gcc-9.4.0` by default.
|
|
|
|
build_setting_default = "9.4.0",
|
2023-01-09 20:42:51 +03:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
2023-01-09 19:28:47 +03:00
|
|
|
#
|
|
|
|
# PLATFORMS
|
|
|
|
#
|
2023-01-09 20:42:51 +03:00
|
|
|
# A platform takes one of two formats: `<compiler>-<os>-<cpu>` or `<os>-<cpu>`
|
|
|
|
# if the compiler is unspecified.
|
|
|
|
|
2023-01-09 22:52:35 +03:00
|
|
|
# Linux aarch64 platform with unspecified compiler.
|
2023-01-09 20:42:51 +03:00
|
|
|
platform(
|
2023-01-09 22:52:35 +03:00
|
|
|
name = "linux-aarch64",
|
2023-01-09 20:42:51 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:linux",
|
2023-01-09 22:52:35 +03:00
|
|
|
"@platforms//cpu:aarch64",
|
2023-01-09 20:42:51 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# 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.
|
2023-01-09 19:28:47 +03:00
|
|
|
platform(
|
|
|
|
name = "gcc-linux-x86_64",
|
|
|
|
constraint_values = [
|
|
|
|
":gcc",
|
|
|
|
"@platforms//os:linux",
|
|
|
|
"@platforms//cpu:x86_64",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-01-09 21:05:24 +03:00
|
|
|
platform(
|
2023-01-09 22:52:35 +03:00
|
|
|
name = "macos-aarch64",
|
2023-01-09 21:05:24 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:macos",
|
2023-01-09 22:52:35 +03:00
|
|
|
"@platforms//cpu:aarch64",
|
2023-01-09 21:05:24 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-01-09 21:03:58 +03:00
|
|
|
platform(
|
2023-01-09 22:52:35 +03:00
|
|
|
name = "clang-macos-aarch64",
|
2023-01-09 21:03:58 +03:00
|
|
|
constraint_values = [
|
|
|
|
":clang",
|
|
|
|
"@platforms//os:macos",
|
2023-01-09 22:52:35 +03:00
|
|
|
"@platforms//cpu:aarch64",
|
2023-01-09 21:03:58 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
platform(
|
2023-01-09 21:05:24 +03:00
|
|
|
name = "macos-x86_64",
|
2023-01-09 21:03:58 +03:00
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:macos",
|
2023-01-09 21:05:24 +03:00
|
|
|
"@platforms//cpu:x86_64",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
platform(
|
|
|
|
name = "clang-macos-x86_64",
|
|
|
|
constraint_values = [
|
|
|
|
":clang",
|
|
|
|
"@platforms//os:macos",
|
|
|
|
"@platforms//cpu:x86_64",
|
2023-01-09 21:03:58 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-01-11 23:13:18 +03:00
|
|
|
# Produce the `U3_VERE_PACE` macro.
|
|
|
|
genrule(
|
2023-01-18 20:24:52 +03:00
|
|
|
name = "pace_hdr",
|
2023-01-11 23:13:18 +03:00
|
|
|
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(
|
2023-01-18 20:24:52 +03:00
|
|
|
name = "version_str",
|
2023-01-11 23:13:18 +03:00
|
|
|
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",
|
|
|
|
],
|
2023-01-18 20:24:52 +03:00
|
|
|
outs = ["version"],
|
2023-01-11 23:13:18 +03:00
|
|
|
cmd = """
|
2023-01-18 20:24:52 +03:00
|
|
|
version_num=$$(cat $(execpath VERSION) | tr -d '\n')
|
|
|
|
commit_sha=$$(git rev-parse --short HEAD)
|
|
|
|
if [ $$(tr -d '\n' < $(execpath PACE)) == "live" ]; then
|
2023-01-11 23:13:18 +03:00
|
|
|
version="$$version_num"
|
|
|
|
else
|
|
|
|
version="$$version_num-$$commit_sha"
|
|
|
|
fi
|
2023-01-18 20:24:52 +03:00
|
|
|
echo -n $$version > $@
|
|
|
|
""",
|
|
|
|
visibility = ["//:__subpackages__"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Produce the `URBIT_VERSION` macro.
|
|
|
|
genrule(
|
|
|
|
name = "version_hdr",
|
|
|
|
srcs = [":version_str"],
|
|
|
|
outs = ["version.h"],
|
|
|
|
cmd = """
|
2023-01-11 23:13:18 +03:00
|
|
|
echo '#ifndef URBIT_VERSION_H' > $@
|
|
|
|
echo '#define URBIT_VERSION_H' >> $@
|
2023-01-18 20:24:52 +03:00
|
|
|
printf '#define URBIT_VERSION "%s"\n' $$(cat $< | tr -d '\n') >> $@
|
2023-01-11 23:13:18 +03:00
|
|
|
echo '#endif' >> $@
|
|
|
|
""",
|
|
|
|
visibility = ["//:__subpackages__"],
|
|
|
|
)
|
|
|
|
|
2023-01-09 19:28:47 +03:00
|
|
|
alias(
|
|
|
|
name = "urbit",
|
|
|
|
actual = "//pkg/vere:urbit",
|
|
|
|
)
|