@@ -217,6 +217,17 @@ public String getToolForAction(
217217 return featureConfiguration .getFeatureConfiguration ().getToolPathForAction (actionName );
218218 }
219219
220+ @ Override
221+ public Sequence <String > getToolRequirementForAction (
222+ FeatureConfigurationForStarlark featureConfiguration ,
223+ String actionName ,
224+ StarlarkThread thread )
225+ throws EvalException {
226+ CcModule .checkPrivateStarlarkificationAllowlist (thread );
227+ return StarlarkList .immutableCopyOf (
228+ featureConfiguration .getFeatureConfiguration ().getToolRequirementsForAction (actionName ));
229+ }
230+
220231 @ Override
221232 public Sequence <String > getExecutionRequirements (
222233 FeatureConfigurationForStarlark featureConfiguration , String actionName ) {
@@ -275,43 +286,61 @@ public CcToolchainVariables getCompileBuildVariables(
275286 Object thinLtoOutputObjectFile ,
276287 boolean usePic ,
277288 boolean addLegacyCxxOptions ,
278- Object variablesExtension )
289+ Object variablesExtension ,
290+ Object stripOpts ,
291+ Object inputFile ,
292+ StarlarkThread thread )
279293 throws EvalException {
294+ if (checkObjectsBound (stripOpts , inputFile )) {
295+ CcModule .checkPrivateStarlarkificationAllowlist (thread );
296+ }
280297 ImmutableList <VariablesExtension > variablesExtensions =
281298 asDict (variablesExtension ).isEmpty ()
282299 ? ImmutableList .of ()
283300 : ImmutableList .of (new UserVariablesExtension (asDict (variablesExtension )));
284- return CompileBuildVariables .setupVariablesOrThrowEvalException (
285- featureConfiguration .getFeatureConfiguration (),
286- ccToolchainProvider ,
287- featureConfiguration
288- .getBuildOptionsFromFeatureConfigurationCreatedForStarlark_andIKnowWhatImDoing (),
289- featureConfiguration
290- .getCppConfigurationFromFeatureConfigurationCreatedForStarlark_andIKnowWhatImDoing (),
291- convertFromNoneable (sourceFile , /* defaultValue= */ null ),
292- convertFromNoneable (outputFile , /* defaultValue= */ null ),
293- /* gcnoFile= */ null ,
294- /* isUsingFission= */ false ,
295- /* dwoFile= */ null ,
296- /* ltoIndexingFile= */ null ,
297- convertFromNoneable (thinLtoIndex , /* defaultValue= */ null ),
298- convertFromNoneable (thinLtoInputBitcodeFile , /* defaultValue=*/ null ),
299- convertFromNoneable (thinLtoOutputObjectFile , /* defaultValue=*/ null ),
300- /* includes= */ ImmutableList .of (),
301- userFlagsToIterable (userCompileFlags ),
302- /* cppModuleMap= */ null ,
303- usePic ,
304- /* fdoStamp= */ null ,
305- /* dotdFileExecPath= */ null ,
306- variablesExtensions ,
307- /* additionalBuildVariables= */ ImmutableMap .of (),
308- /* directModuleMaps= */ ImmutableList .of (),
309- Depset .noneableCast (includeDirs , String .class , "framework_include_directories" ),
310- Depset .noneableCast (quoteIncludeDirs , String .class , "quote_include_directories" ),
311- Depset .noneableCast (systemIncludeDirs , String .class , "system_include_directories" ),
312- Depset .noneableCast (frameworkIncludeDirs , String .class , "framework_include_directories" ),
313- Depset .noneableCast (defines , String .class , "preprocessor_defines" ).toList (),
314- ImmutableList .of ());
301+ CcToolchainVariables .Builder variables =
302+ CcToolchainVariables .builder (
303+ CompileBuildVariables .setupVariablesOrThrowEvalException (
304+ featureConfiguration .getFeatureConfiguration (),
305+ ccToolchainProvider ,
306+ featureConfiguration
307+ .getBuildOptionsFromFeatureConfigurationCreatedForStarlark_andIKnowWhatImDoing (),
308+ featureConfiguration
309+ .getCppConfigurationFromFeatureConfigurationCreatedForStarlark_andIKnowWhatImDoing (),
310+ convertFromNoneable (sourceFile , /* defaultValue= */ null ),
311+ convertFromNoneable (outputFile , /* defaultValue= */ null ),
312+ /* gcnoFile= */ null ,
313+ /* isUsingFission= */ false ,
314+ /* dwoFile= */ null ,
315+ /* ltoIndexingFile= */ null ,
316+ convertFromNoneable (thinLtoIndex , /* defaultValue= */ null ),
317+ convertFromNoneable (thinLtoInputBitcodeFile , /* defaultValue=*/ null ),
318+ convertFromNoneable (thinLtoOutputObjectFile , /* defaultValue=*/ null ),
319+ /* includes= */ ImmutableList .of (),
320+ userFlagsToIterable (userCompileFlags ),
321+ /* cppModuleMap= */ null ,
322+ usePic ,
323+ /* fdoStamp= */ null ,
324+ /* dotdFileExecPath= */ null ,
325+ variablesExtensions ,
326+ /* additionalBuildVariables= */ ImmutableMap .of (),
327+ /* directModuleMaps= */ ImmutableList .of (),
328+ Depset .noneableCast (includeDirs , String .class , "framework_include_directories" ),
329+ Depset .noneableCast (
330+ quoteIncludeDirs , String .class , "quote_include_directories" ),
331+ Depset .noneableCast (
332+ systemIncludeDirs , String .class , "system_include_directories" ),
333+ Depset .noneableCast (
334+ frameworkIncludeDirs , String .class , "framework_include_directories" ),
335+ Depset .noneableCast (defines , String .class , "preprocessor_defines" ).toList (),
336+ ImmutableList .of ()))
337+ .addStringSequenceVariable ("stripopts" , asClassImmutableList (stripOpts ));
338+
339+ String inputFileString = convertFromNoneable (inputFile , null );
340+ if (inputFileString != null ) {
341+ variables .addStringVariable ("input_file" , inputFileString );
342+ }
343+ return variables .build ();
315344 }
316345
317346 @ Override
@@ -1804,16 +1833,26 @@ public Tuple createLinkingContextFromCompilationOutputs(
18041833 Sequence <?> linkingContexts , // <CcLinkingContext> expected
18051834 String name ,
18061835 String languageString ,
1807- boolean alwayslink , // <Artifact> expected
1808- Sequence <?> additionalInputs ,
1836+ boolean alwayslink ,
1837+ Sequence <?> additionalInputs , // <Artifact> expected
18091838 boolean disallowStaticLibraries ,
18101839 boolean disallowDynamicLibraries ,
18111840 Object grepIncludes ,
18121841 Object variablesExtension ,
1842+ Object stamp ,
18131843 StarlarkThread thread )
18141844 throws InterruptedException , EvalException {
1845+ if (checkObjectsBound (stamp )) {
1846+ CcModule .checkPrivateStarlarkificationAllowlist (thread );
1847+ }
18151848 Language language = parseLanguage (languageString );
18161849 StarlarkActionFactory actions = starlarkActionFactoryApi ;
1850+ int stampInt = 0 ;
1851+ if (stamp != Starlark .UNBOUND ) {
1852+ stampInt = (int ) stamp ;
1853+ }
1854+ boolean isStampingEnabled =
1855+ isStampingEnabled (stampInt , actions .getRuleContext ().getConfiguration ());
18171856 CcToolchainProvider ccToolchainProvider =
18181857 convertFromNoneable (starlarkCcToolchainProvider , null );
18191858 FeatureConfigurationForStarlark featureConfiguration =
@@ -1863,6 +1902,7 @@ public Tuple createLinkingContextFromCompilationOutputs(
18631902 .setStaticLinkType (staticLinkTargetType )
18641903 .setDynamicLinkType (LinkTargetType .NODEPS_DYNAMIC_LIBRARY )
18651904 .emitInterfaceSharedLibraries (true )
1905+ .setIsStampingEnabled (isStampingEnabled )
18661906 .addLinkopts (Sequence .cast (userLinkFlags , String .class , "user_link_flags" ));
18671907 if (!asDict (variablesExtension ).isEmpty ()) {
18681908 helper .addVariableExtension (new UserVariablesExtension (asDict (variablesExtension )));
@@ -2268,6 +2308,9 @@ protected CcLinkingOutputs link(
22682308 Object onlyForDynamicLibsObject ,
22692309 Object mainOutputObject ,
22702310 Object linkerOutputsObject ,
2311+ Object useTestOnlyFlags ,
2312+ Object pdbFile ,
2313+ Object winDefFile ,
22712314 StarlarkThread thread )
22722315 throws InterruptedException , EvalException {
22732316 // TODO(bazel-team): Rename always_link to alwayslink before delisting. Also it looks like the
@@ -2284,7 +2327,10 @@ protected CcLinkingOutputs link(
22842327 wholeArchiveObject ,
22852328 additionalLinkstampDefines ,
22862329 mainOutputObject ,
2287- onlyForDynamicLibsObject )) {
2330+ onlyForDynamicLibsObject ,
2331+ useTestOnlyFlags ,
2332+ pdbFile ,
2333+ winDefFile )) {
22882334 checkPrivateStarlarkificationAllowlist (thread );
22892335 }
22902336 Language language = parseLanguage (languageString );
@@ -2379,6 +2425,9 @@ protected CcLinkingOutputs link(
23792425 && CppHelper .useInterfaceSharedLibraries (
23802426 cppConfiguration , ccToolchainProvider , actualFeatureConfiguration ))
23812427 .setLinkerOutputArtifact (convertFromNoneable (mainOutput , null ))
2428+ .setUseTestOnlyFlags (convertFromNoneable (useTestOnlyFlags , false ))
2429+ .setPdbFile (convertFromNoneable (pdbFile , null ))
2430+ .setDefFile (convertFromNoneable (winDefFile , null ))
23822431 .addLinkerOutputs (linkerOutputs );
23832432 if (staticLinkTargetType != null ) {
23842433 helper .setShouldCreateDynamicLibrary (false ).setStaticLinkType (staticLinkTargetType );
@@ -2397,7 +2446,14 @@ protected CcLinkingOutputs link(
23972446 }
23982447
23992448 protected CcCompilationOutputs createCompilationOutputsFromStarlark (
2400- Object objectsObject , Object picObjectsObject ) throws EvalException {
2449+ Object objectsObject ,
2450+ Object picObjectsObject ,
2451+ Object ltoCompilationContextObject ,
2452+ StarlarkThread thread )
2453+ throws EvalException {
2454+ if (checkObjectsBound (ltoCompilationContextObject )) {
2455+ CcModule .checkPrivateStarlarkificationAllowlist (thread );
2456+ }
24012457 CcCompilationOutputs .Builder ccCompilationOutputsBuilder = CcCompilationOutputs .builder ();
24022458 NestedSet <Artifact > objects = convertToNestedSet (objectsObject , Artifact .class , "objects" );
24032459 validateExtensions (
@@ -2406,6 +2462,8 @@ protected CcCompilationOutputs createCompilationOutputsFromStarlark(
24062462 Link .OBJECT_FILETYPES ,
24072463 Link .OBJECT_FILETYPES ,
24082464 /* allowAnyTreeArtifacts= */ false );
2465+ LtoCompilationContext ltoCompilationContext =
2466+ convertFromNoneable (ltoCompilationContextObject , null );
24092467 NestedSet <Artifact > picObjects =
24102468 convertToNestedSet (picObjectsObject , Artifact .class , "pic_objects" );
24112469 validateExtensions (
@@ -2416,6 +2474,9 @@ protected CcCompilationOutputs createCompilationOutputsFromStarlark(
24162474 /* allowAnyTreeArtifacts= */ false );
24172475 ccCompilationOutputsBuilder .addObjectFiles (objects .toList ());
24182476 ccCompilationOutputsBuilder .addPicObjectFiles (picObjects .toList ());
2477+ if (ltoCompilationContext != null ) {
2478+ ccCompilationOutputsBuilder .addLtoCompilationContext (ltoCompilationContext );
2479+ }
24192480 return ccCompilationOutputsBuilder .build ();
24202481 }
24212482
0 commit comments