aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java255
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java91
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java109
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java153
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinary.java36
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryRule.java63
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionRule.java111
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinary.java31
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java100
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java347
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java149
11 files changed, 0 insertions, 1445 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java
deleted file mode 100644
index 6e60ca84bd..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java
+++ /dev/null
@@ -1,255 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.IMPORTED_LIBRARY;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.LIBRARY;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.RunfilesSupport;
-import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
-import com.google.devtools.build.lib.analysis.test.InstrumentedFilesProvider;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.apple.ApplePlatform;
-import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
-import com.google.devtools.build.lib.rules.apple.XcodeConfig;
-import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs;
-import com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes;
-import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.LinkedBinary;
-import com.google.devtools.build.lib.rules.proto.ProtoSourcesProvider;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Implementation for rules that link binaries.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-abstract class BinaryLinkingTargetFactory implements RuleConfiguredTargetFactory {
- /**
- * Indicates whether this binary generates an application bundle. If so, it causes the {@code
- * infoplist} attribute to be read and a bundle to be added to the files-to-build.
- */
- enum HasReleaseBundlingSupport {
- YES,
- NO;
- }
-
- private final HasReleaseBundlingSupport hasReleaseBundlingSupport;
-
- protected BinaryLinkingTargetFactory(HasReleaseBundlingSupport hasReleaseBundlingSupport) {
- this.hasReleaseBundlingSupport = hasReleaseBundlingSupport;
- }
-
- /**
- * Returns extra linker arguments. Default implementation returns empty list. Subclasses can
- * override and customize.
- */
- protected ExtraLinkArgs getExtraLinkArgs(RuleContext ruleContext) {
- return new ExtraLinkArgs();
- }
-
- @VisibleForTesting
- static final String REQUIRES_AT_LEAST_ONE_LIBRARY_OR_SOURCE_FILE =
- "At least one library dependency or source file is required.";
-
- @Override
- public final ConfiguredTarget create(RuleContext ruleContext)
- throws InterruptedException, RuleErrorException {
- ruleContext.ruleWarning(
- "This rule is deprecated. Please use the new Apple build rules "
- + "(https://github.com/bazelbuild/rules_apple) to build Apple targets.");
-
- Iterable<ObjcProtoProvider> objcProtoProviders =
- ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
-
- ProtobufSupport protoSupport =
- new ProtobufSupport(
- ruleContext,
- ruleContext.getConfiguration(),
- ImmutableList.<ProtoSourcesProvider>of(),
- objcProtoProviders,
- ProtobufSupport.getTransitivePortableProtoFilters(objcProtoProviders))
- .registerGenerationActions()
- .registerCompilationActions();
-
- Optional<ObjcProvider> protosObjcProvider = protoSupport.getObjcProvider();
-
- ObjcCommon common = common(ruleContext, protosObjcProvider);
-
- ObjcProvider objcProvider = common.getObjcProvider();
- assertLibraryOrSources(objcProvider, ruleContext);
-
- IntermediateArtifacts intermediateArtifacts =
- ObjcRuleClasses.intermediateArtifacts(ruleContext);
-
- NestedSetBuilder<Artifact> filesToBuild =
- NestedSetBuilder.<Artifact>stableOrder()
- .add(intermediateArtifacts.strippedSingleArchitectureBinary());
-
- new ResourceSupport(ruleContext).validateAttributes();
-
- ruleContext.assertNoErrors();
-
- J2ObjcMappingFileProvider j2ObjcMappingFileProvider =
- J2ObjcMappingFileProvider.union(
- ruleContext.getPrerequisites("deps", Mode.TARGET, J2ObjcMappingFileProvider.class));
- J2ObjcEntryClassProvider j2ObjcEntryClassProvider =
- new J2ObjcEntryClassProvider.Builder()
- .addTransitive(
- ruleContext.getPrerequisites("deps", Mode.TARGET, J2ObjcEntryClassProvider.class))
- .build();
-
- Map<String, NestedSet<Artifact>> outputGroupCollector = new TreeMap<>();
- CompilationSupport compilationSupport =
- new CompilationSupport.Builder()
- .setRuleContext(ruleContext)
- .setOutputGroupCollector(outputGroupCollector)
- .build();
-
- compilationSupport
- .validateAttributes()
- .registerCompileAndArchiveActions(common)
- .registerFullyLinkAction(
- common.getObjcProvider(),
- ruleContext.getImplicitOutputArtifact(CompilationSupport.FULLY_LINKED_LIB))
- .registerLinkActions(
- objcProvider,
- j2ObjcMappingFileProvider,
- j2ObjcEntryClassProvider,
- getExtraLinkArgs(ruleContext),
- ImmutableList.<Artifact>of(),
- DsymOutputType.APP);
-
- Optional<XcTestAppProvider> xcTestAppProvider;
- Optional<RunfilesSupport> maybeRunfilesSupport = Optional.absent();
- switch (hasReleaseBundlingSupport) {
- case YES:
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
- // TODO(bazel-team): Remove once all bundle users are migrated to ios_application.
- ReleaseBundlingSupport releaseBundlingSupport =
- new ReleaseBundlingSupport(
- ruleContext,
- objcProvider,
- LinkedBinary.LOCAL_AND_DEPENDENCIES,
- ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT,
- XcodeConfig.getMinimumOsForPlatformType(ruleContext, PlatformType.IOS),
- appleConfiguration.getSingleArchPlatform());
- releaseBundlingSupport
- .registerActions(DsymOutputType.APP)
- .addFilesToBuild(filesToBuild, Optional.of(DsymOutputType.APP))
- .validateResources()
- .validateAttributes();
-
- xcTestAppProvider = Optional.of(releaseBundlingSupport.xcTestAppProvider());
- if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS)
- == ApplePlatform.IOS_SIMULATOR) {
- Artifact runnerScript = intermediateArtifacts.runnerScript();
- Artifact ipaFile = ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA);
- releaseBundlingSupport.registerGenerateRunnerScriptAction(runnerScript, ipaFile);
- maybeRunfilesSupport = Optional.of(releaseBundlingSupport.runfilesSupport(runnerScript));
- }
- break;
- case NO:
- xcTestAppProvider = Optional.absent();
- break;
- default:
- throw new AssertionError();
- }
-
- RuleConfiguredTargetBuilder targetBuilder =
- ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build())
- .addNativeDeclaredProvider(objcProvider)
- .addNativeDeclaredProvider(objcProvider)
- .addProvider(
- InstrumentedFilesProvider.class,
- compilationSupport.getInstrumentedFilesProvider(common))
- .addOutputGroups(outputGroupCollector);
-
- if (xcTestAppProvider.isPresent()) {
- // TODO(bazel-team): Stop exporting an XcTestAppProvider once objc_binary no longer creates an
- // application bundle.
- targetBuilder.addNativeDeclaredProvider(xcTestAppProvider.get());
- }
- if (maybeRunfilesSupport.isPresent()) {
- RunfilesSupport runfilesSupport = maybeRunfilesSupport.get();
- targetBuilder.setRunfilesSupport(runfilesSupport, runfilesSupport.getExecutable());
- }
- configureTarget(targetBuilder, ruleContext);
- return targetBuilder.build();
- }
-
- private void assertLibraryOrSources(ObjcProvider objcProvider, RuleContext ruleContext)
- throws RuleErrorException {
- if (Iterables.isEmpty(objcProvider.get(LIBRARY)) // Includes sources from this target.
- && Iterables.isEmpty(objcProvider.get(IMPORTED_LIBRARY))) {
- ruleContext.throwWithRuleError(REQUIRES_AT_LEAST_ONE_LIBRARY_OR_SOURCE_FILE);
- }
- }
-
- private ObjcCommon common(RuleContext ruleContext, Optional<ObjcProvider> protosObjcProvider) {
- IntermediateArtifacts intermediateArtifacts =
- ObjcRuleClasses.intermediateArtifacts(ruleContext);
- CompilationArtifacts compilationArtifacts =
- CompilationSupport.compilationArtifacts(ruleContext);
-
- ObjcCommon.Builder builder =
- new ObjcCommon.Builder(ruleContext)
- .setCompilationAttributes(
- CompilationAttributes.Builder.fromRuleContext(ruleContext).build())
- .setCompilationArtifacts(compilationArtifacts)
- .setResourceAttributes(new ResourceAttributes(ruleContext))
- .addDefines(ruleContext.getTokenizedStringListAttr("defines"))
- .addDeps(ruleContext.getPrerequisites("deps", Mode.TARGET))
- .addRuntimeDeps(ruleContext.getPrerequisites("runtime_deps", Mode.TARGET))
- .addDeps(ruleContext.getPrerequisites("bundles", Mode.TARGET))
- .addDepObjcProviders(protosObjcProvider.asSet())
- .addNonPropagatedDepObjcProviders(
- ruleContext.getPrerequisites(
- "non_propagated_deps", Mode.TARGET, ObjcProvider.SKYLARK_CONSTRUCTOR))
- .setIntermediateArtifacts(intermediateArtifacts)
- .setAlwayslink(false)
- .setHasModuleMap()
- .setLinkedBinary(intermediateArtifacts.strippedSingleArchitectureBinary());
-
- if (ObjcRuleClasses.objcConfiguration(ruleContext).generateDsym()) {
- builder.addDebugArtifacts(DsymOutputType.APP);
- }
-
- if (ObjcRuleClasses.objcConfiguration(ruleContext).generateLinkmap()) {
- builder.setLinkmapFile(intermediateArtifacts.linkmap());
- }
-
- return builder.build();
- }
-
- /**
- * Performs additional configuration of the target. The default implementation does nothing, but
- * subclasses may override it to add logic.
- */
- protected void configureTarget(RuleConfiguredTargetBuilder target, RuleContext ruleContext) {};
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java
deleted file mode 100644
index f0b426569f..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Streams;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.config.BuildOptions;
-import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
-import com.google.devtools.build.lib.packages.Attribute.SplitTransition;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.apple.ApplePlatform;
-import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
-import com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag;
-import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.SplitArchTransition;
-
-/**
- * Implementation for {@code ios_application}.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class IosApplication extends ReleaseBundlingTargetFactory {
-
- /**
- * Transition that when applied to a target generates a configured target for each value in
- * {@code --ios_multi_cpus}, such that {@code --ios_cpu} is set to a different one of those values
- * in the configured targets.
- */
- public static final SplitTransition<BuildOptions> SPLIT_ARCH_TRANSITION =
- new SplitArchTransition();
-
- private static final ImmutableSet<Attribute> DEPENDENCY_ATTRIBUTES =
- ImmutableSet.of(
- new Attribute("binary", Mode.SPLIT),
- new Attribute("extensions", Mode.TARGET));
-
- public IosApplication() {
- super(ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT, DEPENDENCY_ATTRIBUTES);
- }
-
- /**
- * Validates that there is exactly one watch extension for each OS version.
- */
- @Override
- protected void validateAttributes(RuleContext ruleContext) {
- Iterable<ObjcProvider> extensionProviders = ruleContext.getPrerequisites(
- "extensions", Mode.TARGET, ObjcProvider.SKYLARK_CONSTRUCTOR);
- if (hasMoreThanOneWatchExtension(extensionProviders, Flag.HAS_WATCH1_EXTENSION)
- || hasMoreThanOneWatchExtension(extensionProviders, Flag.HAS_WATCH2_EXTENSION)) {
- ruleContext.attributeError("extensions", "An iOS application can contain exactly one "
- + "watch extension for each watch OS version");
- }
- }
-
- private boolean hasMoreThanOneWatchExtension(
- Iterable<ObjcProvider> objcProviders, final Flag watchExtensionVersionFlag) {
- return Streams.stream(objcProviders)
- .filter(objcProvider -> objcProvider.is(watchExtensionVersionFlag))
- .count()
- > 1;
- }
-
- @Override
- protected void configureTarget(RuleConfiguredTargetBuilder target, RuleContext ruleContext,
- ReleaseBundlingSupport releaseBundlingSupport) throws InterruptedException {
- // If this is an application built for the simulator, make it runnable.
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
- if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == ApplePlatform.IOS_SIMULATOR) {
- Artifact runnerScript = ObjcRuleClasses.intermediateArtifacts(ruleContext).runnerScript();
- Artifact ipaFile = ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA);
- releaseBundlingSupport.registerGenerateRunnerScriptAction(runnerScript, ipaFile);
- target.setRunfilesSupport(releaseBundlingSupport.runfilesSupport(runnerScript), runnerScript);
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java
deleted file mode 100644
index 7beb9bbde5..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import static com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition.HOST;
-import static com.google.devtools.build.lib.packages.Attribute.attr;
-import static com.google.devtools.build.lib.packages.BuildType.LABEL;
-import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
-import static com.google.devtools.build.lib.syntax.Type.BOOLEAN;
-
-import com.google.devtools.build.lib.analysis.BaseRuleClasses;
-import com.google.devtools.build.lib.analysis.RuleDefinition;
-import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
-import com.google.devtools.build.lib.packages.RuleClass;
-import com.google.devtools.build.lib.packages.RuleClass.Builder;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.IpaRule;
-
-/**
- * Rule definition for ios_application.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class IosApplicationRule implements RuleDefinition {
-
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- .requiresConfigurationFragments(ObjcConfiguration.class, AppleConfiguration.class)
- /*<!-- #BLAZE_RULE(ios_application).IMPLICIT_OUTPUTS -->
- <ul>
- <li><code><var>name</var>.ipa</code>: the application bundle as an <code>.ipa</code>
- file
- </ul>
- <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS -->*/
- .setImplicitOutputsFunction(ReleaseBundlingSupport.IPA)
- /* <!-- #BLAZE_RULE(ios_application).ATTRIBUTE(binary) -->
- The binary target included in the final bundle.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr("binary", LABEL)
- .allowedRuleClasses("objc_binary")
- .allowedFileTypes()
- .mandatory()
- .direct_compile_time_input()
- .cfg(IosApplication.SPLIT_ARCH_TRANSITION))
- /* <!-- #BLAZE_RULE(ios_application).ATTRIBUTE(extensions) -->
- Any extensions to include in the final application.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr("extensions", LABEL_LIST)
- .allowedRuleClasses(
- "ios_extension", "apple_watch1_extension")
- .allowedFileTypes()
- .direct_compile_time_input())
- .add(
- attr("$runner_script_template", LABEL)
- .cfg(HOST)
- .value(env.getToolsLabel("//tools/objc:ios_runner.sh.mac_template")))
- .add(
- attr("$is_executable", BOOLEAN)
- .value(true)
- .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target"))
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("ios_application")
- .factoryClass(IosApplication.class)
- .ancestors(
- BaseRuleClasses.BaseRule.class,
- ObjcRuleClasses.ReleaseBundlingRule.class,
- ObjcRuleClasses.SimulatorRule.class,
- IpaRule.class)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = ios_application, TYPE = BINARY, FAMILY = Objective-C) -->
-
-<p><strong>This rule is deprecated.</strong> Please use the new Apple build rules
-(<a href="https://github.com/bazelbuild/rules_apple">https://github.com/bazelbuild/rules_apple</a>)
-to build Apple targets.</p>
-
-<p>This rule produces an application bundle for iOS.</p>
-<p>When running an iOS application using the <code>run</code> command, environment variables that
-are prefixed with <code>IOS_</code> will be passed to the launched application, with the prefix
-stripped. For example, if you export <code>IOS_ENV=foo</code>, <code>ENV=foo</code> will be
-passed to the application.</p>
-
-${IMPLICIT_OUTPUTS}
-
-<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java
deleted file mode 100644
index f255e7ec29..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MERGE_ZIP;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Ordering;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.config.BuildOptions;
-import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
-import com.google.devtools.build.lib.packages.Attribute.SplitTransition;
-import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
-import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
-import com.google.devtools.build.lib.rules.apple.DottedVersion;
-import com.google.devtools.build.lib.rules.apple.XcodeConfig;
-import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.SplitArchTransition;
-import java.io.Serializable;
-import javax.annotation.Nullable;
-
-/**
- * Implementation for {@code ios_extension}.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class IosExtension extends ReleaseBundlingTargetFactory {
-
- // Apple only accepts extensions starting at 8.0.
- @VisibleForTesting
- static final DottedVersion EXTENSION_MINIMUM_OS_VERSION = DottedVersion.fromString("8.0");
-
- /**
- * Transition that when applied to a target generates a configured target for each value in
- * {@code --ios_multi_cpus}, such that {@code --ios_cpu} is set to a different one of those values
- * in the configured targets.
- *
- * <p>Also ensures that, no matter whether {@code --ios_multi_cpus} is set, {@code
- * --ios_minimum_os} is at least {@code 8.0} as Apple requires this for extensions.
- */
- static final SplitTransition<BuildOptions> MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION =
- new ExtensionSplitArchTransition(EXTENSION_MINIMUM_OS_VERSION,
- ConfigurationDistinguisher.IOS_EXTENSION);
-
- public IosExtension() {
- super(
- ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT,
- ImmutableSet.of(new Attribute("binary", Mode.SPLIT)));
- }
-
- @Override
- protected DottedVersion bundleMinimumOsVersion(RuleContext ruleContext) {
- return determineMinimumOsVersion(
- XcodeConfig.getMinimumOsForPlatformType(ruleContext, PlatformType.IOS),
- EXTENSION_MINIMUM_OS_VERSION);
- }
-
- @Override
- protected ObjcProvider exposedObjcProvider(
- RuleContext ruleContext, ReleaseBundlingSupport releaseBundlingSupport)
- throws InterruptedException {
- ObjcProvider.Builder builder =
- new ObjcProvider.Builder()
- // Nest this target's bundle under final IPA
- .add(MERGE_ZIP, ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA));
-
- releaseBundlingSupport.addExportedDebugArtifacts(builder, DsymOutputType.APP);
- return builder.build();
- }
-
- /**
- * Overrides (if necessary) any flag-set minimum iOS version for extensions only with given
- * minimum OS version.
- *
- * Extensions are not accepted by Apple below given mininumOSVersion. While applications built
- * with a minimum iOS version of less than give version may contain extensions in their bundle,
- * the extension itself needs to be built with given version or higher.
- *
- * @param fromFlag the minimum OS version from command line flag
- * @param minimumOSVersion the minumum OS version the extension should be built with
- */
- private static DottedVersion determineMinimumOsVersion(@Nullable DottedVersion fromFlag,
- DottedVersion minimumOSVersion) {
- if (fromFlag == null) {
- return minimumOSVersion;
- }
- return Ordering.natural().max(fromFlag, minimumOSVersion);
- }
-
- /**
- * Split transition that configures the minimum iOS version in addition to architecture splitting.
- */
- static class ExtensionSplitArchTransition extends SplitArchTransition
- implements Serializable {
-
- private final DottedVersion minimumOSVersion;
- private final ConfigurationDistinguisher configurationDistinguisher;
-
- ExtensionSplitArchTransition(DottedVersion minimumOSVersion,
- ConfigurationDistinguisher configurationDistinguisher) {
- this.minimumOSVersion = minimumOSVersion;
- this.configurationDistinguisher = configurationDistinguisher;
- }
-
- @Override
- protected ImmutableList<BuildOptions> defaultOptions(BuildOptions originalOptions) {
- AppleCommandLineOptions appleOptions = originalOptions.get(AppleCommandLineOptions.class);
- DottedVersion newMinimumVersion = determineMinimumOsVersion(appleOptions.iosMinimumOs,
- minimumOSVersion);
-
- if (newMinimumVersion.equals(appleOptions.iosMinimumOs)) {
- return ImmutableList.of();
- }
-
- BuildOptions splitOptions = originalOptions.clone();
- setMinimumOsVersion(splitOptions, newMinimumVersion);
- splitOptions.get(AppleCommandLineOptions.class).configurationDistinguisher =
- getConfigurationDistinguisher();
- return ImmutableList.of(splitOptions);
- }
-
- @Override
- protected void setAdditionalOptions(BuildOptions splitOptions, BuildOptions originalOptions) {
- DottedVersion fromFlag = originalOptions.get(AppleCommandLineOptions.class).iosMinimumOs;
- setMinimumOsVersion(splitOptions, determineMinimumOsVersion(fromFlag, minimumOSVersion));
- }
-
- @Override
- protected ConfigurationDistinguisher getConfigurationDistinguisher() {
- return configurationDistinguisher;
- }
-
- private void setMinimumOsVersion(BuildOptions splitOptions, DottedVersion newMinimumVersion) {
- splitOptions.get(AppleCommandLineOptions.class).iosMinimumOs = newMinimumVersion;
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinary.java
deleted file mode 100644
index d598f6c2c2..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinary.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs;
-
-/**
- * Implementation for the "ios_extension_binary" rule.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class IosExtensionBinary extends BinaryLinkingTargetFactory {
- public IosExtensionBinary() {
- super(HasReleaseBundlingSupport.NO);
- }
-
- @Override
- protected ExtraLinkArgs getExtraLinkArgs(RuleContext ruleContext) {
- return new ExtraLinkArgs("-e", "_NSExtensionMain", "-fapplication-extension");
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryRule.java
deleted file mode 100644
index 226b98ff2f..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryRule.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import com.google.devtools.build.lib.analysis.BaseRuleClasses;
-import com.google.devtools.build.lib.analysis.RuleDefinition;
-import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
-import com.google.devtools.build.lib.packages.RuleClass;
-import com.google.devtools.build.lib.packages.RuleClass.Builder;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
-
-/**
- * Rule definition for ios_extension_binary.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class IosExtensionBinaryRule implements RuleDefinition {
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- .requiresConfigurationFragments(ObjcConfiguration.class, J2ObjcConfiguration.class,
- AppleConfiguration.class, CppConfiguration.class)
- .cfg(AppleCrosstoolTransition.APPLE_CROSSTOOL_TRANSITION)
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("ios_extension_binary")
- .factoryClass(IosExtensionBinary.class)
- .ancestors(BaseRuleClasses.BaseRule.class, ObjcRuleClasses.LinkingRule.class)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = ios_extension_binary, TYPE = BINARY, FAMILY = Objective-C) -->
-
-<p><strong>This rule is deprecated.</strong> Please use the new Apple build rules
-(<a href="https://github.com/bazelbuild/rules_apple">https://github.com/bazelbuild/rules_apple</a>)
-to build Apple targets.</p>
-
-<p>This rule produces a binary for an iOS app extension by linking one or more
-Objective-C libraries.</p>
-
-${IMPLICIT_OUTPUTS}
-
-<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionRule.java
deleted file mode 100644
index 62b6374d7e..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtensionRule.java
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import static com.google.devtools.build.lib.packages.Attribute.attr;
-import static com.google.devtools.build.lib.packages.BuildType.LABEL;
-
-import com.google.devtools.build.lib.analysis.BaseRuleClasses;
-import com.google.devtools.build.lib.analysis.RuleDefinition;
-import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
-import com.google.devtools.build.lib.packages.RuleClass;
-import com.google.devtools.build.lib.packages.RuleClass.Builder;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.IpaRule;
-
-/**
- * Rule definition for ios_extension.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class IosExtensionRule implements RuleDefinition {
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- .requiresConfigurationFragments(ObjcConfiguration.class, AppleConfiguration.class)
- /*<!-- #BLAZE_RULE(ios_extension).IMPLICIT_OUTPUTS -->
- <ul>
- <li><code><var>name</var>.ipa</code>: the extension bundle as an <code>.ipa</code>
- file</li>
- </ul>
- <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS -->*/
- .setImplicitOutputsFunction(ReleaseBundlingSupport.IPA)
- /* <!-- #BLAZE_RULE(ios_extension).ATTRIBUTE(binary) -->
- The binary target containing the logic for the extension.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr("binary", LABEL)
- .allowedRuleClasses("ios_extension_binary")
- .allowedFileTypes()
- .mandatory()
- .direct_compile_time_input()
- .cfg(IosExtension.MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION))
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("ios_extension")
- .factoryClass(IosExtension.class)
- .ancestors(
- BaseRuleClasses.BaseRule.class,
- ObjcRuleClasses.ReleaseBundlingRule.class,
- IpaRule.class)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = ios_extension, TYPE = BINARY, FAMILY = Objective-C) -->
-
-<p><strong>This rule is deprecated.</strong> Please use the new Apple build rules
-(<a href="https://github.com/bazelbuild/rules_apple">https://github.com/bazelbuild/rules_apple</a>)
-to build Apple targets.</p>
-
-<p>This rule produces a bundled binary for an iOS app extension from a compiled binary and bundle
-metadata.</p>
-
-<p>An iOS app extension is a nested bundle that is located inside the application bundle and is
-released with it. An iOS app extension cannot be released alone, although this rule allows you to
-build an <code>.ipa</code> with only the extension.
-
-<p>Bundles generated by this rule use a bundle directory called
-<code>PlugIns/<var>target-name</var>.appex</code>, while an application bundle uses
-<code>Payload/<var>target-name</var>.app</code>. For instance, if an application call Foo has an app
-extension called Bar, the Bar extension bundle files will be stored in
-<code>Payload/Foo.app/PlugIns/Bar.appex</code> in the final application <code>.ipa</code>.
-
-<p>There are many similarities between app extensions and applications with little to no difference
-between how each thing is processed:
-<ul>
- <li>both have entitlements and Info.plist files
- <li>both are code-signed. Signing and merging happens in this order: the extension is code-signed,
- bundles are merged, application is code-signed
- <li>both can have an app icon and launch image, and of course asset catalogs and all kinds of
- resources
- <li>both have linked binaries. The app extension binary is different in that it is linked with
- these additional flags:
- <ul>
- <li><code>-e _NSExtensionMain</code> - sets the entry point to a standard function in the
- iOS runtime rather than <code>main()</code>
- <li><code>-fapplicationextension</code>
- </ul>
-</ul>
-
-${IMPLICIT_OUTPUTS}
-
-<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinary.java
deleted file mode 100644
index 03fdb97f3b..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinary.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-/**
- * Implementation for the "objc_binary" rule.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class ObjcBinary extends BinaryLinkingTargetFactory {
- public ObjcBinary() {
- super(
- // TODO(bazel-team): Remove the enum and delete all code depending on YES case once all
- // bundle users are migrated to ios_application.
- HasReleaseBundlingSupport.YES);
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java
deleted file mode 100644
index 55cde701d5..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import static com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition.HOST;
-import static com.google.devtools.build.lib.packages.Attribute.attr;
-import static com.google.devtools.build.lib.packages.BuildType.LABEL;
-import static com.google.devtools.build.lib.syntax.Type.BOOLEAN;
-
-import com.google.devtools.build.lib.analysis.BaseRuleClasses;
-import com.google.devtools.build.lib.analysis.RuleDefinition;
-import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
-import com.google.devtools.build.lib.packages.RuleClass;
-import com.google.devtools.build.lib.packages.RuleClass.Builder;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
-
-/**
- * Rule definition for objc_binary.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-// TODO(bazel-team): Remove bundling functionality (dependency on ApplicationRule, IPA output).
-@Deprecated
-public class ObjcBinaryRule implements RuleDefinition {
-
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- .requiresConfigurationFragments(
- ObjcConfiguration.class,
- J2ObjcConfiguration.class,
- AppleConfiguration.class,
- CppConfiguration.class)
- /*<!-- #BLAZE_RULE(objc_binary).IMPLICIT_OUTPUTS -->
- <ul>
- <li><code><var>name</var>.ipa</code>: the application bundle as an <code>.ipa</code>
- file</li>
- </ul>
- <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS -->*/
- .setImplicitOutputsFunction(ReleaseBundlingSupport.IPA)
- // TODO(bazel-team): Remove these when this rule no longer produces a bundle.
- .add(
- attr("$runner_script_template", LABEL)
- .cfg(HOST)
- .value(env.getToolsLabel("//tools/objc:ios_runner.sh.mac_template")))
- .add(
- attr("$is_executable", BOOLEAN)
- .value(true)
- .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target"))
- .cfg(AppleCrosstoolTransition.APPLE_CROSSTOOL_TRANSITION)
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("objc_binary")
- .factoryClass(ObjcBinary.class)
- .ancestors(
- BaseRuleClasses.BaseRule.class,
- ObjcRuleClasses.LinkingRule.class,
- ObjcRuleClasses.ReleaseBundlingRule.class,
- ObjcRuleClasses.SimulatorRule.class)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = objc_binary, TYPE = BINARY, FAMILY = Objective-C) -->
-
-<p><strong>This rule is deprecated.</strong> Please use the new Apple build rules
-(<a href="https://github.com/bazelbuild/rules_apple">https://github.com/bazelbuild/rules_apple</a>)
-to build Apple targets.</p>
-
-<p>This rule produces one or more Objective-C libraries for bundling in an
-<code>ios_application</code>.</p>
-
-<p>Any application-related attributes (infoplist, app_icon, resources, xibs, datamodels...) on this
-rule are deprecated and you should define them on <code>ios_application</code> instead. They will be
-removed from <code>objc_binary</code> soon.</p>
-
-<p>Until the migration to <code>ios_application</code> is complete, this rule requires at least one
-source file to be defined in either <code>srcs</code> or <code>non_arc_srcs</code></p>.
-
-${IMPLICIT_OUTPUTS}
-
-<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
index bd4e99087b..e292f000c6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
@@ -1394,351 +1394,4 @@ public class ObjcRuleClasses {
.build();
}
}
-
- /**
- * Attributes for {@code apple_watch*} rules that creates a watch extension bundle.
- */
- public static class WatchExtensionBundleRule implements RuleDefinition {
- static final String WATCH_EXT_BUNDLE_ID_ATTR = "ext_bundle_id";
- static final String WATCH_EXT_DEFAULT_PROVISIONING_PROFILE_ATTR =
- ":default_ext_provisioning_profile";
- static final String WATCH_EXT_ENTITLEMENTS_ATTR = "ext_entitlements";
- static final String WATCH_EXT_PROVISIONING_PROFILE_ATTR = "ext_provisioning_profile";
- static final String WATCH_EXT_INFOPLISTS_ATTR = "ext_infoplists";
- static final String WATCH_EXT_RESOURCES_ATTR = "ext_resources";
- static final String WATCH_EXT_STRUCTURED_RESOURCES_ATTR = "ext_structured_resources";
- static final String WATCH_EXT_STRINGS_ATTR = "ext_strings";
-
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_bundle_id) -->
- The bundle ID (reverse-DNS path followed by app name) of the watch extension binary.
-
- If specified, it will override the bundle ID specified in the associated plist file. If
- no bundle ID is specified on either this attribute or in the plist file, a junk value
- will be used.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_EXT_BUNDLE_ID_ATTR, STRING)
- .value(
- new Attribute.ComputedDefault() {
- @Override
- public Object getDefault(AttributeMap rule) {
- // For tests and similar, we don't want to force people to explicitly
- // specify throw-away data.
- return "example.ext." + rule.getName();
- }
- }))
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_entitlements) -->
- The entitlements file required for device builds of watch extension.
-
- See
- <a href="https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html">the apple documentation</a>
- for more information. If absent, the default entitlements from the
- provisioning profile will be used.
- <p>
- The following variables are substituted as per
- <a href="https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html">their definitions in Apple's documentation</a>:
- $(AppIdentifierPrefix) and $(CFBundleIdentifier).
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_EXT_ENTITLEMENTS_ATTR, LABEL).allowedFileTypes(ENTITLEMENTS_TYPE))
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_infoplists) -->
- Infoplist files to be merged. The merged output corresponds to <i>appname</i>-Info.plist
- in Xcode projects. Duplicate keys between infoplist files will cause an error if
- and only if the values conflict. If both <code>infoplist</code> and
- <code>infoplists</code> are specified, the files defined in both attributes will be used.
- Blaze will perform variable substitution on the plist files for the following values:
- <ul>
- <li><code>${EXECUTABLE_NAME}</code>: The name of the executable generated and included
- in the bundle by blaze, which can be used as the value for
- <code>CFBundleExecutable</code> within the plist.
- <li><code>${BUNDLE_NAME}</code>: This target's name and bundle suffix (.bundle or .app)
- in the form<code><var>name</var></code>.<code>suffix</code>.
- <li><code>${PRODUCT_NAME}</code>: This target's name.
- </ul>
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_EXT_INFOPLISTS_ATTR, BuildType.LABEL_LIST).allowedFileTypes(PLIST_TYPE))
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_provisioning_profile) -->
- The provisioning profile (.mobileprovision file) to use when bundling
- the watch extension.
-
- This is only used for non-simulator builds.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_EXT_PROVISIONING_PROFILE_ATTR, LABEL)
- .singleArtifact()
- .allowedFileTypes(FileType.of(".mobileprovision")))
- .add(
- attr(WATCH_EXT_DEFAULT_PROVISIONING_PROFILE_ATTR, LABEL)
- .singleArtifact()
- .allowedFileTypes(FileType.of(".mobileprovision"))
- .value(
- LateBoundDefault.fromTargetConfiguration(
- AppleConfiguration.class,
- null,
- (rule, attributes, appleConfig) -> {
- if (appleConfig.getMultiArchPlatform(PlatformType.IOS)
- != ApplePlatform.IOS_DEVICE) {
- return null;
- }
- if (attributes.isAttributeValueExplicitlySpecified(
- WATCH_EXT_PROVISIONING_PROFILE_ATTR)) {
- return null;
- }
- return appleConfig.getDefaultProvisioningProfileLabel();
- })))
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_resources) -->
- Files to include in the final watch extension bundle.
-
- They are not processed or compiled in any way besides the processing
- done by the rules that actually generate them. These files are placed
- in the root of the bundle (e.g. Foo.app/...) in most cases.
- However, if they appear to be localized (i.e. are contained in a
- directory called *.lproj), they will be placed in a directory of the
- same name in the app bundle.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_EXT_RESOURCES_ATTR, LABEL_LIST)
- .legacyAllowAnyFileType()
- .direct_compile_time_input())
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_structured_resources)-->
- Files to include in the final watch extension bundle.
-
- They are not processed or compiled in any way besides the processing
- done by the rules that actually generate them. In differences to
- <code>resources</code> these files are placed in the bundle root in
- the same structure passed to this argument, so
- <code>["res/foo.png"]</code> will end up in
- <code>Foo.app/res/foo.png</code>.
- <p>Note that in the generated XCode project file, all files in the top directory of
- the specified files will be included in the Xcode-generated app bundle. So
- specifying <code>["res/foo.png"]</code> will lead to the inclusion of all files in
- directory <code>res</code>.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_EXT_STRUCTURED_RESOURCES_ATTR, LABEL_LIST)
- .legacyAllowAnyFileType()
- .direct_compile_time_input())
- /* <!-- #BLAZE_RULE($watch_extension_bundle_rule).ATTRIBUTE(ext_strings) -->
- Files which are plists of strings, often localizable to be added to watch extension.
-
- These files are converted to binary plists (if they are not already)
- and placed in the bundle root of the final package. If this file's
- immediate containing directory is named *.lproj (e.g. en.lproj,
- Base.lproj), it will be placed under a directory of that name in the
- final bundle. This allows for localizable strings.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_EXT_STRINGS_ATTR, LABEL_LIST)
- .allowedFileTypes(STRINGS_TYPE)
- .direct_compile_time_input())
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("$watch_extension_bundle_rule")
- .type(RuleClassType.ABSTRACT)
- .ancestors(
- AppleToolchain.RequiresXcodeConfigRule.class,
- ResourceToolsRule.class,
- ReleaseBundlingToolsRule.class,
- XcrunRule.class)
- .build();
- }
- }
-
- /**
- * Attributes for {@code apple_watch*} rules that creates a watch application bundle.
- */
- public static class WatchApplicationBundleRule implements RuleDefinition {
- static final String WATCH_APP_NAME_ATTR = "app_name";
- static final String WATCH_APP_ICON_ATTR = "app_icon";
- static final String WATCH_APP_BUNDLE_ID_ATTR = "app_bundle_id";
- static final String WATCH_APP_DEFAULT_PROVISIONING_PROFILE_ATTR =
- ":default_app_provisioning_profile";
- static final String WATCH_APP_ENTITLEMENTS_ATTR = "app_entitlements";
- static final String WATCH_APP_PROVISIONING_PROFILE_ATTR = "app_provisioning_profile";
- static final String WATCH_APP_ASSET_CATALOGS_ATTR = "app_asset_catalogs";
- static final String WATCH_APP_INFOPLISTS_ATTR = "app_infoplists";
- static final String WATCH_APP_STORYBOARDS_ATTR = "app_storyboards";
- static final String WATCH_APP_RESOURCES_ATTR = "app_resources";
- static final String WATCH_APP_STRUCTURED_RESOURCES_ATTR = "app_structured_resources";
- static final String WATCH_APP_STRINGS_ATTR = "app_strings";
-
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_name) -->
- Name of the final watch application binary.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_APP_NAME_ATTR, STRING).mandatory())
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_icon) -->
- The name of the watch application icon.
-
- The icon should be in one of the asset catalogs of this target or
- a (transitive) dependency. In a new project, this is initialized
- to "AppIcon" by Xcode.
- <p>
- If the application icon is not in an asset catalog, do not use this
- attribute. Instead, add a CFBundleIcons entry to the Info.plist file.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_APP_ICON_ATTR, STRING))
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_entitlements) -->
- The entitlements file required for device builds of watch application.
-
- See
- <a href="https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html">the apple documentation</a>
- for more information. If absent, the default entitlements from the
- provisioning profile will be used.
- <p>
- The following variables are substituted as per
- <a href="https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html">their definitions in Apple's documentation</a>:
- $(AppIdentifierPrefix) and $(CFBundleIdentifier).
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_APP_ENTITLEMENTS_ATTR, LABEL).allowedFileTypes(ENTITLEMENTS_TYPE))
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_asset_catalogs) -->
- Files that comprise the asset catalogs of the final linked binary.
-
- Each file must have a containing directory named *.xcassets. This
- containing directory becomes the root of one of the asset catalogs
- linked with any binary that depends directly or indirectly on this
- target.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_ASSET_CATALOGS_ATTR, LABEL_LIST)
- .legacyAllowAnyFileType()
- .direct_compile_time_input())
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_bundle_id) -->
- The bundle ID (reverse-DNS path followed by app name) of the watch application binary.
-
- If specified, it will override the bundle ID specified in the associated plist file. If
- no bundle ID is specified on either this attribute or in the plist file, a junk value
- will be used.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_BUNDLE_ID_ATTR, STRING)
- .value(
- new Attribute.ComputedDefault(WATCH_APP_NAME_ATTR) {
- @Override
- public Object getDefault(AttributeMap rule) {
- // For tests and similar, we don't want to force people to explicitly
- // specify throw-away data.
- return "example.app." + rule.get(WATCH_APP_NAME_ATTR, STRING);
- }
- }))
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_infoplists) -->
- Infoplist files to be merged. The merged output corresponds to <i>appname</i>-Info.plist
- in Xcode projects. Duplicate keys between infoplist files will cause an error if
- and only if the values conflict. If both <code>infoplist</code> and
- <code>infoplists</code> are specified, the files defined in both attributes will be used.
- Blaze will perform variable substitution on the plist files for the following values:
- <ul>
- <li><code>${EXECUTABLE_NAME}</code>: The name of the executable generated and included
- in the bundle by blaze, which can be used as the value for
- <code>CFBundleExecutable</code> within the plist.
- <li><code>${BUNDLE_NAME}</code>: This target's name and bundle suffix (.bundle or .app)
- in the form<code><var>name</var></code>.<code>suffix</code>.
- <li><code>${PRODUCT_NAME}</code>: This target's name.
- </ul>
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_APP_INFOPLISTS_ATTR, BuildType.LABEL_LIST).allowedFileTypes(PLIST_TYPE))
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_provisioning_profile)-->
- The provisioning profile (.mobileprovision file) to use when bundling
- the watch application.
-
- This is only used for non-simulator builds.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_PROVISIONING_PROFILE_ATTR, LABEL)
- .singleArtifact()
- .allowedFileTypes(FileType.of(".mobileprovision")))
- .add(
- attr(WATCH_APP_DEFAULT_PROVISIONING_PROFILE_ATTR, LABEL)
- .singleArtifact()
- .allowedFileTypes(FileType.of(".mobileprovision"))
- .value(
- LateBoundDefault.fromTargetConfiguration(
- AppleConfiguration.class,
- null,
- (rule, attributes, appleConfig) -> {
- if (appleConfig.getMultiArchPlatform(PlatformType.IOS)
- != ApplePlatform.IOS_DEVICE) {
- return null;
- }
- if (attributes.isAttributeValueExplicitlySpecified(
- WATCH_APP_PROVISIONING_PROFILE_ATTR)) {
- return null;
- }
- return appleConfig.getDefaultProvisioningProfileLabel();
- })))
- /* <!-- #BLAZE_RULE($objc_resources_rule).ATTRIBUTE(app_storyboards) -->
- Files which are .storyboard resources for the watch application, possibly
- localizable.
-
- These files are compiled and placed in the bundle root of the final package.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(attr(WATCH_APP_STORYBOARDS_ATTR, LABEL_LIST).allowedFileTypes(STORYBOARD_TYPE))
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_resources) -->
- Files to include in the final watch application bundle.
-
- They are not processed or compiled in any way besides the processing
- done by the rules that actually generate them. These files are placed
- in the root of the bundle (e.g. Foo.app/...) in most cases.
- However, if they appear to be localized (i.e. are contained in a
- directory called *.lproj), they will be placed in a directory of the
- same name in the app bundle.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_RESOURCES_ATTR, LABEL_LIST)
- .legacyAllowAnyFileType()
- .direct_compile_time_input())
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_structured_resources)-->
- Files to include in the final watch application bundle.
-
- They are not processed or compiled in any way besides the processing
- done by the rules that actually generate them. In differences to
- <code>resources</code> these files are placed in the bundle root in
- the same structure passed to this argument, so
- <code>["res/foo.png"]</code> will end up in
- <code>Foo.app/res/foo.png</code>.
- <p>Note that in the generated XCode project file, all files in the top directory of
- the specified files will be included in the Xcode-generated app bundle. So
- specifying <code>["res/foo.png"]</code> will lead to the inclusion of all files in
- directory <code>res</code>.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_STRUCTURED_RESOURCES_ATTR, LABEL_LIST)
- .legacyAllowAnyFileType()
- .direct_compile_time_input())
- /* <!-- #BLAZE_RULE($watch_application_bundle_rule).ATTRIBUTE(app_strings) -->
- Files which are plists of strings, often localizable to be added to watch application.
-
- These files are converted to binary plists (if they are not already)
- and placed in the bundle root of the final package. If this file's
- immediate containing directory is named *.lproj (e.g. en.lproj,
- Base.lproj), it will be placed under a directory of that name in the
- final bundle. This allows for localizable strings.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_STRINGS_ATTR, LABEL_LIST)
- .allowedFileTypes(STRINGS_TYPE)
- .direct_compile_time_input())
- .build();
- }
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("$watch_application_bundle_rule")
- .type(RuleClassType.ABSTRACT)
- .ancestors(
- AppleToolchain.RequiresXcodeConfigRule.class,
- ResourceToolsRule.class,
- ReleaseBundlingToolsRule.class,
- XcrunRule.class)
- .build();
- }
- }
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java
deleted file mode 100644
index 1a5ca6d5e1..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.test.InstrumentedFilesCollector;
-import com.google.devtools.build.lib.analysis.test.InstrumentedFilesProvider;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
-import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
-import com.google.devtools.build.lib.rules.apple.DottedVersion;
-import com.google.devtools.build.lib.rules.apple.XcodeConfig;
-import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.LinkedBinary;
-import javax.annotation.Nullable;
-
-/**
- * Base class for rules that bundle releases.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public abstract class ReleaseBundlingTargetFactory implements RuleConfiguredTargetFactory {
-
- private final String bundleDirFormat;
- private final ImmutableSet<Attribute> dependencyAttributes;
-
- /**
- * @param bundleDirFormat format string representing the bundle's directory with a single
- * placeholder for the target name (e.g. {@code "Payload/%s.app"})
- * @param dependencyAttributes all attributes that contain dependencies of this rule. Any
- * dependency so listed must expose {@link ObjcProvider}.
- */
- public ReleaseBundlingTargetFactory(
- String bundleDirFormat, ImmutableSet<Attribute> dependencyAttributes) {
- this.bundleDirFormat = bundleDirFormat;
- this.dependencyAttributes = dependencyAttributes;
- }
-
- @Override
- public ConfiguredTarget create(RuleContext ruleContext)
- throws InterruptedException, RuleErrorException {
- ruleContext.ruleWarning(
- "This rule is deprecated. Please use the new Apple build rules "
- + "(https://github.com/bazelbuild/rules_apple) to build Apple targets.");
-
- validateAttributes(ruleContext);
- ObjcCommon common = common(ruleContext);
-
- NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
-
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
- ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(
- ruleContext, common.getObjcProvider(), LinkedBinary.DEPENDENCIES_ONLY, bundleDirFormat,
- bundleName(ruleContext), bundleMinimumOsVersion(ruleContext),
- appleConfiguration.getMultiArchPlatform(PlatformType.IOS));
- releaseBundlingSupport
- .registerActions(DsymOutputType.APP)
- .addFilesToBuild(filesToBuild, Optional.of(DsymOutputType.APP))
- .validateResources()
- .validateAttributes();
-
- RuleConfiguredTargetBuilder targetBuilder =
- ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build())
- .addNativeDeclaredProvider(releaseBundlingSupport.xcTestAppProvider())
- .addProvider(
- InstrumentedFilesProvider.class,
- InstrumentedFilesCollector.forward(ruleContext, "binary"));
-
- ObjcProvider exposedObjcProvider = exposedObjcProvider(ruleContext, releaseBundlingSupport);
- if (exposedObjcProvider != null) {
- targetBuilder
- .addNativeDeclaredProvider(exposedObjcProvider);
- }
-
- configureTarget(targetBuilder, ruleContext, releaseBundlingSupport);
- return targetBuilder.build();
- }
-
- /**
- * Validates application-related attributes set on this rule and registers any errors with the
- * rule context. Default implemenation does nothing; subclasses may override it.
- */
- protected void validateAttributes(RuleContext ruleContext) {}
-
- /**
- * Returns the minimum OS version this bundle's plist and resources should be generated for
- * (<b>not</b> the minimum OS version its binary is compiled with, that needs to be set in the
- * configuration).
- */
- protected DottedVersion bundleMinimumOsVersion(RuleContext ruleContext) {
- return XcodeConfig.getMinimumOsForPlatformType(ruleContext, PlatformType.IOS);
- }
-
- /**
- * Performs additional configuration of the target. The default implementation does nothing, but
- * subclasses may override it to add logic.
- * @throws InterruptedException
- */
- protected void configureTarget(RuleConfiguredTargetBuilder target, RuleContext ruleContext,
- ReleaseBundlingSupport releaseBundlingSupport) throws InterruptedException {}
-
- /**
- * Returns the name of this target's bundle.
- */
- protected String bundleName(RuleContext ruleContext) {
- return ruleContext.getLabel().getName();
- }
-
- /**
- * Returns an exposed {@code ObjcProvider} object.
- * @throws InterruptedException
- */
- @Nullable
- protected ObjcProvider exposedObjcProvider(
- RuleContext ruleContext, ReleaseBundlingSupport releaseBundlingSupport)
- throws InterruptedException {
- return null;
- }
-
- private ObjcCommon common(RuleContext ruleContext) {
- ObjcCommon.Builder builder = new ObjcCommon.Builder(ruleContext)
- .setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext));
- for (Attribute attribute : dependencyAttributes) {
- builder.addDepObjcProviders(
- ruleContext.getPrerequisites(
- attribute.getName(), attribute.getAccessMode(), ObjcProvider.SKYLARK_CONSTRUCTOR));
- }
- return builder.build();
- }
-}