use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testActionToolFromFeatureSet.
@Test
public void testActionToolFromFeatureSet() throws Exception {
CcToolchainFeatures toolchainFeatures = buildFeatures("action_config {", " config_name: 'action-a'", " action_name: 'action-a'", " tool {", " tool_path: 'toolchain/features-a-and-b'", " with_feature: {", " feature: 'feature-a'", " feature: 'feature-b'", " }", " }", " tool {", " tool_path: 'toolchain/feature-a'", " with_feature: { feature: 'feature-a' }", " }", " tool {", " tool_path: 'toolchain/feature-b'", " with_feature: { feature: 'feature-b' }", " }", " tool {", " tool_path: 'toolchain/default'", " }", "}", "feature {", " name: 'feature-a'", "}", "feature {", " name: 'feature-b'", "}", "feature {", " name: 'activates-action-a'", " implies: 'action-a'", "}");
PathFragment crosstoolPath = new PathFragment("crosstool/");
FeatureConfiguration featureAConfiguration = toolchainFeatures.getFeatureConfiguration("feature-a", "activates-action-a");
assertThat(featureAConfiguration.getToolForAction("action-a").getToolPath(crosstoolPath).toString()).isEqualTo("crosstool/toolchain/feature-a");
FeatureConfiguration featureBConfiguration = toolchainFeatures.getFeatureConfiguration("feature-b", "activates-action-a");
assertThat(featureBConfiguration.getToolForAction("action-a").getToolPath(crosstoolPath).toString()).isEqualTo("crosstool/toolchain/feature-b");
FeatureConfiguration featureAAndBConfiguration = toolchainFeatures.getFeatureConfiguration("feature-a", "feature-b", "activates-action-a");
assertThat(featureAAndBConfiguration.getToolForAction("action-a").getToolPath(crosstoolPath).toString()).isEqualTo("crosstool/toolchain/features-a-and-b");
FeatureConfiguration noFeaturesConfiguration = toolchainFeatures.getFeatureConfiguration("activates-action-a");
assertThat(noFeaturesConfiguration.getToolForAction("action-a").getToolPath(crosstoolPath).toString()).isEqualTo("crosstool/toolchain/default");
}
use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testFeatureCanRequireActionConfig.
@Test
public void testFeatureCanRequireActionConfig() 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: 'requires-action-a'", " requires: { feature: 'action-a' }", "}");
FeatureConfiguration featureConfigurationWithoutAction = toolchainFeatures.getFeatureConfiguration("requires-action-a");
assertThat(featureConfigurationWithoutAction.isEnabled("requires-action-a")).isFalse();
FeatureConfiguration featureConfigurationWithAction = toolchainFeatures.getFeatureConfiguration("action-a", "requires-action-a");
assertThat(featureConfigurationWithAction.isEnabled("requires-action-a")).isTrue();
}
use of com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration in project bazel by bazelbuild.
the class CcToolchainFeaturesTest method testEnvVars.
@Test
public void testEnvVars() throws Exception {
FeatureConfiguration configuration = buildFeatures("feature {", " name: 'a'", " env_set {", " action: 'c++-compile'", " env_entry { key: 'foo', value: 'bar' }", " env_entry { key: 'cat', value: 'meow' }", " }", " flag_set {", " action: 'c++-compile'", " flag_group { flag: '-a-c++-compile' }", " }", "}", "feature {", " name: 'b'", " env_set {", " action: 'c++-compile'", " env_entry { key: 'dog', value: 'woof' }", " }", "}", "feature {", " name: 'c'", " env_set {", " action: 'c++-compile'", " env_entry { key: 'doNotInclude', value: 'doNotIncludePlease' }", " }", "}").getFeatureConfiguration("a", "b");
Map<String, String> env = configuration.getEnvironmentVariables(CppCompileAction.CPP_COMPILE, createVariables());
assertThat(env).containsExactly("foo", "bar", "cat", "meow", "dog", "woof").inOrder();
assertThat(env).doesNotContainEntry("doNotInclude", "doNotIncludePlease");
}
Aggregations