2828import com .google .common .collect .ImmutableMap ;
2929import com .google .common .collect .ImmutableSet ;
3030import com .google .common .collect .ImmutableSortedSet ;
31- import com .google .common .collect .ImmutableTable ;
3231import com .google .common .collect .Iterables ;
3332import com .google .common .collect .ListMultimap ;
3433import com .google .common .collect .Lists ;
@@ -211,7 +210,7 @@ public ImmutableList<TransitiveInfoCollection> getFiles() {
211210 private final ConstraintSemantics <RuleContext > constraintSemantics ;
212211 private final ImmutableSet <String > requiredConfigFragments ;
213212 private final List <Expander > makeVariableExpanders = new ArrayList <>();
214- private final ImmutableTable <String , String , String > execProperties ;
213+ private final ImmutableMap <String , ImmutableMap < String , String > > execProperties ;
215214
216215 /** Map of exec group names to ActionOwners. */
217216 private final Map <String , ActionOwner > actionOwners = new HashMap <>();
@@ -604,16 +603,17 @@ private static ImmutableMap<String, String> computeExecProperties(
604603 Map <String , String > execProperties = new HashMap <>();
605604
606605 if (executionPlatform != null ) {
607- ImmutableTable <String , String , String > execPropertiesPerGroup =
606+ Map <String , Map < String , String > > execPropertiesPerGroup =
608607 parseExecGroups (executionPlatform .execProperties ());
609608
610- if (execPropertiesPerGroup .containsRow (DEFAULT_EXEC_GROUP_NAME )) {
611- execProperties .putAll (execPropertiesPerGroup .row (DEFAULT_EXEC_GROUP_NAME ));
609+ if (execPropertiesPerGroup .containsKey (DEFAULT_EXEC_GROUP_NAME )) {
610+ execProperties .putAll (execPropertiesPerGroup .get (DEFAULT_EXEC_GROUP_NAME ));
611+ execPropertiesPerGroup .remove (DEFAULT_EXEC_GROUP_NAME );
612612 }
613613
614- for (String execGroup : execPropertiesPerGroup .rowKeySet ()) {
615- if (execGroups .contains (execGroup )) {
616- execProperties .putAll (execPropertiesPerGroup . row ( execGroup ));
614+ for (Map . Entry < String , Map < String , String >> execGroup : execPropertiesPerGroup .entrySet ()) {
615+ if (execGroups .contains (execGroup . getKey () )) {
616+ execProperties .putAll (execGroup . getValue ( ));
617617 }
618618 }
619619 }
@@ -1273,10 +1273,10 @@ public ImmutableSortedSet<String> getRequiredConfigFragments() {
12731273 return ans .build ();
12741274 }
12751275
1276- private ImmutableTable <String , String , String > parseExecProperties (
1276+ private ImmutableMap <String , ImmutableMap < String , String > > parseExecProperties (
12771277 Map <String , String > execProperties ) throws InvalidExecGroupException {
12781278 if (execProperties .isEmpty ()) {
1279- return ImmutableTable .of ();
1279+ return ImmutableMap .of (DEFAULT_EXEC_GROUP_NAME , ImmutableMap . of () );
12801280 } else {
12811281 return parseExecProperties (
12821282 execProperties , toolchainContexts == null ? null : toolchainContexts .getExecGroups ());
@@ -1289,35 +1289,39 @@ private ImmutableTable<String, String, String> parseExecProperties(
12891289 * former get parsed into the default exec group, the latter get parsed into their relevant exec
12901290 * groups.
12911291 */
1292- private static ImmutableTable <String , String , String > parseExecGroups (
1292+ private static Map <String , Map < String , String > > parseExecGroups (
12931293 Map <String , String > rawExecProperties ) {
1294- ImmutableTable .Builder <String , String , String > execProperties = ImmutableTable .builder ();
1294+ Map <String , Map <String , String >> consolidatedProperties = new HashMap <>();
1295+ consolidatedProperties .put (DEFAULT_EXEC_GROUP_NAME , new HashMap <>());
12951296 for (Map .Entry <String , String > execProperty : rawExecProperties .entrySet ()) {
12961297 String rawProperty = execProperty .getKey ();
12971298 int delimiterIndex = rawProperty .indexOf ('.' );
12981299 if (delimiterIndex == -1 ) {
1299- execProperties .put (DEFAULT_EXEC_GROUP_NAME , rawProperty , execProperty .getValue ());
1300+ consolidatedProperties
1301+ .get (DEFAULT_EXEC_GROUP_NAME )
1302+ .put (rawProperty , execProperty .getValue ());
13001303 } else {
13011304 String execGroup = rawProperty .substring (0 , delimiterIndex );
13021305 String property = rawProperty .substring (delimiterIndex + 1 );
1303- execProperties .put (execGroup , property , execProperty .getValue ());
1306+ consolidatedProperties .putIfAbsent (execGroup , new HashMap <>());
1307+ consolidatedProperties .get (execGroup ).put (property , execProperty .getValue ());
13041308 }
13051309 }
1306- return execProperties . build () ;
1310+ return consolidatedProperties ;
13071311 }
13081312
13091313 /**
13101314 * Parse raw exec properties attribute value into a map of exec group names to their properties.
13111315 * If given a set of exec groups, validates all the exec groups in the map are applicable to the
13121316 * action.
13131317 */
1314- private static ImmutableTable <String , String , String > parseExecProperties (
1318+ private static ImmutableMap <String , ImmutableMap < String , String > > parseExecProperties (
13151319 Map <String , String > rawExecProperties , @ Nullable Set <String > execGroups )
13161320 throws InvalidExecGroupException {
1317- ImmutableTable <String , String , String > consolidatedProperties =
1318- parseExecGroups (rawExecProperties );
1321+ Map <String , Map <String , String >> consolidatedProperties = parseExecGroups (rawExecProperties );
13191322 if (execGroups != null ) {
1320- for (String execGroupName : consolidatedProperties .rowKeySet ()) {
1323+ for (Map .Entry <String , Map <String , String >> execGroup : consolidatedProperties .entrySet ()) {
1324+ String execGroupName = execGroup .getKey ();
13211325 if (!execGroupName .equals (DEFAULT_EXEC_GROUP_NAME ) && !execGroups .contains (execGroupName )) {
13221326 throw new InvalidExecGroupException (
13231327 String .format (
@@ -1326,7 +1330,14 @@ private static ImmutableTable<String, String, String> parseExecProperties(
13261330 }
13271331 }
13281332
1329- return consolidatedProperties ;
1333+ // Copy everything to immutable maps.
1334+ ImmutableMap .Builder <String , ImmutableMap <String , String >> execProperties =
1335+ new ImmutableMap .Builder <>();
1336+ for (Map .Entry <String , Map <String , String >> execGroupMap : consolidatedProperties .entrySet ()) {
1337+ execProperties .put (execGroupMap .getKey (), ImmutableMap .copyOf (execGroupMap .getValue ()));
1338+ }
1339+
1340+ return execProperties .build ();
13301341 }
13311342
13321343 /**
@@ -1338,16 +1349,16 @@ private static ImmutableTable<String, String, String> parseExecProperties(
13381349 * @param execProperties Map of exec group name to map of properties and values
13391350 */
13401351 private static ImmutableMap <String , String > getExecProperties (
1341- String execGroup , ImmutableTable <String , String , String > execProperties ) {
1342- if (!execProperties .containsRow (execGroup ) || execGroup .equals (DEFAULT_EXEC_GROUP_NAME )) {
1343- return execProperties .row (DEFAULT_EXEC_GROUP_NAME );
1352+ String execGroup , Map <String , ImmutableMap < String , String > > execProperties ) {
1353+ if (!execProperties .containsKey (execGroup ) || execGroup .equals (DEFAULT_EXEC_GROUP_NAME )) {
1354+ return execProperties .get (DEFAULT_EXEC_GROUP_NAME );
13441355 }
13451356
13461357 // Use a HashMap to build here because we expect duplicate keys to happen
13471358 // (and rewrite previous entries).
13481359 Map <String , String > targetAndGroupProperties =
1349- new HashMap <>(execProperties .row (DEFAULT_EXEC_GROUP_NAME ));
1350- targetAndGroupProperties .putAll (execProperties .row (execGroup ));
1360+ new HashMap <>(execProperties .get (DEFAULT_EXEC_GROUP_NAME ));
1361+ targetAndGroupProperties .putAll (execProperties .get (execGroup ));
13511362 return ImmutableMap .copyOf (targetAndGroupProperties );
13521363 }
13531364
@@ -1368,6 +1379,11 @@ public DetailedExitCode getDetailedExitCode() {
13681379 }
13691380 }
13701381
1382+ @ VisibleForTesting
1383+ public ImmutableMap <String , ImmutableMap <String , String >> getExecPropertiesForTesting () {
1384+ return execProperties ;
1385+ }
1386+
13711387 private void checkAttributeIsDependency (String attributeName ) {
13721388 Attribute attributeDefinition = attributes .getAttributeDefinition (attributeName );
13731389 if (attributeDefinition == null ) {
0 commit comments