aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar hlopko <hlopko@google.com>2018-03-21 07:00:35 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-21 07:02:30 -0700
commit67549a752c2316234b19d7b50ea84a8ae80d3669 (patch)
tree563d8d00732e5988d339cc633d8ddf78c7167a0f /src
parenta1068c44a700ec2cff84cbd12592e9bfea25d754 (diff)
Automated rollback of commit 3c5a1098af0c5ae80d4e3b1fc52dd1fef6027d43.
*** Reason for rollback *** Breaks bazel ci: https://github.com/bazelbuild/bazel/issues/4894#event-1533040075 *** Original change description *** Add crosstool_lib.bzl and crosstool_utils.bzl These will be used to rewrite current crosstool autoconfiguration into action_configs and features. RELNOTES: None. PiperOrigin-RevId: 189901308
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java36
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD5
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java144
3 files changed, 15 insertions, 170 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
index a2da30d674..b25dc7fc85 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
@@ -50,7 +50,6 @@ import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration.HeadersCheckingMode;
import com.google.devtools.build.lib.rules.cpp.FdoSupport.FdoMode;
-import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType;
import com.google.devtools.build.lib.shell.ShellUtils;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
@@ -106,8 +105,11 @@ public final class CcCommon {
}
};
- public static final ImmutableSet<String> ALL_COMPILE_ACTIONS =
+ /** Action configs we request to enable. */
+ private static final ImmutableSet<String> DEFAULT_ACTION_CONFIGS =
ImmutableSet.of(
+ CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME,
+ CppCompileAction.STRIP_ACTION_NAME,
CppCompileAction.C_COMPILE,
CppCompileAction.CPP_COMPILE,
CppCompileAction.CPP_HEADER_PARSING,
@@ -118,29 +120,16 @@ public final class CcCommon {
CppCompileAction.PREPROCESS_ASSEMBLE,
CppCompileAction.CLIF_MATCH,
CppCompileAction.LINKSTAMP_COMPILE,
- CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME);
-
- public static final ImmutableSet<String> ALL_LINK_ACTIONS =
- ImmutableSet.of(
+ Link.LinkTargetType.STATIC_LIBRARY.getActionName(),
+ // We need to create pic-specific actions for link actions, as they will produce
+ // differently named outputs.
+ Link.LinkTargetType.PIC_STATIC_LIBRARY.getActionName(),
Link.LinkTargetType.INTERFACE_DYNAMIC_LIBRARY.getActionName(),
- Link.LinkTargetType.DYNAMIC_LIBRARY.getActionName(),
Link.LinkTargetType.NODEPS_DYNAMIC_LIBRARY.getActionName(),
- LinkTargetType.EXECUTABLE.getActionName());
-
- public static final ImmutableSet<String> ALL_ARCHIVE_ACTIONS =
- ImmutableSet.of(Link.LinkTargetType.STATIC_LIBRARY.getActionName());
-
- public static final ImmutableSet<String> ALL_OTHER_ACTIONS =
- ImmutableSet.of(CppCompileAction.STRIP_ACTION_NAME);
-
- /** Action configs we request to enable. */
- public static final ImmutableSet<String> DEFAULT_ACTION_CONFIGS =
- ImmutableSet.<String>builder()
- .addAll(ALL_COMPILE_ACTIONS)
- .addAll(ALL_LINK_ACTIONS)
- .addAll(ALL_ARCHIVE_ACTIONS)
- .addAll(ALL_OTHER_ACTIONS)
- .build();
+ Link.LinkTargetType.DYNAMIC_LIBRARY.getActionName(),
+ Link.LinkTargetType.ALWAYS_LINK_STATIC_LIBRARY.getActionName(),
+ Link.LinkTargetType.ALWAYS_LINK_PIC_STATIC_LIBRARY.getActionName(),
+ Link.LinkTargetType.EXECUTABLE.getActionName());
/** Features we request to enable unless a rule explicitly doesn't support them. */
private static final ImmutableSet<String> DEFAULT_FEATURES =
@@ -153,7 +142,6 @@ public final class CcCommon {
CppRuleClasses.INCLUDE_PATHS,
CppRuleClasses.PIC,
CppRuleClasses.PREPROCESSOR_DEFINES);
-
public static final String CC_TOOLCHAIN_DEFAULT_ATTRIBUTE_NAME = ":cc_toolchain";
/** C++ configuration */
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
index 9d5482bada..7e0b17115b 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
@@ -13,10 +13,7 @@ filegroup(
java_test(
name = "cpp-rules-tests",
srcs = glob(["*.java"]) + ["proto/CcProtoLibraryTest.java"],
- resources = [
- "//tools/cpp:crosstool_utils",
- "//tools/cpp:lib_cc_configure",
- ],
+ resources = ["//tools/cpp:lib_cc_configure"],
tags = ["rules"],
test_class = "com.google.devtools.build.lib.AllTests",
deps = [
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java
index c3386fff9a..dbaa612fb3 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java
@@ -27,15 +27,6 @@ import org.junit.runners.JUnit4;
public class SkylarkCcToolchainConfigureTest extends EvaluationTestCase {
@Test
- public void testActionNames() throws Exception {
- newTest()
- .testStatement("COMPILE_ACTIONS", MutableList.copyOf(env, CcCommon.ALL_COMPILE_ACTIONS))
- .testStatement("LINK_ACTIONS", MutableList.copyOf(env, CcCommon.ALL_LINK_ACTIONS))
- .testStatement("ARCHIVE_ACTIONS", MutableList.copyOf(env, CcCommon.ALL_ARCHIVE_ACTIONS))
- .testStatement("OTHER_ACTIONS", MutableList.copyOf(env, CcCommon.ALL_OTHER_ACTIONS));
- }
-
- @Test
public void testSplitEscaped() throws Exception {
newTest()
.testStatement("split_escaped('a:b:c', ':')", MutableList.of(env, "a", "b", "c"))
@@ -56,135 +47,7 @@ public class SkylarkCcToolchainConfigureTest extends EvaluationTestCase {
.testStatement("split_escaped('a%%b', ':')", MutableList.of(env, "a%b"))
.testStatement("split_escaped('a%:', ':')", MutableList.of(env, "a:"));
}
-
- @Test
- public void testActionConfig() throws Exception {
- newTest()
- .testStatement(
- "action_config('c++-compile', '/usr/bin/gcc')",
- "\n"
- + " action_config {\n"
- + " config_name: 'c++-compile'\n"
- + " action_name: 'c++-compile'\n"
- + " tool {\n"
- + " tool_path: '/usr/bin/gcc'\n"
- + " }\n"
- + " }");
- }
-
- @Test
- public void testFeature() throws Exception {
- newTest()
- .testStatement(
- "feature("
- + "'fully_static_link', "
- + " [ "
- + " flag_set("
- + " ['c++-link-dynamic-library', 'c++-link-nodeps-dynamic-library'], "
- + " [flag_group([flag('-a'), flag('-b'), flag('-c')])])])",
- "\n"
- + " feature {\n"
- + " name: 'fully_static_link'\n"
- + " enabled: true\n"
- + " flag_set {\n"
- + " action: 'c++-link-dynamic-library'\n"
- + " action: 'c++-link-nodeps-dynamic-library'\n"
- + " flag_group {\n"
- + " flag: '-a'\n"
- + " flag: '-b'\n"
- + " flag: '-c'\n"
- + " }\n"
- + " }\n"
- + " }");
- }
-
- @Test
- public void testFeatureThoroughly() throws Exception {
- newTest()
- .testStatement(
- "feature("
- + "'fully_static_link', "
- + " [ "
- + " flag_set("
- + " ['c++-link-dynamic-library'], "
- + " [flag_group([flag('-a')])]),"
- + " flag_set("
- + " ['c++-link-dynamic-library'],"
- + " ["
- + " flag_group("
- + " [flag('-a')],"
- + " iterate_over='a'),"
- + " flag_group("
- + " [flag('-c')],"
- + " expand_if_all_available=['a','b'],"
- + " expand_if_none_available=['a'],"
- + " expand_if_true=['a','b'],"
- + " expand_if_false=['a'],"
- + " expand_if_equal=[['a','val']],"
- + " ),"
- + " flag_group("
- + " [flag('-c')],"
- + " iterate_over='a',"
- + " expand_if_all_available=['a','b'],"
- + " expand_if_none_available=['a'],"
- + " expand_if_true=['a','b'],"
- + " expand_if_false=['a'],"
- + " expand_if_equal=[['a','val']],"
- + " )"
- + " ]),"
- + " flag_set("
- + " ['c++-link-dynamic-library'], "
- + " [flag_group([flag_group([flag('-a')])])])"
- + " ])",
- "\n"
- + " feature {\n"
- + " name: 'fully_static_link'\n"
- + " enabled: true\n"
- + " flag_set {\n"
- + " action: 'c++-link-dynamic-library'\n"
- + " flag_group {\n"
- + " flag: '-a'\n"
- + " }\n"
- + " }\n"
- + " flag_set {\n"
- + " action: 'c++-link-dynamic-library'\n"
- + " flag_group {\n"
- + " iterate_over: 'a'\n"
- + " flag: '-a'\n"
- + " }\n"
- + " flag_group {\n"
- + " expand_if_all_available: 'a'\n"
- + " expand_if_all_available: 'b'\n"
- + " expand_if_none_available: 'a'\n"
- + " expand_if_true: 'a'\n"
- + " expand_if_true: 'b'\n"
- + " expand_if_false: 'a'\n"
- + " expand_if_equal { variable: 'a' value: 'val' }\n"
- + " flag: '-c'\n"
- + " }\n"
- + " flag_group {\n"
- + " expand_if_all_available: 'a'\n"
- + " expand_if_all_available: 'b'\n"
- + " expand_if_none_available: 'a'\n"
- + " expand_if_true: 'a'\n"
- + " expand_if_true: 'b'\n"
- + " expand_if_false: 'a'\n"
- + " expand_if_equal { variable: 'a' value: 'val' }\n"
- + " iterate_over: 'a'\n"
- + " flag: '-c'\n"
- + " }\n"
- + " }\n"
- + " flag_set {\n"
- + " action: 'c++-link-dynamic-library'\n"
- + " flag_group {\n"
- + " flag_group {\n"
- + " flag: '-a'\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }");
- }
-
+
private ModalTestCase newTest(String... skylarkOptions) throws IOException {
return new SkylarkTest(skylarkOptions)
// A mock implementation of Label to be able to parse lib_cc_configure under default
@@ -193,9 +56,6 @@ public class SkylarkCcToolchainConfigureTest extends EvaluationTestCase {
.setUp("def Label(arg):\n return 42")
.setUp(
ResourceLoader.readFromResources(
- TestConstants.BAZEL_REPO_PATH + "tools/cpp/lib_cc_configure.bzl"))
- .setUp(
- ResourceLoader.readFromResources(
- TestConstants.BAZEL_REPO_PATH + "tools/cpp/crosstool_utils.bzl"));
+ TestConstants.BAZEL_REPO_PATH + "tools/cpp/lib_cc_configure.bzl"));
}
}