Skip to content

Commit

Permalink
Support aliases in the --experimental_stl attribute.
Browse files Browse the repository at this point in the history
--
PiperOrigin-RevId: 150610613
MOS_MIGRATED_REVID=150610613
  • Loading branch information
lberki authored and hermione521 committed Mar 20, 2017
1 parent e721340 commit 2cea8bc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ ImmutableList<String> evaluate(Iterable<String> features) {
private final Label staticRuntimeLibsLabel;
private final Label dynamicRuntimeLibsLabel;
private final Label ccToolchainLabel;
private final Label stlLabel;

private final PathFragment sysroot;
private final PathFragment runtimeSysroot;
Expand Down Expand Up @@ -356,6 +357,7 @@ protected CppConfiguration(CppConfigurationParameters params)
this.targetOS = toolchain.getCcTargetOs();
this.crosstoolTop = params.crosstoolTop;
this.ccToolchainLabel = params.ccToolchainLabel;
this.stlLabel = params.stlLabel;
this.compilationMode = params.commonOptions.compilationMode;
this.useLLVMCoverageMap = params.commonOptions.useLLVMCoverageMapFormat;
this.lipoContextCollector = cppOptions.lipoCollector;
Expand Down Expand Up @@ -1616,7 +1618,7 @@ public boolean getAutoFdoLipoData() {
* otherwise.
*/
public Label getStl() {
return cppOptions.stl;
return stlLabel;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,24 @@ public static class CppConfigurationParameters {
protected final CppOptions cppOptions;
protected final Label crosstoolTop;
protected final Label ccToolchainLabel;
protected final Label stlLabel;
protected final Path fdoZip;

CppConfigurationParameters(CrosstoolConfig.CToolchain toolchain,
String cacheKeySuffix,
BuildOptions buildOptions,
Path fdoZip,
Label crosstoolTop,
Label ccToolchainLabel) {
Label ccToolchainLabel,
Label stlLabel) {
this.toolchain = toolchain;
this.cacheKeySuffix = cacheKeySuffix;
this.commonOptions = buildOptions.get(BuildConfiguration.Options.class);
this.cppOptions = buildOptions.get(CppOptions.class);
this.fdoZip = fdoZip;
this.crosstoolTop = crosstoolTop;
this.ccToolchainLabel = ccToolchainLabel;
this.stlLabel = stlLabel;
}
}

Expand All @@ -125,6 +128,15 @@ protected CppConfigurationParameters createParameters(
return null;
}

CppOptions cppOptions = options.get(CppOptions.class);
Label stlLabel = null;
if (cppOptions.stl != null) {
stlLabel = RedirectChaser.followRedirects(env, cppOptions.stl, "stl");
if (stlLabel == null) {
return null;
}
}

CrosstoolConfigurationLoader.CrosstoolFile file =
CrosstoolConfigurationLoader.readCrosstool(env, crosstoolTopLabel);
if (file == null) {
Expand All @@ -135,7 +147,6 @@ protected CppConfigurationParameters createParameters(

// FDO
// TODO(bazel-team): move this to CppConfiguration.prepareHook
CppOptions cppOptions = options.get(CppOptions.class);
Path fdoZip;
if (cppOptions.fdoOptimize == null) {
fdoZip = null;
Expand Down Expand Up @@ -211,6 +222,6 @@ protected CppConfigurationParameters createParameters(
}

return new CppConfigurationParameters(toolchain, file.getMd5(), options,
fdoZip, crosstoolTopLabel, ccToolchainLabel);
fdoZip, crosstoolTopLabel, ccToolchainLabel, stlLabel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1172,4 +1172,15 @@ public void testProcessedHeadersWithPicSharedLibsAndNoPicBinaries() throws Excep
// Should not crash
scratchConfiguredTarget("a", "a", "cc_library(name='a', hdrs=['a.h'])");
}

@Test
public void testStlWithAlias() throws Exception {
scratch.file("a/BUILD",
"cc_library(name='a')",
"alias(name='stl', actual=':realstl')",
"cc_library(name='realstl')");

useConfiguration("--experimental_stl=//a:stl");
getConfiguredTarget("//a:a");
}
}

0 comments on commit 2cea8bc

Please sign in to comment.