use of com.google.devtools.build.lib.rules.apple.XcodeVersionProperties in project bazel by bazelbuild.
the class IosDevice method create.
@Override
public ConfiguredTarget create(RuleContext context) throws InterruptedException, RuleErrorException {
AppleConfiguration appleConfiguration = context.getFragment(AppleConfiguration.class);
String iosVersionAttribute = context.attributes().get(IosDeviceRule.IOS_VERSION_ATTR_NAME, STRING);
XcodeVersionProperties xcodeVersionProperties = (XcodeVersionProperties) context.getPrerequisite(IosDeviceRule.XCODE_ATTR_NAME, Mode.TARGET, XcodeVersionProperties.SKYLARK_CONSTRUCTOR.getKey());
DottedVersion xcodeVersion = null;
if (xcodeVersionProperties != null && xcodeVersionProperties.getXcodeVersion().isPresent()) {
xcodeVersion = xcodeVersionProperties.getXcodeVersion().get();
} else if (appleConfiguration.getXcodeVersion() != null) {
xcodeVersion = appleConfiguration.getXcodeVersion();
}
DottedVersion iosVersion;
if (!Strings.isNullOrEmpty(iosVersionAttribute)) {
iosVersion = DottedVersion.fromString(iosVersionAttribute);
} else if (xcodeVersionProperties != null) {
iosVersion = xcodeVersionProperties.getDefaultIosSdkVersion();
} else {
iosVersion = appleConfiguration.getSdkVersionForPlatform(Platform.IOS_SIMULATOR);
}
IosDeviceProvider provider = new IosDeviceProvider.Builder().setType(context.attributes().get(IosDeviceRule.TYPE_ATTR_NAME, STRING)).setIosVersion(iosVersion).setLocale(context.attributes().get(IosDeviceRule.LOCALE_ATTR_NAME, STRING)).setXcodeVersion(xcodeVersion).build();
return new RuleConfiguredTargetBuilder(context).add(RunfilesProvider.class, RunfilesProvider.EMPTY).addNativeDeclaredProvider(provider).add(IosTestSubstitutionProvider.class, provider.iosTestSubstitutionProvider()).build();
}
Aggregations