use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CppLinkActionTest method testInterfaceOutputForDynamicLibrary.
@Test
public void testInterfaceOutputForDynamicLibrary() throws Exception {
FeatureConfiguration featureConfiguration = CcToolchainFeaturesTest.buildFeatures("feature {", " name: 'build_interface_libraries'", " flag_set {", " action: '" + LinkTargetType.DYNAMIC_LIBRARY.getActionName() + "',", " flag_group {", " flag: '%{generate_interface_library}'", " flag: '%{interface_library_builder_path}'", " flag: '%{interface_library_input_path}'", " flag: '%{interface_library_output_path}'", " }", " }", "}", "feature {", " name: 'dynamic_library_linker_tool'", " flag_set {", " action: 'c++-link-dynamic-library'", " flag_group {", " flag: 'dynamic_library_linker_tool'", " }", " }", "}", "feature {", " name: 'has_configured_linker_path'", "}", "action_config {", " config_name: '" + LinkTargetType.DYNAMIC_LIBRARY.getActionName() + "'", " action_name: '" + LinkTargetType.DYNAMIC_LIBRARY.getActionName() + "'", " tool {", " tool_path: 'custom/crosstool/scripts/link_dynamic_library.sh'", " }", " implies: 'has_configured_linker_path'", " implies: 'build_interface_libraries'", " implies: 'dynamic_library_linker_tool'", "}").getFeatureConfiguration("build_interface_libraries", "dynamic_library_linker_tool", LinkTargetType.DYNAMIC_LIBRARY.getActionName());
CppLinkActionBuilder builder = createLinkBuilder(LinkTargetType.DYNAMIC_LIBRARY, "foo.so", ImmutableList.<Artifact>of(), ImmutableList.<LibraryToLink>of(), featureConfiguration).setLibraryIdentifier("foo").setInterfaceOutput(scratchArtifact("FakeInterfaceOutput.ifso"));
List<String> commandLine = builder.build().getCommandLine();
assertThat(commandLine).hasSize(6);
assertThat(commandLine.get(0)).endsWith("custom/crosstool/scripts/link_dynamic_library.sh");
assertThat(commandLine.get(1)).isEqualTo("yes");
assertThat(commandLine.get(2)).endsWith("tools/cpp/build_interface_so");
assertThat(commandLine.get(3)).endsWith("foo.so");
assertThat(commandLine.get(4)).isEqualTo("FakeInterfaceOutput.ifso");
assertThat(commandLine.get(5)).isEqualTo("dynamic_library_linker_tool");
}
use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testErrorForNoMatchingTool.
@Test
public void testErrorForNoMatchingTool() throws Exception {
CcToolchainFeatures toolchainFeatures = buildFeatures("action_config {", " config_name: 'action-a'", " action_name: 'action-a'", " tool {", " tool_path: 'toolchain/feature-a'", " with_feature: { feature: 'feature-a' }", " }", "}", "feature {", " name: 'feature-a'", "}", "feature {", " name: 'activates-action-a'", " implies: 'action-a'", "}");
PathFragment crosstoolPath = new PathFragment("crosstool/");
FeatureConfiguration noFeaturesConfiguration = toolchainFeatures.getFeatureConfiguration("activates-action-a");
try {
noFeaturesConfiguration.getToolForAction("action-a").getToolPath(crosstoolPath);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage()).contains("Matching tool for action action-a not found for given feature configuration");
}
}
use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testActionConfigCanActivateFeature.
@Test
public void testActionConfigCanActivateFeature() throws Exception {
CcToolchainFeatures toolchainFeatures = buildFeatures("action_config {", " config_name: 'action-a'", " action_name: 'action-a'", " tool {", " tool_path: 'toolchain/feature-a'", " with_feature: { feature: 'feature-a' }", " }", " implies: 'activated-feature'", "}", "feature {", " name: 'activated-feature'", "}");
FeatureConfiguration featureConfiguration = toolchainFeatures.getFeatureConfiguration("action-a");
assertThat(featureConfiguration.isEnabled("activated-feature")).isTrue();
}
use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testFlagsFromActionConfig.
@Test
public void testFlagsFromActionConfig() throws Exception {
FeatureConfiguration featureConfiguration = buildFeatures("action_config {", " config_name: 'c++-compile'", " action_name: 'c++-compile'", " flag_set {", " flag_group {flag: 'foo'}", " }", "}").getFeatureConfiguration("c++-compile");
List<String> commandLine = featureConfiguration.getCommandLine("c++-compile", createVariables());
assertThat(commandLine).contains("foo");
;
}
use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testActivateActionConfigFromFeature.
@Test
public void testActivateActionConfigFromFeature() throws Exception {
CcToolchainFeatures toolchainFeatures = buildFeatures("action_config {", " config_name: 'action-a'", " action_name: 'action-a'", " tool {", " tool_path: 'toolchain/feature-a'", " with_feature: { feature: 'feature-a' }", " }", "}", "feature {", " name: 'activates-action-a'", " implies: 'action-a'", "}");
FeatureConfiguration featureConfiguration = toolchainFeatures.getFeatureConfiguration("activates-action-a");
assertThat(featureConfiguration.actionIsConfigured("action-a")).isTrue();
}
Aggregations