mirror of
https://github.com/urbit/vere.git
synced 2024-09-11 03:45:31 +03:00
182 lines
3.7 KiB
Python
182 lines
3.7 KiB
Python
load("//bazel:common_settings.bzl", "string_flag")
|
|
|
|
#
|
|
# 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",
|
|
],
|
|
)
|
|
|
|
#
|
|
# COMPILERS
|
|
#
|
|
|
|
# Version flag for clang.
|
|
string_flag(
|
|
name = "clang_version",
|
|
# macOS uses `clang-14.0.0` by default.
|
|
build_setting_default = "14.0.0",
|
|
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",
|
|
)
|