Skip to content

Commit

Permalink
Add an option to remove the toolchain identifier from the name of the…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
lberki authored and aehlig committed Jul 18, 2017
1 parent 61536c3 commit 8457eed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ ImmutableList<String> evaluate(Iterable<String> features) {
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;
Expand Down Expand Up @@ -313,12 +318,17 @@ ImmutableList<String> evaluate(Iterable<String> features) {
*/
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();
Expand Down Expand Up @@ -2068,7 +2078,9 @@ public String getOutputDirectoryName() {
} else {
lipoSuffix = "";
}
return toolchainIdentifier + lipoSuffix;
String toolchainPrefix = toolchainIdInOutputDirectory
? toolchainIdentifier : desiredCpu;
return toolchainPrefix + lipoSuffix;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,16 @@ public LipoMode getLipoMode() {
*/
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.
Expand Down Expand Up @@ -840,6 +850,11 @@ public FragmentOptions getHost(boolean fallback) {
}
}

// 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
Expand Down

0 comments on commit 8457eed

Please sign in to comment.