use of com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.InvalidFamilyNameException in project bazel by bazelbuild.
the class ObjcBundleLibrary method bundling.
private Bundling bundling(RuleContext ruleContext, ObjcCommon common) {
IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext);
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
ImmutableSet<TargetDeviceFamily> families = null;
List<String> rawFamilies = ruleContext.attributes().get(FAMILIES_ATTR, Type.STRING_LIST);
try {
families = ImmutableSet.copyOf(TargetDeviceFamily.fromNamesInRule(rawFamilies));
} catch (InvalidFamilyNameException | RepeatedFamilyNameException e) {
families = ImmutableSet.of();
}
if (families.isEmpty()) {
ruleContext.attributeError(FAMILIES_ATTR, ReleaseBundling.INVALID_FAMILIES_ERROR);
}
return new Bundling.Builder().setName(ruleContext.getLabel().getName()).setArchitecture(appleConfiguration.getIosCpu()).setBundleDirFormat("%s.bundle").setObjcProvider(common.getObjcProvider()).addInfoplistInputFromRule(ruleContext).setIntermediateArtifacts(intermediateArtifacts).setMinimumOsVersion(appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)).setTargetDeviceFamilies(families).build();
}
use of com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.InvalidFamilyNameException in project bazel by bazelbuild.
the class ReleaseBundling method releaseBundling.
/**
* Returns a {@link ReleaseBundling} object constructed using the information available in given
* context.
*/
public static ReleaseBundling releaseBundling(RuleContext ruleContext) throws InterruptedException {
Preconditions.checkState(!Strings.isNullOrEmpty(ruleContext.attributes().get(BUNDLE_ID_ATTR, Type.STRING)), "requires a bundle_id value");
String primaryBundleId = null;
String fallbackBundleId = null;
Artifact provisioningProfile;
if (ruleContext.attributes().isAttributeValueExplicitlySpecified(BUNDLE_ID_ATTR)) {
primaryBundleId = ruleContext.attributes().get(BUNDLE_ID_ATTR, Type.STRING);
} else {
fallbackBundleId = ruleContext.attributes().get(BUNDLE_ID_ATTR, Type.STRING);
}
Artifact explicitProvisioningProfile = ruleContext.getPrerequisiteArtifact(PROVISIONING_PROFILE_ATTR, Mode.TARGET);
if (explicitProvisioningProfile != null) {
provisioningProfile = explicitProvisioningProfile;
} else {
provisioningProfile = ruleContext.getPrerequisiteArtifact(DEFAULT_PROVISIONING_PROFILE_ATTR, Mode.TARGET);
}
ImmutableSet<TargetDeviceFamily> families = null;
List<String> rawFamilies = ruleContext.attributes().get(FAMILIES_ATTR, Type.STRING_LIST);
try {
families = ImmutableSet.copyOf(TargetDeviceFamily.fromNamesInRule(rawFamilies));
} catch (InvalidFamilyNameException | RepeatedFamilyNameException e) {
families = ImmutableSet.of();
}
if (families.isEmpty()) {
ruleContext.attributeError(FAMILIES_ATTR, INVALID_FAMILIES_ERROR);
}
return new ReleaseBundling.Builder().setIpaArtifact(ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA)).setBundleId(ruleContext.attributes().get(BUNDLE_ID_ATTR, Type.STRING)).setPrimaryBundleId(primaryBundleId).setFallbackBundleId(fallbackBundleId).setAppIcon(Strings.emptyToNull(ruleContext.attributes().get(APP_ICON_ATTR, Type.STRING))).setLaunchImage(Strings.emptyToNull(ruleContext.attributes().get(LAUNCH_IMAGE_ATTR, Type.STRING))).setLaunchStoryboard(ruleContext.getPrerequisiteArtifact(LAUNCH_STORYBOARD_ATTR, Mode.TARGET)).setProvisioningProfile(provisioningProfile).setProvisioningProfileAttributeName(PROVISIONING_PROFILE_ATTR).setTargetDeviceFamilies(families).setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext)).setEntitlements(ruleContext.getPrerequisiteArtifact("entitlements", Mode.TARGET)).build();
}
Aggregations