Skip to content

Commit

Permalink
Automated rollback of commit 36f093a.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Accidentally added some pending changes from a different client right before submission. Partial rollback to get rid of those.

*** Original change description ***

Allow *allowMultiple* options to be *set* by Starlark transitions.

Specifically helpful for --define.

Work towards #5574

RELNOTES: None.
PiperOrigin-RevId: 242759162
  • Loading branch information
juliexxia authored and copybara-github committed Apr 9, 2019
1 parent b4bc40a commit 5cd0e66
Showing 1 changed file with 1 addition and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.google.devtools.build.lib.syntax.Runtime.NoneType;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.syntax.SkylarkList.MutableList;
import com.google.devtools.common.options.OptionDefinition;
import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.OptionsParsingException;
Expand Down Expand Up @@ -179,33 +178,7 @@ static SkylarkDict<String, Object> buildSettings(
Field field = optionInfo.getDefinition().getField();
FragmentOptions options = buildOptions.get(optionInfo.getOptionClass());
Object optionValue = field.get(options);
if (optionInfo.getDefinition().allowsMultiple()) {
List<?> optionValueList = (List<?>) optionValue;
if (optionValueList.isEmpty()) {
optionValue = MutableList.empty();
} else {
if (optionValueList.get(0) instanceof Map.Entry) {
SkylarkDict<String, String> valueDict = SkylarkDict.withMutability(mutability);
for (Map.Entry singleValue : (List<Map.Entry>) optionValueList) {
valueDict.put(
singleValue.getKey().toString(),
singleValue.getValue().toString(),
starlarkTransition.getLocationForErrorReporting(),
mutability);
}
optionValue = valueDict;
}
}
} else {
if (optionValue instanceof Map.Entry) {
SkylarkDict<String, String> valueDict = SkylarkDict.withMutability(mutability);
valueDict.put(
((Map.Entry) optionValue).getKey().toString(),
((Map.Entry) optionValue).getValue().toString(),
starlarkTransition.getLocationForErrorReporting(),
mutability);
}
}

dict.put(optionKey, optionValue == null ? Runtime.NONE : optionValue, null, mutability);
} catch (IllegalAccessException e) {
// These exceptions should not happen, but if they do, throw a RuntimeException.
Expand Down

0 comments on commit 5cd0e66

Please sign in to comment.