aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar schmitt <schmitt@google.com>2017-04-17 20:31:13 +0200
committerGravatar Klaus Aehlig <aehlig@google.com>2017-04-18 11:33:10 +0200
commitd470a32e641b0aa407ffbff2022f44636d204f67 (patch)
treef24f9d195c95dcfdd0363b4522b4a95993cb70cf /src/main
parent501b62716af12ba42c019bd9f231468b3c144757 (diff)
Automated g4 rollback of commit e1d692e486a2f838c3c894fd9de693fabd6685ed.
*** Reason for rollback *** broken tests *** Original change description *** Init absent action configs for CppCompile actions So far only link actions were initialized in CppLinkActionConfigs. This cl changes this class to also initialize CppCompile actions. This is needed for our ongoing work removing hard-coded flags from Bazel and moving them into Crosstool. RELNOTES: None. PiperOrigin-RevId: 153366563
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java47
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionConfigs.java (renamed from src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java)37
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java2
3 files changed, 34 insertions, 52 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
index 54e8d6457c..4d3decbd48 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
@@ -38,8 +38,9 @@ import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
-import com.google.devtools.build.lib.rules.cpp.CppActionConfigs.CppPlatform;
import com.google.devtools.build.lib.rules.cpp.CppConfigurationLoader.CppConfigurationParameters;
+import com.google.devtools.build.lib.rules.cpp.CppLinkActionConfigs.CppLinkPlatform;
+import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
@@ -741,15 +742,21 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
return result.build();
}
- private static boolean actionsAreConfigured(CToolchain toolchain) {
- return Iterables.any(
- toolchain.getActionConfigList(),
- new Predicate<ActionConfig>() {
- @Override
- public boolean apply(@Nullable ActionConfig actionConfig) {
- return actionConfig.getActionName().contains("c++");
- }
- });
+ private boolean linkActionsAreConfigured(CToolchain toolchain) {
+
+ for (LinkTargetType type : Link.MANDATORY_LINK_TARGET_TYPES) {
+ boolean typeIsConfigured = false;
+ for (ActionConfig actionConfig : toolchain.getActionConfigList()) {
+ if (actionConfig.getActionName().equals(type.getActionName())) {
+ typeIsConfigured = true;
+ break;
+ }
+ }
+ if (!typeIsConfigured) {
+ return false;
+ }
+ }
+ return true;
}
// TODO(bazel-team): Remove this once bazel supports all crosstool flags through
@@ -783,12 +790,10 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
Set<String> features = featuresBuilder.build();
if (!features.contains(CppRuleClasses.NO_LEGACY_FEATURES)) {
try {
- if (!actionsAreConfigured(toolchain)) {
- String gccToolPath = "DUMMY_GCC_TOOL";
+ if (!linkActionsAreConfigured(toolchain)) {
String linkerToolPath = "DUMMY_LINKER_TOOL";
for (ToolPath tool : toolchain.getToolPathList()) {
if (tool.getName().equals(Tool.GCC.getNamePart())) {
- gccToolPath = tool.getPath();
linkerToolPath =
crosstoolTopPathFragment
.getRelative(PathFragment.create(tool.getPath()))
@@ -797,21 +802,13 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
}
if (getTargetLibc().equals("macosx")) {
TextFormat.merge(
- CppActionConfigs.getCppActionConfigs(
- CppPlatform.MAC,
- features,
- gccToolPath,
- linkerToolPath,
- supportsEmbeddedRuntimes),
+ CppLinkActionConfigs.getCppLinkActionConfigs(
+ CppLinkPlatform.MAC, features, linkerToolPath, supportsEmbeddedRuntimes),
toolchainBuilder);
} else {
TextFormat.merge(
- CppActionConfigs.getCppActionConfigs(
- CppPlatform.LINUX,
- features,
- gccToolPath,
- linkerToolPath,
- supportsEmbeddedRuntimes),
+ CppLinkActionConfigs.getCppLinkActionConfigs(
+ CppLinkPlatform.LINUX, features, linkerToolPath, supportsEmbeddedRuntimes),
toolchainBuilder);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionConfigs.java
index ae53fc1d46..7a1c6da7b4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionConfigs.java
@@ -18,24 +18,23 @@ import com.google.common.collect.ImmutableList;
import java.util.Set;
/**
- * A helper class for creating action_configs for the c++ actions.
+ * A helper class for creating action_configs for the c++ link action.
*
* <p>TODO(b/30109612): Replace this with action_configs in the crosstool instead of putting it in
* legacy features.
*/
-public class CppActionConfigs {
+public class CppLinkActionConfigs {
/** A platform for linker invocations. */
- public enum CppPlatform {
+ public static enum CppLinkPlatform {
LINUX,
MAC
}
- public static String getCppActionConfigs(
- CppPlatform platform,
+ public static String getCppLinkActionConfigs(
+ CppLinkPlatform platform,
Set<String> features,
- String gccToolPath,
- String linkerToolPath,
+ String cppLinkDynamicLibraryToolPath,
boolean supportsEmbeddedRuntimes) {
String cppDynamicLibraryLinkerTool = "";
if (!features.contains("dynamic_library_linker_tool")) {
@@ -47,7 +46,7 @@ public class CppActionConfigs {
+ " action: 'c++-link-dynamic-library'"
+ " flag_group {"
+ " flag: '"
- + linkerToolPath
+ + cppLinkDynamicLibraryToolPath
+ "'"
+ " }"
+ " }"
@@ -58,20 +57,6 @@ public class CppActionConfigs {
.join(
ImmutableList.of(
"action_config {",
- " config_name: 'c-compile'",
- " action_name: 'c-compile'",
- " tool {",
- " tool_path: '" + gccToolPath + "'",
- " }",
- "}",
- "action_config {",
- " config_name: 'c++-compile'",
- " action_name: 'c++-compile'",
- " tool {",
- " tool_path: '" + gccToolPath + "'",
- " }",
- "}",
- "action_config {",
" config_name: 'c++-link-executable'",
" action_name: 'c++-link-executable'",
" tool {",
@@ -513,12 +498,12 @@ public class CppActionConfigs {
"}"));
}
- private static String ifLinux(CppPlatform platform, String... lines) {
- return ifTrue(platform == CppPlatform.LINUX, lines);
+ private static String ifLinux(CppLinkPlatform platform, String... lines) {
+ return ifTrue(platform == CppLinkPlatform.LINUX, lines);
}
- private static String ifMac(CppPlatform platform, String... lines) {
- return ifTrue(platform == CppPlatform.MAC, lines);
+ private static String ifMac(CppLinkPlatform platform, String... lines) {
+ return ifTrue(platform == CppLinkPlatform.MAC, lines);
}
private static String ifTrue(boolean condition, String... lines) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
index e39173dda5..bbb3b4ddb8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
@@ -378,7 +378,7 @@ public final class LinkCommandLine extends CommandLine {
List<String> argv = new ArrayList<>();
// TODO(b/30109612): Extract this switch into individual crosstools once action configs are no
- // longer hardcoded in CppActionConfigs
+ // longer hardcoded in CppLinkActionConfigs
switch (linkTargetType) {
case EXECUTABLE:
argv.add(cppConfiguration.getCppExecutable().getPathString());