diff options
author | hlopko <hlopko@google.com> | 2018-06-07 01:15:01 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-07 01:16:34 -0700 |
commit | 5146ce0da00ea12f1730b7036e8e9f42d3561477 (patch) | |
tree | 62c270f54c4252fe1ea4b9a0ae049af5607db607 /src/test/java/com/google/devtools/build/lib/rules | |
parent | d0982b905d93e219a0caccdcf5d6ae1e219387c2 (diff) |
Expose C++ action names to Skylark
This cl adds Skylark constants allowing users to specify which C++ action they
want for the feature configuration Skylark API. This is done by exposing a
Skylark file at @bazel_tools//tools/cpp:action_names.bzl.
Skylark api to the C++ toolchain doc:
https://docs.google.com/document/d/1g91BWJITcYw_X-VxsDC0VgUn5E9g0kRBGoBSpoO41gA/edit#.
Progress on #4571.
RELNOTES: None.
PiperOrigin-RevId: 199596778
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java | 49 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java | 16 |
2 files changed, 32 insertions, 33 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java index f8c29e00e8..a0671e386d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java @@ -225,8 +225,8 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { " }", "}") .getFeatureConfiguration(ImmutableSet.of("a", "b")); - List<String> commandLine = configuration.getCommandLine( - CppCompileAction.CPP_COMPILE, createVariables()); + List<String> commandLine = + configuration.getCommandLine(CppActionNames.CPP_COMPILE, createVariables()); assertThat(commandLine).containsExactly("-a-c++-compile", "-b-c++-compile").inOrder(); } @@ -285,8 +285,8 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { "feature { name: 'f' }", "feature { name: 'g' }") .getFeatureConfiguration(ImmutableSet.of("a", "b", "d", "f")); - Map<String, String> env = configuration.getEnvironmentVariables( - CppCompileAction.CPP_COMPILE, createVariables()); + Map<String, String> env = + configuration.getEnvironmentVariables(CppActionNames.CPP_COMPILE, createVariables()); assertThat(env) .containsExactly( "foo", "bar", "cat", "meow", "dog", "woof", @@ -317,7 +317,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { " }", "}") .getFeatureConfiguration(ImmutableSet.of("a")); - return configuration.getCommandLine(CppCompileAction.CPP_COMPILE, variables); + return configuration.getCommandLine(CppActionNames.CPP_COMPILE, variables); } private List<String> getCommandLineForFlag(String value, CcToolchainVariables variables) @@ -1081,7 +1081,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { "}") .getFeatureConfiguration(ImmutableSet.of("a")); - assertThat(configuration.getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + assertThat(configuration.getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("unconditional"); } @@ -1109,8 +1109,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { "}") .getFeatureConfiguration(ImmutableSet.of("a")); - assertThat( - configuration.getCommandLine(CppCompileAction.CPP_COMPILE, createVariables("v", "1"))) + assertThat(configuration.getCommandLine(CppActionNames.CPP_COMPILE, createVariables("v", "1"))) .containsExactly("1", "unconditional"); } @@ -1140,7 +1139,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( configuration.getCommandLine( - CppCompileAction.CPP_COMPILE, createVariables("v", "1", "v", "2"))) + CppActionNames.CPP_COMPILE, createVariables("v", "1", "v", "2"))) .containsExactly("1", "2", "unconditional") .inOrder(); } @@ -1171,7 +1170,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( configuration.getCommandLine( - CppCompileAction.CPP_COMPILE, createVariables("v", "1", "v", "2", "w", "3"))) + CppActionNames.CPP_COMPILE, createVariables("v", "1", "v", "2", "w", "3"))) .containsExactly("1", "2", "13", "23", "unconditional") .inOrder(); } @@ -1194,7 +1193,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( features .getFeatureConfiguration(ImmutableSet.of("b")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables("v", "1"))) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables("v", "1"))) .containsExactly("-f", "1"); byte[] serialized = TestUtils.serializeObject(features); CcToolchainFeatures deserialized = @@ -1203,7 +1202,7 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( features .getFeatureConfiguration(ImmutableSet.of("b")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables("v", "1"))) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables("v", "1"))) .containsExactly("-f", "1"); } @@ -1240,12 +1239,12 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "b")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); } @@ -1268,17 +1267,17 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "b", "c")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "b")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); } @@ -1304,17 +1303,17 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "b1", "c1", "b2", "c2")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "b1", "c1")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "b1", "b2")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); } @@ -1340,27 +1339,27 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { assertThat( features .getFeatureConfiguration(ImmutableSet.of("a")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "q")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "q", "z")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .containsExactly("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "q", "x", "z")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); assertThat( features .getFeatureConfiguration(ImmutableSet.of("a", "q", "x", "y", "z")) - .getCommandLine(CppCompileAction.CPP_COMPILE, createVariables())) + .getCommandLine(CppActionNames.CPP_COMPILE, createVariables())) .doesNotContain("dummy_flag"); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java index 9778050d01..1dffb0f870 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java @@ -55,14 +55,14 @@ public class CompileCommandLineTest extends BuildViewTestCase { return CcToolchainFeaturesTest.buildFeatures(crosstool) .getFeatureConfiguration( ImmutableSet.of( - CppCompileAction.ASSEMBLE, - CppCompileAction.PREPROCESS_ASSEMBLE, - CppCompileAction.C_COMPILE, - CppCompileAction.CPP_COMPILE, - CppCompileAction.CPP_HEADER_PARSING, - CppCompileAction.CPP_HEADER_PREPROCESSING, - CppCompileAction.CPP_MODULE_CODEGEN, - CppCompileAction.CPP_MODULE_COMPILE)); + CppActionNames.ASSEMBLE, + CppActionNames.PREPROCESS_ASSEMBLE, + CppActionNames.C_COMPILE, + CppActionNames.CPP_COMPILE, + CppActionNames.CPP_HEADER_PARSING, + CppActionNames.CPP_HEADER_PREPROCESSING, + CppActionNames.CPP_MODULE_CODEGEN, + CppActionNames.CPP_MODULE_COMPILE)); } @Test |