aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2017-07-18 11:28:14 +0200
committerGravatar Klaus Aehlig <aehlig@google.com>2017-07-18 11:42:19 +0200
commit8457eedb0eb4ee0ded142ea4d5dd8f9f1b53d875 (patch)
treec5258f4e7263647cff191edb8ba1b5ed519d3537 /src/main/java/com/google/devtools
parent61536c3259a138a6268b56388bc71a4a91ab0db0 (diff)
Add an option to remove the toolchain identifier from the name of the output directory.
This will probably need some more work so that there are no name clashes with e.g. Android output directory names, but let's take one step at a time. RELNOTES: None. PiperOrigin-RevId: 162328750
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java15
2 files changed, 28 insertions, 1 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 73a3535b49..cd58be8100 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
@@ -226,6 +226,11 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
private final Label crosstoolTop;
private final String hostSystemName;
private final String compiler;
+ // TODO(lberki): desiredCpu *should* be always the same as targetCpu, except that we don't check
+ // that the CPU we get from the toolchain matches BuildConfiguration.Options.cpu . So we store
+ // it here so that the output directory doesn't depend on the CToolchain. When we will eventually
+ // verify that the two are the same, we can remove one of desiredCpu and targetCpu.
+ private final String desiredCpu;
private final String targetCpu;
private final String targetSystemName;
private final String targetLibc;
@@ -313,12 +318,17 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
*/
private final boolean lipoContextCollector;
+ /** If true, add the toolchain identifier to the name of the output directory. */
+ private final boolean toolchainIdInOutputDirectory;
+
protected CppConfiguration(CppConfigurationParameters params)
throws InvalidConfigurationException {
CrosstoolConfig.CToolchain toolchain = params.toolchain;
cppOptions = params.cppOptions;
+ this.toolchainIdInOutputDirectory = cppOptions.toolchainIdInOutputDirectory;
this.hostSystemName = toolchain.getHostSystemName();
this.compiler = toolchain.getCompiler();
+ this.desiredCpu = Preconditions.checkNotNull(params.commonOptions.cpu);
this.targetCpu = toolchain.getTargetCpu();
this.lipoMode = cppOptions.getLipoMode();
this.targetSystemName = toolchain.getTargetSystemName();
@@ -2068,7 +2078,9 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
} else {
lipoSuffix = "";
}
- return toolchainIdentifier + lipoSuffix;
+ String toolchainPrefix = toolchainIdInOutputDirectory
+ ? toolchainIdentifier : desiredCpu;
+ return toolchainPrefix + lipoSuffix;
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
index 9c8e5a536b..97492ae816 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
@@ -540,6 +540,16 @@ public class CppOptions extends FragmentOptions {
*/
public Label lipoContextForBuild;
+ @Option(
+ name = "experimental_toolchain_id_in_output_directory",
+ defaultValue = "true",
+ category = "semantics",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = OptionEffectTag.AFFECTS_OUTPUTS,
+ help = "Whether to embed the name of the C++ toolchain in the name of the output directory"
+ )
+ public boolean toolchainIdInOutputDirectory;
+
/**
* Returns the --lipo_context value if LIPO is specified and active for this configuration,
* null otherwise.
@@ -840,6 +850,11 @@ public class CppOptions extends FragmentOptions {
}
}
+ // the name of the output directory for the host configuration is forced to be "host" in
+ // BuildConfiguration.Options#getHost(), but let's be prudent here in case someone ends up
+ // removing that
+ host.toolchainIdInOutputDirectory = toolchainIdInOutputDirectory;
+
// hostLibcTop doesn't default to the target's libcTop.
// Only an explicit command-line option will change it.
// The default is whatever the host's crosstool (which might have been specified