Skip to content

Commit

Permalink
Automated rollback of commit 3c5a109.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaks bazel ci: #4894 (comment)

*** 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
  • Loading branch information
hlopko authored and Copybara-Service committed Mar 21, 2018
1 parent a1068c4 commit 67549a7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 863 deletions.
36 changes: 12 additions & 24 deletions src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
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;
Expand Down Expand Up @@ -106,8 +105,11 @@ public void collectMetadataArtifacts(Iterable<Artifact> objectFiles,
}
};

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,
Expand All @@ -118,29 +120,16 @@ public void collectMetadataArtifacts(Iterable<Artifact> objectFiles,
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 =
Expand All @@ -153,7 +142,6 @@ public void collectMetadataArtifacts(Iterable<Artifact> objectFiles,
CppRuleClasses.INCLUDE_PATHS,
CppRuleClasses.PIC,
CppRuleClasses.PREPROCESSOR_DEFINES);

public static final String CC_TOOLCHAIN_DEFAULT_ATTRIBUTE_NAME = ":cc_toolchain";

/** C++ configuration */
Expand Down
5 changes: 1 addition & 4 deletions src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@
@RunWith(JUnit4.class)
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()
Expand All @@ -56,135 +47,7 @@ public void testSplitEscaped() throws Exception {
.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
Expand All @@ -193,9 +56,6 @@ private ModalTestCase newTest(String... skylarkOptions) throws IOException {
.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"));
}
}
10 changes: 0 additions & 10 deletions tools/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,6 @@ filegroup(
srcs = ["lib_cc_configure.bzl"],
)

filegroup(
name = "crosstool_utils",
srcs = ["crosstool_utils.bzl"],
)

filegroup(
name = "crosstool_lib",
srcs = ["crosstool_lib.bzl"],
)

cc_toolchain_type(name = "toolchain_type")

# A dummy toolchain is necessary to satisfy toolchain resolution until platforms
Expand Down
Loading

0 comments on commit 67549a7

Please sign in to comment.