mirror of https://github.com/bazelbuild/rules_cc
Fix load("//tools/cpp:cc_toolchain_config_lib.bzl") to load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl")
And add a test checking the full output from the migrator for a simple CROSSTOOL. Issue #5380 RELNOTES: None. PiperOrigin-RevId: 239153961
This commit is contained in:
parent
3b89ccfbe7
commit
943183cae8
|
@ -27,7 +27,7 @@ type CToolchainIdentifier struct {
|
||||||
|
|
||||||
// Writes the load statement for the cc_toolchain_config_lib
|
// Writes the load statement for the cc_toolchain_config_lib
|
||||||
func getCcToolchainConfigHeader() string {
|
func getCcToolchainConfigHeader() string {
|
||||||
return `load("//tools/cpp:cc_toolchain_config_lib.bzl",
|
return `load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
|
||||||
"action_config",
|
"action_config",
|
||||||
"artifact_name_pattern",
|
"artifact_name_pattern",
|
||||||
"env_entry",
|
"env_entry",
|
||||||
|
|
|
@ -1530,3 +1530,150 @@ func TestFeatureDeclaration(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRule(t *testing.T) {
|
||||||
|
simpleToolchain := getSimpleCToolchain("simple")
|
||||||
|
expected := `load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
|
||||||
|
"action_config",
|
||||||
|
"artifact_name_pattern",
|
||||||
|
"env_entry",
|
||||||
|
"env_set",
|
||||||
|
"feature",
|
||||||
|
"feature_set",
|
||||||
|
"flag_group",
|
||||||
|
"flag_set",
|
||||||
|
"make_variable",
|
||||||
|
"tool",
|
||||||
|
"tool_path",
|
||||||
|
"variable_with_value",
|
||||||
|
"with_feature_set",
|
||||||
|
)
|
||||||
|
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
|
||||||
|
|
||||||
|
def _impl(ctx):
|
||||||
|
toolchain_identifier = "id-simple"
|
||||||
|
|
||||||
|
host_system_name = "host-simple"
|
||||||
|
|
||||||
|
target_system_name = "target-simple"
|
||||||
|
|
||||||
|
target_cpu = "cpu-simple"
|
||||||
|
|
||||||
|
target_libc = "libc-simple"
|
||||||
|
|
||||||
|
compiler = "compiler-simple"
|
||||||
|
|
||||||
|
abi_version = "version-simple"
|
||||||
|
|
||||||
|
abi_libc_version = "libc_version-simple"
|
||||||
|
|
||||||
|
cc_target_os = None
|
||||||
|
|
||||||
|
builtin_sysroot = None
|
||||||
|
|
||||||
|
all_compile_actions = [
|
||||||
|
ACTION_NAMES.c_compile,
|
||||||
|
ACTION_NAMES.cpp_compile,
|
||||||
|
ACTION_NAMES.linkstamp_compile,
|
||||||
|
ACTION_NAMES.assemble,
|
||||||
|
ACTION_NAMES.preprocess_assemble,
|
||||||
|
ACTION_NAMES.cpp_header_parsing,
|
||||||
|
ACTION_NAMES.cpp_module_compile,
|
||||||
|
ACTION_NAMES.cpp_module_codegen,
|
||||||
|
ACTION_NAMES.clif_match,
|
||||||
|
ACTION_NAMES.lto_backend,
|
||||||
|
]
|
||||||
|
|
||||||
|
all_cpp_compile_actions = [
|
||||||
|
ACTION_NAMES.cpp_compile,
|
||||||
|
ACTION_NAMES.linkstamp_compile,
|
||||||
|
ACTION_NAMES.cpp_header_parsing,
|
||||||
|
ACTION_NAMES.cpp_module_compile,
|
||||||
|
ACTION_NAMES.cpp_module_codegen,
|
||||||
|
ACTION_NAMES.clif_match,
|
||||||
|
]
|
||||||
|
|
||||||
|
preprocessor_compile_actions = [
|
||||||
|
ACTION_NAMES.c_compile,
|
||||||
|
ACTION_NAMES.cpp_compile,
|
||||||
|
ACTION_NAMES.linkstamp_compile,
|
||||||
|
ACTION_NAMES.preprocess_assemble,
|
||||||
|
ACTION_NAMES.cpp_header_parsing,
|
||||||
|
ACTION_NAMES.cpp_module_compile,
|
||||||
|
ACTION_NAMES.clif_match,
|
||||||
|
]
|
||||||
|
|
||||||
|
codegen_compile_actions = [
|
||||||
|
ACTION_NAMES.c_compile,
|
||||||
|
ACTION_NAMES.cpp_compile,
|
||||||
|
ACTION_NAMES.linkstamp_compile,
|
||||||
|
ACTION_NAMES.assemble,
|
||||||
|
ACTION_NAMES.preprocess_assemble,
|
||||||
|
ACTION_NAMES.cpp_module_codegen,
|
||||||
|
ACTION_NAMES.lto_backend,
|
||||||
|
]
|
||||||
|
|
||||||
|
all_link_actions = [
|
||||||
|
ACTION_NAMES.cpp_link_executable,
|
||||||
|
ACTION_NAMES.cpp_link_dynamic_library,
|
||||||
|
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
|
||||||
|
]
|
||||||
|
|
||||||
|
action_configs = []
|
||||||
|
|
||||||
|
features = []
|
||||||
|
|
||||||
|
cxx_builtin_include_directories = []
|
||||||
|
|
||||||
|
artifact_name_patterns = []
|
||||||
|
|
||||||
|
make_variables = []
|
||||||
|
|
||||||
|
tool_paths = []
|
||||||
|
|
||||||
|
|
||||||
|
out = ctx.actions.declare_file(ctx.label.name)
|
||||||
|
ctx.actions.write(out, "Fake executable")
|
||||||
|
return [
|
||||||
|
cc_common.create_cc_toolchain_config_info(
|
||||||
|
ctx = ctx,
|
||||||
|
features = features,
|
||||||
|
action_configs = action_configs,
|
||||||
|
artifact_name_patterns = artifact_name_patterns,
|
||||||
|
cxx_builtin_include_directories = cxx_builtin_include_directories,
|
||||||
|
toolchain_identifier = toolchain_identifier,
|
||||||
|
host_system_name = host_system_name,
|
||||||
|
target_system_name = target_system_name,
|
||||||
|
target_cpu = target_cpu,
|
||||||
|
target_libc = target_libc,
|
||||||
|
compiler = compiler,
|
||||||
|
abi_version = abi_version,
|
||||||
|
abi_libc_version = abi_libc_version,
|
||||||
|
tool_paths = tool_paths,
|
||||||
|
make_variables = make_variables,
|
||||||
|
builtin_sysroot = builtin_sysroot,
|
||||||
|
cc_target_os = cc_target_os
|
||||||
|
),
|
||||||
|
DefaultInfo(
|
||||||
|
executable = out,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
cc_toolchain_config = rule(
|
||||||
|
implementation = _impl,
|
||||||
|
attrs = {
|
||||||
|
"cpu": attr.string(mandatory=True, values=["cpu-simple"]),
|
||||||
|
},
|
||||||
|
provides = [CcToolchainConfigInfo],
|
||||||
|
executable = True,
|
||||||
|
)
|
||||||
|
`
|
||||||
|
crosstool := makeCrosstool([]string{simpleToolchain})
|
||||||
|
got, err := Transform(crosstool)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("CROSSTOOL conversion failed: %v", err)
|
||||||
|
}
|
||||||
|
if got != expected {
|
||||||
|
t.Fatalf("Expected:\n%v\nGot:\n%v\nTested CROSSTOOL:\n%v",
|
||||||
|
expected, got, simpleToolchain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue