Search in sources :

Example 1 with XcodeVersionProperties

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();
}
Also used : DottedVersion(com.google.devtools.build.lib.rules.apple.DottedVersion) XcodeVersionProperties(com.google.devtools.build.lib.rules.apple.XcodeVersionProperties) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) RunfilesProvider(com.google.devtools.build.lib.analysis.RunfilesProvider)

Aggregations

RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)1 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)1 AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)1 DottedVersion (com.google.devtools.build.lib.rules.apple.DottedVersion)1 XcodeVersionProperties (com.google.devtools.build.lib.rules.apple.XcodeVersionProperties)1