@@ -483,8 +483,7 @@ public ActionOwner getActionOwner(String execGroup) {
483483 aspectDescriptors ,
484484 getConfiguration (),
485485 getExecProperties (execGroup , execProperties ),
486- getExecutionPlatform (execGroup ),
487- ImmutableSet .of (execGroup ));
486+ getExecutionPlatform (execGroup ));
488487 actionOwners .put (execGroup , actionOwner );
489488 return actionOwner ;
490489 }
@@ -591,31 +590,12 @@ public ImmutableList<Artifact> getBuildInfo(BuildInfoKey key) throws Interrupted
591590 AnalysisUtils .isStampingEnabled (this , getConfiguration ()), key , getConfiguration ());
592591 }
593592
594- /**
595- * Computes a map of exec properties given the execution platform, taking only properties in exec
596- * groups that are applicable to this action. Properties for specific exec groups take precedence
597- * over properties that don't specify an exec group.
598- */
599593 private static ImmutableMap <String , String > computeExecProperties (
600- Map <String , String > targetExecProperties ,
601- @ Nullable PlatformInfo executionPlatform ,
602- Set <String > execGroups ) {
594+ Map <String , String > targetExecProperties , @ Nullable PlatformInfo executionPlatform ) {
603595 Map <String , String > execProperties = new HashMap <>();
604596
605597 if (executionPlatform != null ) {
606- Map <String , Map <String , String >> execPropertiesPerGroup =
607- parseExecGroups (executionPlatform .execProperties ());
608-
609- if (execPropertiesPerGroup .containsKey (DEFAULT_EXEC_GROUP_NAME )) {
610- execProperties .putAll (execPropertiesPerGroup .get (DEFAULT_EXEC_GROUP_NAME ));
611- execPropertiesPerGroup .remove (DEFAULT_EXEC_GROUP_NAME );
612- }
613-
614- for (Map .Entry <String , Map <String , String >> execGroup : execPropertiesPerGroup .entrySet ()) {
615- if (execGroups .contains (execGroup .getKey ())) {
616- execProperties .putAll (execGroup .getValue ());
617- }
618- }
598+ execProperties .putAll (executionPlatform .execProperties ());
619599 }
620600
621601 // If the same key occurs both in the platform and in target-specific properties, the
@@ -631,8 +611,7 @@ public static ActionOwner createActionOwner(
631611 ImmutableList <AspectDescriptor > aspectDescriptors ,
632612 BuildConfiguration configuration ,
633613 Map <String , String > targetExecProperties ,
634- @ Nullable PlatformInfo executionPlatform ,
635- Set <String > execGroups ) {
614+ @ Nullable PlatformInfo executionPlatform ) {
636615 return ActionOwner .create (
637616 rule .getLabel (),
638617 aspectDescriptors ,
@@ -642,7 +621,7 @@ public static ActionOwner createActionOwner(
642621 configuration .checksum (),
643622 configuration .toBuildEvent (),
644623 configuration .isHostConfiguration () ? HOST_CONFIGURATION_PROGRESS_TAG : null ,
645- computeExecProperties (targetExecProperties , executionPlatform , execGroups ),
624+ computeExecProperties (targetExecProperties , executionPlatform ),
646625 executionPlatform );
647626 }
648627
@@ -1279,18 +1258,20 @@ private ImmutableMap<String, ImmutableMap<String, String>> parseExecProperties(
12791258 return ImmutableMap .of (DEFAULT_EXEC_GROUP_NAME , ImmutableMap .of ());
12801259 } else {
12811260 return parseExecProperties (
1282- execProperties , toolchainContexts == null ? null : toolchainContexts .getExecGroups ());
1261+ execProperties ,
1262+ toolchainContexts == null ? ImmutableSet .of () : toolchainContexts .getExecGroups ());
12831263 }
12841264 }
12851265
12861266 /**
12871267 * Parse raw exec properties attribute value into a map of exec group names to their properties.
12881268 * The raw map can have keys of two forms: (1) 'property' and (2) 'exec_group_name.property'. The
1289- * former get parsed into the default exec group, the latter get parsed into their relevant exec
1290- * groups.
1269+ * former get parsed into the target's default exec group, the latter get parsed into their
1270+ * relevant exec groups.
12911271 */
1292- private static Map <String , Map <String , String >> parseExecGroups (
1293- Map <String , String > rawExecProperties ) {
1272+ private static ImmutableMap <String , ImmutableMap <String , String >> parseExecProperties (
1273+ Map <String , String > rawExecProperties , Set <String > execGroups )
1274+ throws InvalidExecGroupException {
12941275 Map <String , Map <String , String >> consolidatedProperties = new HashMap <>();
12951276 consolidatedProperties .put (DEFAULT_EXEC_GROUP_NAME , new HashMap <>());
12961277 for (Map .Entry <String , String > execProperty : rawExecProperties .entrySet ()) {
@@ -1303,30 +1284,14 @@ private static Map<String, Map<String, String>> parseExecGroups(
13031284 } else {
13041285 String execGroup = rawProperty .substring (0 , delimiterIndex );
13051286 String property = rawProperty .substring (delimiterIndex + 1 );
1306- consolidatedProperties .putIfAbsent (execGroup , new HashMap <>());
1307- consolidatedProperties .get (execGroup ).put (property , execProperty .getValue ());
1308- }
1309- }
1310- return consolidatedProperties ;
1311- }
1312-
1313- /**
1314- * Parse raw exec properties attribute value into a map of exec group names to their properties.
1315- * If given a set of exec groups, validates all the exec groups in the map are applicable to the
1316- * action.
1317- */
1318- private static ImmutableMap <String , ImmutableMap <String , String >> parseExecProperties (
1319- Map <String , String > rawExecProperties , @ Nullable Set <String > execGroups )
1320- throws InvalidExecGroupException {
1321- Map <String , Map <String , String >> consolidatedProperties = parseExecGroups (rawExecProperties );
1322- if (execGroups != null ) {
1323- for (Map .Entry <String , Map <String , String >> execGroup : consolidatedProperties .entrySet ()) {
1324- String execGroupName = execGroup .getKey ();
1325- if (!execGroupName .equals (DEFAULT_EXEC_GROUP_NAME ) && !execGroups .contains (execGroupName )) {
1287+ if (!execGroups .contains (execGroup )) {
13261288 throw new InvalidExecGroupException (
13271289 String .format (
1328- "Tried to set properties for non-existent exec group '%s'." , execGroupName ));
1290+ "Tried to set exec property '%s' for non-existent exec group '%s'." ,
1291+ property , execGroup ));
13291292 }
1293+ consolidatedProperties .putIfAbsent (execGroup , new HashMap <>());
1294+ consolidatedProperties .get (execGroup ).put (property , execProperty .getValue ());
13301295 }
13311296 }
13321297
0 commit comments