Skip to content

Commit

Permalink
When copying dynamic libraries to binary, copy them into the runfiles…
Browse files Browse the repository at this point in the history
… as well.

RELNOTES: None.
PiperOrigin-RevId: 256184273
  • Loading branch information
Googler authored and laurentlb committed Jul 16, 2019
1 parent 18cd904 commit 9d53cec
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
// logical since all symlinked libraries will be linked anyway and would
// not require manual loading but if we do, then we would need to collect
// their names and use a different constructor below.
NestedSetBuilder<Artifact> transitiveArtifacts =
NestedSetBuilder.<Artifact>stableOrder()
.addTransitive(filesToBuild)
.addTransitive(extraLinkTimeRuntimeLibraries.build());
if (featureConfiguration.isEnabled(CppRuleClasses.COPY_DYNAMIC_LIBRARIES_TO_BINARY)) {
transitiveArtifacts.addTransitive(copiedRuntimeDynamicLibraries);
}
Runfiles runfiles =
collectRunfiles(
ruleContext,
Expand All @@ -593,10 +600,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
ccLinkingOutputs,
ccCompilationContext,
linkingMode,
NestedSetBuilder.<Artifact>stableOrder()
.addTransitive(filesToBuild)
.addTransitive(extraLinkTimeRuntimeLibraries.build())
.build(),
transitiveArtifacts.build(),
fakeLinkerInputs,
fake,
compilationHelper.getCompilationUnitSources(),
Expand Down Expand Up @@ -656,11 +660,6 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
}

if (copiedRuntimeDynamicLibraries != null) {
// When COPY_DYNAMIC_LIBRARIES_TO_BINARY is enabled, runtime dynamic libraries should be
// copied to the binary's directory. Therefore, we add them to HIDDEN_TOP_LEVEL output group
// to make sure they are built for the target and runtime_dynamic_libraries output group
// to make them easier to access.
ruleBuilder.addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL, copiedRuntimeDynamicLibraries);
ruleBuilder.addOutputGroup("runtime_dynamic_libraries", copiedRuntimeDynamicLibraries);
}

Expand Down

0 comments on commit 9d53cec

Please sign in to comment.