|
19 | 19 | import com.google.common.base.Strings;
|
20 | 20 | import com.google.common.collect.ImmutableSortedMap;
|
21 | 21 | import com.google.common.collect.Ordering;
|
| 22 | +import com.google.devtools.build.lib.actions.Spawn; |
22 | 23 | import com.google.devtools.build.lib.actions.UserExecException;
|
23 | 24 | import com.google.devtools.build.lib.remote.options.RemoteOptions;
|
24 | 25 | import com.google.protobuf.TextFormat;
|
|
33 | 34 | public final class PlatformUtils {
|
34 | 35 |
|
35 | 36 | @Nullable
|
36 |
| - public static Platform getPlatformProto( |
37 |
| - @Nullable PlatformInfo executionPlatform, @Nullable RemoteOptions remoteOptions) |
| 37 | + public static Platform getPlatformProto(Spawn spawn, @Nullable RemoteOptions remoteOptions) |
38 | 38 | throws UserExecException {
|
39 | 39 | SortedMap<String, String> defaultExecProperties =
|
40 | 40 | remoteOptions != null
|
41 | 41 | ? remoteOptions.getRemoteDefaultExecProperties()
|
42 | 42 | : ImmutableSortedMap.of();
|
43 | 43 |
|
44 |
| - if (executionPlatform == null && defaultExecProperties.isEmpty()) { |
| 44 | + if (spawn.getExecutionPlatform() == null |
| 45 | + && spawn.getCombinedExecProperties().isEmpty() |
| 46 | + && defaultExecProperties.isEmpty()) { |
45 | 47 | return null;
|
46 | 48 | }
|
47 | 49 |
|
48 | 50 | Platform.Builder platformBuilder = Platform.newBuilder();
|
49 | 51 |
|
50 |
| - if (executionPlatform != null && !executionPlatform.execProperties().isEmpty()) { |
51 |
| - for (Map.Entry<String, String> entry : executionPlatform.execProperties().entrySet()) { |
| 52 | + if (!spawn.getCombinedExecProperties().isEmpty()) { |
| 53 | + for (Map.Entry<String, String> entry : spawn.getCombinedExecProperties().entrySet()) { |
52 | 54 | platformBuilder.addPropertiesBuilder().setName(entry.getKey()).setValue(entry.getValue());
|
53 | 55 | }
|
54 |
| - } else if (executionPlatform != null |
55 |
| - && !Strings.isNullOrEmpty(executionPlatform.remoteExecutionProperties())) { |
| 56 | + } else if (spawn.getExecutionPlatform() != null |
| 57 | + && !Strings.isNullOrEmpty(spawn.getExecutionPlatform().remoteExecutionProperties())) { |
56 | 58 | // Try and get the platform info from the execution properties.
|
57 | 59 | try {
|
58 | 60 | TextFormat.getParser()
|
59 |
| - .merge(executionPlatform.remoteExecutionProperties(), platformBuilder); |
| 61 | + .merge(spawn.getExecutionPlatform().remoteExecutionProperties(), platformBuilder); |
60 | 62 | } catch (ParseException e) {
|
61 | 63 | throw new UserExecException(
|
62 | 64 | String.format(
|
63 | 65 | "Failed to parse remote_execution_properties from platform %s",
|
64 |
| - executionPlatform.label()), |
| 66 | + spawn.getExecutionPlatform().label()), |
65 | 67 | e);
|
66 | 68 | }
|
67 | 69 | } else {
|
|
0 commit comments