mirror of https://github.com/bazelbuild/rules_cc
Get toolchain working
This commit is contained in:
parent
2bdc5d9a6b
commit
87a3dd9d0e
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "dynamic_answer.h"
|
#include "dynamic_answer.h"
|
||||||
|
|
||||||
int dynamic_answer() {
|
int dynamic_answer(void) {
|
||||||
return 24;
|
return 24;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_type = "@bazel_tools//tools/cpp:toolchain_type",
|
||||||
)
|
)
|
||||||
toolchain = ":host_toolchain",
|
for platform_name, constraints in PLATFORMS.items()
|
||||||
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -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",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue