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();
}
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()));
}
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();
}
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();
}
Aggregations