Search in sources :

Example 1 with DottedVersion

use of com.google.devtools.build.lib.rules.apple.DottedVersion in project bazel by bazelbuild.

the class LegacyCompilationSupport method commonLinkAndCompileFlagsForClang.

/** Returns a list of clang flags used for all link and compile actions executed through clang. */
private List<String> commonLinkAndCompileFlagsForClang(ObjcProvider provider, ObjcConfiguration objcConfiguration, AppleConfiguration appleConfiguration) {
    ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
    Platform platform = appleConfiguration.getSingleArchPlatform();
    String minOSVersionArg;
    switch(platform) {
        case IOS_SIMULATOR:
            minOSVersionArg = "-mios-simulator-version-min";
            break;
        case IOS_DEVICE:
            minOSVersionArg = "-miphoneos-version-min";
            break;
        case WATCHOS_SIMULATOR:
            minOSVersionArg = "-mwatchos-simulator-version-min";
            break;
        case WATCHOS_DEVICE:
            minOSVersionArg = "-mwatchos-version-min";
            break;
        case TVOS_SIMULATOR:
            minOSVersionArg = "-mtvos-simulator-version-min";
            break;
        case TVOS_DEVICE:
            minOSVersionArg = "-mtvos-version-min";
            break;
        default:
            throw new IllegalArgumentException("Unhandled platform " + platform);
    }
    DottedVersion minOSVersion = appleConfiguration.getMinimumOsForPlatformType(platform.getType());
    builder.add(minOSVersionArg + "=" + minOSVersion);
    if (objcConfiguration.generateDsym()) {
        builder.add("-g");
    }
    return builder.add("-arch", appleConfiguration.getSingleArchitecture()).add("-isysroot", AppleToolchain.sdkDir()).addAll(commonFrameworkFlags(provider, appleConfiguration)).build();
}
Also used : DottedVersion(com.google.devtools.build.lib.rules.apple.DottedVersion) Platform(com.google.devtools.build.lib.rules.apple.Platform) ImmutableList(com.google.common.collect.ImmutableList) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)

Example 2 with DottedVersion

use of com.google.devtools.build.lib.rules.apple.DottedVersion in project bazel by bazelbuild.

the class TestSupport method getExtraProviders.

/**
   * Returns any additional providers that need to be exported to the rule context to the passed
   * builder.
   */
public Iterable<SkylarkClassObject> getExtraProviders() {
    IosDeviceProvider deviceProvider = (IosDeviceProvider) ruleContext.getPrerequisite(IosTest.TARGET_DEVICE, Mode.TARGET, IosDeviceProvider.SKYLARK_CONSTRUCTOR.getKey());
    DottedVersion xcodeVersion = deviceProvider.getXcodeVersion();
    AppleConfiguration configuration = ruleContext.getFragment(AppleConfiguration.class);
    ImmutableMap.Builder<String, String> envBuilder = ImmutableMap.builder();
    if (xcodeVersion != null) {
        envBuilder.putAll(configuration.getXcodeVersionEnv(xcodeVersion));
    }
    if (ruleContext.getConfiguration().isCodeCoverageEnabled()) {
        envBuilder.put("COVERAGE_GCOV_PATH", ruleContext.getHostPrerequisiteArtifact(IosTest.OBJC_GCOV_ATTR).getExecPathString());
        envBuilder.put("APPLE_COVERAGE", "1");
    }
    return ImmutableList.<SkylarkClassObject>of(new TestEnvironmentProvider(envBuilder.build()));
}
Also used : DottedVersion(com.google.devtools.build.lib.rules.apple.DottedVersion) SkylarkClassObject(com.google.devtools.build.lib.packages.SkylarkClassObject) TestEnvironmentProvider(com.google.devtools.build.lib.rules.test.TestEnvironmentProvider) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with DottedVersion

use of com.google.devtools.build.lib.rules.apple.DottedVersion 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)

Example 4 with DottedVersion

use of com.google.devtools.build.lib.rules.apple.DottedVersion in project bazel by bazelbuild.

the class WatchApplicationSupport method createBundle.

private void createBundle(Optional<XcodeProvider.Builder> xcodeProviderBuilder, ObjcProvider depsObjcProvider, NestedSetBuilder<Artifact> filesToBuild) throws InterruptedException {
    registerActions();
    ReleaseBundling.Builder releaseBundling = new ReleaseBundling.Builder().setIpaArtifact(ipaArtifact).setBundleId(attributes.bundleId()).setAppIcon(attributes.appIcon()).setProvisioningProfile(attributes.provisioningProfile()).setProvisioningProfileAttributeName(WATCH_APP_PROVISIONING_PROFILE_ATTR).setTargetDeviceFamilies(families()).setIntermediateArtifacts(intermediateArtifacts).setInfoPlistsFromRule(attributes.infoPlists()).setArtifactPrefix(artifactPrefix).setEntitlements(attributes.entitlements());
    if (attributes.isBundleIdExplicitySpecified()) {
        releaseBundling.setPrimaryBundleId(attributes.bundleId());
    } else {
        releaseBundling.setFallbackBundleId(attributes.bundleId());
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    PlatformType appPlatformType = watchOSVersion == WatchOSVersion.OS1 ? PlatformType.IOS : PlatformType.WATCHOS;
    DottedVersion minimumOsVersion = appPlatformType == PlatformType.IOS ? WatchUtils.determineMinimumIosVersion(appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)) : appleConfiguration.getMinimumOsForPlatformType(PlatformType.WATCHOS);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, depsObjcProvider, LinkedBinary.DEPENDENCIES_ONLY, watchOSVersion.getApplicationBundleDirFormat(), bundleName, minimumOsVersion, releaseBundling.build(), appleConfiguration.getMultiArchPlatform(appPlatformType)).registerActions(DsymOutputType.APP);
    if (xcodeProviderBuilder.isPresent()) {
        releaseBundlingSupport.addXcodeSettings(xcodeProviderBuilder.get());
    }
    releaseBundlingSupport.addFilesToBuild(filesToBuild, Optional.<DsymOutputType>absent()).validateResources().validateAttributes();
}
Also used : DottedVersion(com.google.devtools.build.lib.rules.apple.DottedVersion) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Aggregations

DottedVersion (com.google.devtools.build.lib.rules.apple.DottedVersion)4 AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)3 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)1 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)1 SkylarkClassObject (com.google.devtools.build.lib.packages.SkylarkClassObject)1 Platform (com.google.devtools.build.lib.rules.apple.Platform)1 PlatformType (com.google.devtools.build.lib.rules.apple.Platform.PlatformType)1 XcodeVersionProperties (com.google.devtools.build.lib.rules.apple.XcodeVersionProperties)1 TestEnvironmentProvider (com.google.devtools.build.lib.rules.test.TestEnvironmentProvider)1