Get toolchain working

This commit is contained in:
Armando Montanez 2024-09-06 11:03:17 -07:00
parent 2bdc5d9a6b
commit 87a3dd9d0e
4 changed files with 24 additions and 18 deletions

View File

@ -3,8 +3,9 @@ module(
version = "0.0.1", version = "0.0.1",
) )
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "googletest", version = "1.15.2") bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "skylib", version = "1.7.1") bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc") bazel_dep(name = "rules_cc")
local_path_override(module_name = "rules_cc", path = "../..") local_path_override(module_name = "rules_cc", path = "../..")
@ -28,8 +29,6 @@ http_archive(
) )
register_toolchains( register_toolchains(
[
"//toolchain:host-linux-x86_64", "//toolchain:host-linux-x86_64",
],
dev_dependency = True, dev_dependency = True,
) )

View File

@ -1,5 +1,5 @@
#include "dynamic_answer.h" #include "dynamic_answer.h"
int dynamic_answer() { int dynamic_answer(void) {
return 24; return 24;
} }

View File

@ -15,7 +15,7 @@ cc_args(
actions = [ actions = [
"@rules_cc//cc/toolchains/actions:c_compile", "@rules_cc//cc/toolchains/actions:c_compile",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions", "@rules_cc//cc/toolchains/actions:cpp_compile_actions",
] ],
args = [ args = [
"-Wall", "-Wall",
"-Wextra", "-Wextra",
@ -23,18 +23,28 @@ cc_args(
], ],
) )
cc_args(
name = "no_canonical_prefixes",
actions = [
"@rules_cc//cc/toolchains/actions:c_compile",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions",
],
args = ["-no-canonical-prefixes"],
)
[ [
cc_toolchain( cc_toolchain(
name = "host-{}-config".format(platform), name = "host-{}-config".format(platform_name),
args = select({ args = select({
"@platforms//os:linux": [ "@platforms//os:linux": [
"@linux_sysroot//:sysroot", "@linux_sysroot//:sysroot",
], ],
"//conditions:default": [], "//conditions:default": [],
}) + [ }) + [
":no_canonical_prefixes",
":warnings", ":warnings",
], ],
tools = "@clang-{}//:all_tools".format(platform), tool_map = "@clang-{}//:all_tools".format(platform_name),
known_features = ["@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features"], known_features = ["@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features"],
enabled_features = ["@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features"], enabled_features = ["@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features"],
target_compatible_with = constraints, target_compatible_with = constraints,
@ -44,10 +54,11 @@ cc_args(
[ [
toolchain( toolchain(
name = "host-{}".format(platform), name = "host-{}".format(platform_name),
exec_compatible_with = constraints, exec_compatible_with = constraints,
target_compatible_with = constraints, target_compatible_with = constraints,
) toolchain = ":host-{}-config".format(platform_name),
toolchain = ":host_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
for platform_name, constraints in PLATFORMS.items()
] ]

View File

@ -8,8 +8,7 @@ cc_sysroot(
name = "sysroot", name = "sysroot",
sysroot = ":root", sysroot = ":root",
data = [":root"], data = [":root"],
implicit_include_directories = [ allowlist_include_directories = [
":usr-local-include",
":usr-include-x86_64-linux-gnu", ":usr-include-x86_64-linux-gnu",
":usr-include", ":usr-include",
], ],
@ -20,17 +19,14 @@ directory(
srcs = glob(["**/*"]), srcs = glob(["**/*"]),
) )
subdirectory(
name = "usr-local-include",
path = "usr/local/include",
)
subdirectory( subdirectory(
name = "usr-include-x86_64-linux-gnu", name = "usr-include-x86_64-linux-gnu",
path = "usr/include/x86_64-linux-gnu", path = "usr/include/x86_64-linux-gnu",
parent = ":root",
) )
subdirectory( subdirectory(
name = "usr-include", name = "usr-include",
path = "usr/include", path = "usr/include",
parent = ":root",
) )