aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2017-07-11 20:21:23 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-12 08:49:35 +0200
commitb8ed52129f6884ca7b7a40b4a6f515797a7f6fa6 (patch)
treeb076132eac910d81ea49d8d51a8ca2a39a68d151 /src/main/java/com/google/devtools/build
parent990622b2d6d2a72947ccf6ad18de7aabac49ebe8 (diff)
Remove apple_watch1_extension and apple_watch_extension_binary rules
RELNOTES: Remove apple_watch1_extension and apple_watch_extension_binary rules. Users should be using the skylark watchos_application and watchos_extension rules. https://github.com/bazelbuild/rules_apple has details. PiperOrigin-RevId: 161555395
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1Extension.java220
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1ExtensionRule.java119
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinary.java37
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinaryRule.java63
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/Watch2ExtensionSupport.java205
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java362
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/WatchExtensionSupport.java269
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java149
10 files changed, 0 insertions, 1430 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
index 1c01cfae09..429ef08eab 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
@@ -131,8 +131,6 @@ import com.google.devtools.build.lib.rules.objc.AppleBinaryRule;
import com.google.devtools.build.lib.rules.objc.AppleSkylarkCommon;
import com.google.devtools.build.lib.rules.objc.AppleStaticLibraryRule;
import com.google.devtools.build.lib.rules.objc.AppleStubBinaryRule;
-import com.google.devtools.build.lib.rules.objc.AppleWatch1ExtensionRule;
-import com.google.devtools.build.lib.rules.objc.AppleWatchExtensionBinaryRule;
import com.google.devtools.build.lib.rules.objc.IosApplicationRule;
import com.google.devtools.build.lib.rules.objc.IosDeviceRule;
import com.google.devtools.build.lib.rules.objc.IosExtensionBinaryRule;
@@ -589,8 +587,6 @@ public class BazelRuleClassProvider {
builder.addRuleDefinition(new AppleCcToolchainRule());
builder.addRuleDefinition(new AppleToolchain.RequiresXcodeConfigRule(toolsRepository));
- builder.addRuleDefinition(new AppleWatch1ExtensionRule());
- builder.addRuleDefinition(new AppleWatchExtensionBinaryRule());
builder.addRuleDefinition(new IosApplicationRule());
builder.addRuleDefinition(new IosDeviceRule());
builder.addRuleDefinition(new IosExtensionBinaryRule());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
index 76ec63ec1c..936a3bb6cf 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
@@ -710,8 +710,6 @@ public class AppleConfiguration extends BuildConfiguration.Fragment {
IOS_APPLICATION("ios_application"),
/** Split transition distinguisher for {@code ios_framework} rule. */
FRAMEWORK("framework"),
- /** Split transition distinguisher for {@code apple_watch1_extension} rule. */
- WATCH_OS1_EXTENSION("watch_os1_extension"),
/** Distinguisher for {@code apple_binary} rule with "ios" platform_type. */
APPLEBIN_IOS("applebin_ios"),
/** Distinguisher for {@code apple_binary} rule with "watchos" platform_type. */
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1Extension.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1Extension.java
deleted file mode 100644
index 3c134e0475..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1Extension.java
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright 2016 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.AppleWatch1ExtensionRule.WATCH_APP_DEPS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FLAG;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag.HAS_WATCH1_EXTENSION;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MERGE_ZIP;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_NAME_ATTR;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-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.RuleConfiguredTarget.Mode;
-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.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.packages.Attribute.SplitTransition;
-import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
-import com.google.devtools.build.lib.rules.objc.IosExtension.ExtensionSplitArchTransition;
-import com.google.devtools.build.lib.rules.objc.WatchUtils.WatchOSVersion;
-import com.google.devtools.build.lib.rules.test.InstrumentedFilesCollector;
-import com.google.devtools.build.lib.rules.test.InstrumentedFilesProvider;
-import com.google.devtools.build.lib.syntax.Type;
-
-/**
- * Implementation for {@code apple_watch1_extension}.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class AppleWatch1Extension implements RuleConfiguredTargetFactory {
-
- static final SplitTransition<BuildOptions> MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION =
- new ExtensionSplitArchTransition(WatchUtils.MINIMUM_OS_VERSION,
- ConfigurationDistinguisher.WATCH_OS1_EXTENSION);
- private static final ImmutableSet<Attribute> extensionDependencyAttributes =
- ImmutableSet.of(new Attribute("binary", Mode.SPLIT));
- private static final ImmutableSet<Attribute> applicationDependencyAttributes =
- ImmutableSet.of(new Attribute(WATCH_APP_DEPS_ATTR, Mode.SPLIT));
-
- @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.");
-
- ObjcProvider.Builder extensionObjcProviderBuilder = new ObjcProvider.Builder();
- NestedSetBuilder<Artifact> applicationFilesToBuild = NestedSetBuilder.stableOrder();
- NestedSetBuilder<Artifact> extensionfilesToBuild = NestedSetBuilder.stableOrder();
-
- // 1. Build watch application bundle.
- createWatchApplicationBundle(
- ruleContext,
- applicationFilesToBuild);
-
- // 2. Build watch extension bundle.
- createWatchExtensionBundle(ruleContext, extensionObjcProviderBuilder, extensionfilesToBuild);
-
- // 3. Extract the watch application bundle into the extension bundle.
- registerWatchApplicationUnBundlingAction(ruleContext);
-
- RuleConfiguredTargetBuilder targetBuilder =
- ObjcRuleClasses.ruleConfiguredTarget(ruleContext, extensionfilesToBuild.build())
- .addProvider(
- InstrumentedFilesProvider.class,
- InstrumentedFilesCollector.forward(ruleContext, "binary"));
-
- // 4. Exposed {@ObjcProvider} for bundling into final IPA.
- exposeObjcProvider(ruleContext, targetBuilder, extensionObjcProviderBuilder);
-
- return targetBuilder.build();
- }
-
- /**
- * Exposes an {@link ObjcProvider} with the following to create the final IPA:
- * 1. Watch extension bundle.
- * 2. WatchKitSupport.
- * 3. A flag to indicate that watch os 1 extension is included.
- */
- private void exposeObjcProvider(
- RuleContext ruleContext,
- RuleConfiguredTargetBuilder targetBuilder,
- ObjcProvider.Builder exposedObjcProviderBuilder)
- throws InterruptedException {
- exposedObjcProviderBuilder.add(MERGE_ZIP,
- ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA));
- WatchUtils.registerActionsToAddWatchSupport(ruleContext, exposedObjcProviderBuilder,
- WatchOSVersion.OS1);
- exposedObjcProviderBuilder.add(FLAG, HAS_WATCH1_EXTENSION);
-
- targetBuilder.addProvider(ObjcProvider.class, exposedObjcProviderBuilder.build());
- }
-
- /**
- * Creates a watch extension bundle.
- *
- * @param ruleContext rule context in which to create the bundle
- * which is added as a dependency to the extension
- * @param objcProviderBuilder {@link ObjcProvider.Builder} for the extension
- * @param filesToBuild the list to contain the files to be built for this extension bundle
- */
- private void createWatchExtensionBundle(RuleContext ruleContext,
- ObjcProvider.Builder objcProviderBuilder,
- NestedSetBuilder<Artifact> filesToBuild) throws InterruptedException {
- new WatchExtensionSupport(
- ruleContext,
- extensionDependencyAttributes,
- ObjcRuleClasses.intermediateArtifacts(ruleContext),
- watchExtensionBundleName(ruleContext),
- watchExtensionIpaArtifact(ruleContext),
- watchApplicationBundle(ruleContext))
- .createBundle(filesToBuild, objcProviderBuilder);
- }
-
- /**
- * Creates a watch application bundle.
- * @param ruleContext rule context in which to create the bundle
- * @param filesToBuild the list to contain the files to be built for this bundle
- */
- private void createWatchApplicationBundle(
- RuleContext ruleContext,
- NestedSetBuilder<Artifact> filesToBuild)
- throws InterruptedException {
- new WatchApplicationSupport(
- ruleContext,
- WatchOSVersion.OS1,
- applicationDependencyAttributes,
- new IntermediateArtifacts(ruleContext, "", watchApplicationBundleName(ruleContext)),
- watchApplicationBundleName(ruleContext),
- watchApplicationIpaArtifact(ruleContext),
- watchApplicationBundleName(ruleContext))
- .createBundle(ImmutableList.<Artifact>of(), filesToBuild);
- }
-
- /**
- * Registers action to extract the watch application ipa (after signing if required) to the
- * extension bundle.
- *
- * For example, TestWatchApp.ipa will be unbundled into,
- * PlugIns/TestWatchExtension.appex
- * PlugIns/TestWatchExtension.appex/TestWatchApp.app
- */
- private void registerWatchApplicationUnBundlingAction(RuleContext ruleContext) {
- Artifact watchApplicationIpa = watchApplicationIpaArtifact(ruleContext);
- Artifact watchApplicationBundle = watchApplicationBundle(ruleContext);
-
- String workingDirectory = watchApplicationBundle.getExecPathString().substring(0,
- watchApplicationBundle.getExecPathString().lastIndexOf('/'));
-
- ImmutableList<String> command = ImmutableList.of(
- "mkdir -p " + workingDirectory,
- "&&",
- String.format("/usr/bin/unzip -q -o %s -d %s",
- watchApplicationIpa.getExecPathString(),
- workingDirectory),
- "&&",
- String.format("cd %s/Payload", workingDirectory),
- "&&",
- String.format("/usr/bin/zip -q -r -0 ../%s *", watchApplicationBundle.getFilename()));
- ruleContext.registerAction(
- ObjcRuleClasses.spawnOnDarwinActionBuilder()
- .setProgressMessage("Extracting watch app: " + ruleContext.getLabel())
- .setShellCommand(ImmutableList.of("/bin/bash", "-c", Joiner.on(" ").join(command)))
- .addInput(watchApplicationIpa)
- .addOutput(watchApplicationBundle)
- .build(ruleContext));
- }
-
- /**
- * Returns a zip {@Artifact} containing extracted watch application - "TestWatchApp.app"
- * which is to be merged into the extension bundle.
- */
- private Artifact watchApplicationBundle(RuleContext ruleContext) {
- return ruleContext.getRelatedArtifact(ruleContext.getUniqueDirectory(
- "_watch"), String.format("/%s", watchApplicationIpaArtifact(ruleContext)
- .getFilename().replace(".ipa", ".zip")));
- }
-
- /**
- * Returns the {@Artifact} containing final watch application bundle.
- */
- private Artifact watchApplicationIpaArtifact(RuleContext ruleContext) {
- return ruleContext.getRelatedArtifact(ruleContext.getUniqueDirectory("_watch"),
- String.format("/%s.ipa", watchApplicationBundleName(ruleContext)));
- }
-
- /**
- * Returns the {@Artifact} containing final watch extension bundle.
- */
- private Artifact watchExtensionIpaArtifact(RuleContext ruleContext) throws InterruptedException {
- return ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA);
- }
-
- private String watchApplicationBundleName(RuleContext ruleContext) {
- return ruleContext.attributes().get(WATCH_APP_NAME_ATTR, Type.STRING);
- }
-
- private String watchExtensionBundleName(RuleContext ruleContext) {
- return ruleContext.getLabel().getName();
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1ExtensionRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1ExtensionRule.java
deleted file mode 100644
index a4cbcc328e..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatch1ExtensionRule.java
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2016 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 static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
-import static com.google.devtools.build.lib.syntax.Type.STRING_LIST;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-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;
-
-/**
- * Rule definition for apple_watch1_extension.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class AppleWatch1ExtensionRule implements RuleDefinition {
-
- private static final ImmutableSet<String> ALLOWED_DEPS_RULE_CLASSES =
- ImmutableSet.of("objc_library", "objc_import");
- static final String WATCH_APP_DEPS_ATTR = "app_deps";
- static final String WATCH_EXT_FAMILIES_ATTR = "ext_families";
-
- @Override
- public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
- return builder
- .requiresConfigurationFragments(ObjcConfiguration.class, AppleConfiguration.class)
- /*<!-- #BLAZE_RULE(apple_watch1_extension).IMPLICIT_OUTPUTS -->
- <ul>
- <li><code><var>name</var>.ipa</code>: the extension bundle as an <code>.ipa</code>
- file</li>
- <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS -->*/
- .setImplicitOutputsFunction(ReleaseBundlingSupport.IPA)
- /* <!-- #BLAZE_RULE(apple_watch1_extension).ATTRIBUTE(binary) -->
- The binary target containing the logic for the watch extension. This must be an
- <code>apple_watch1_extension_binary</code> target.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr("binary", LABEL)
- .allowedRuleClasses("apple_watch_extension_binary")
- .allowedFileTypes()
- .mandatory()
- .direct_compile_time_input()
- .cfg(AppleWatch1Extension.MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION))
- /* <!-- #BLAZE_RULE(apple_watch1_extension).ATTRIBUTE(app_deps) -->
- The list of targets whose resources files are bundled together to form final watch
- application bundle.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_APP_DEPS_ATTR, LABEL_LIST)
- .direct_compile_time_input()
- .allowedRuleClasses(ALLOWED_DEPS_RULE_CLASSES)
- .allowedFileTypes()
- .cfg(AppleWatch1Extension.MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION))
- /* <!-- #BLAZE_RULE(apple_watch1_extension).ATTRIBUTE(ext_families) -->
- The device families to which the watch extension is targeted.
-
- This is known as the <code>TARGETED_DEVICE_FAMILY</code> build setting
- in Xcode project files. It is a list of one or more of the strings
- <code>"iphone"</code> and <code>"ipad"</code>.
-
- <p>By default this is set to <code>"iphone"</code>. If it is explicitly specified it may not
- be empty.</p>
- <p>The watch application is always built for <code>"watch"</code> for device builds and
- <code>"iphone, watch"</code> for simulator builds.
- <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
- .add(
- attr(WATCH_EXT_FAMILIES_ATTR, STRING_LIST)
- .value(ImmutableList.of(TargetDeviceFamily.IPHONE.getNameInRule())))
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("apple_watch1_extension")
- .factoryClass(AppleWatch1Extension.class)
- .ancestors(BaseRuleClasses.BaseRule.class,
- ObjcRuleClasses.WatchApplicationBundleRule.class,
- ObjcRuleClasses.WatchExtensionBundleRule.class)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = apple_watch1_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 an extension bundle for apple watch OS 1 which also contains the watch
-application bundle</p>
-
-${IMPLICIT_OUTPUTS}
-
-${ATTRIBUTE_DEFINITION}
-
-<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinary.java
deleted file mode 100644
index 24fc54fc18..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinary.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2016 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 "apple_watch_extension_binary" rule.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class AppleWatchExtensionBinary extends BinaryLinkingTargetFactory {
-
- public AppleWatchExtensionBinary() {
- super(HasReleaseBundlingSupport.NO);
- }
-
- @Override
- protected ExtraLinkArgs getExtraLinkArgs(RuleContext ruleContext) {
- return new ExtraLinkArgs("-fapplication-extension", "-framework", "WatchKit");
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinaryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinaryRule.java
deleted file mode 100644
index d6a5d30e4b..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleWatchExtensionBinaryRule.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2016 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 apple_watch_extension_binary.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class AppleWatchExtensionBinaryRule 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("apple_watch_extension_binary")
- .factoryClass(AppleWatchExtensionBinary.class)
- .ancestors(BaseRuleClasses.BaseRule.class, ObjcRuleClasses.LinkingRule.class)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = apple_watch_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 watch 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/Watch2ExtensionSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/Watch2ExtensionSupport.java
deleted file mode 100644
index a73ecaeafb..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/Watch2ExtensionSupport.java
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright 2016 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.BUNDLE_FILE;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_DIR;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_FILE;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.STRINGS;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_BUNDLE_ID_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_DEFAULT_PROVISIONING_PROFILE_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_ENTITLEMENTS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_INFOPLISTS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_PROVISIONING_PROFILE_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_RESOURCES_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_STRINGS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_STRUCTURED_RESOURCES_ATTR;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
-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.objc.ReleaseBundlingSupport.LinkedBinary;
-import com.google.devtools.build.lib.syntax.Type;
-import javax.annotation.Nullable;
-
-/**
- * Contains support methods to build watch extension bundle - does normal bundle processing -
- * compiling and linking the binary, resources, plists and creates a final (signed if necessary)
- * bundle.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class Watch2ExtensionSupport {
-
- private final RuleContext ruleContext;
- private final IntermediateArtifacts intermediateArtifacts;
- private final String bundleName;
- private final Attributes attributes;
-
- /**
- * @param ruleContext the current rule context
- * @param intermediateArtifacts the utility object to obtain namespacing for intermediate bundling
- * artifacts
- * @param bundleName the name of the bundle
- */
- Watch2ExtensionSupport(
- RuleContext ruleContext, IntermediateArtifacts intermediateArtifacts, String bundleName) {
- this.ruleContext = ruleContext;
- this.intermediateArtifacts = intermediateArtifacts;
- this.bundleName = bundleName;
- this.attributes = new Attributes(ruleContext);
- }
-
- /**
- * Registers actions to create a watchOS2 extension bundle and zip it into an {@code .ipa}.
- *
- * @param ipaArtifact an .ipa artifact containing to extension bundle; this is the output artifact
- * of the bundling
- */
- void createBundle(Artifact ipaArtifact,
- NestedSetBuilder<Artifact> extensionFilesToBuild,
- ObjcProvider.Builder exposedObjcProviderBuilder) throws InterruptedException {
- ObjcProvider.Builder releaseBundlingObjcProviderBuilder = new ObjcProvider.Builder();
- releaseBundlingObjcProviderBuilder.addTransitiveAndPropagate(attributes.binaryDependencies());
- releaseBundlingObjcProviderBuilder
- .addAll(GENERAL_RESOURCE_FILE, attributes.resources())
- .addAll(GENERAL_RESOURCE_FILE, attributes.strings())
- .addAll(
- GENERAL_RESOURCE_DIR,
- ObjcCommon.xcodeStructuredResourceDirs(attributes.structuredResources()))
- .addAll(BUNDLE_FILE, BundleableFile.flattenedRawResourceFiles(attributes.resources()))
- .addAll(
- BUNDLE_FILE,
- BundleableFile.structuredRawResourceFiles(attributes.structuredResources()))
- .addAll(STRINGS, attributes.strings());
- ObjcProvider releaseBundlingObjcProvider = releaseBundlingObjcProviderBuilder.build();
-
- ReleaseBundling.Builder releaseBundling =
- new ReleaseBundling.Builder()
- .setIpaArtifact(ipaArtifact)
- .setBundleId(attributes.bundleId())
- .setProvisioningProfile(attributes.provisioningProfile())
- .setProvisioningProfileAttributeName(WATCH_EXT_PROVISIONING_PROFILE_ATTR)
- .setTargetDeviceFamilies(ImmutableSet.of(TargetDeviceFamily.WATCH))
- .setIntermediateArtifacts(intermediateArtifacts)
- .setInfoPlistsFromRule(attributes.infoPlists())
- .setEntitlements(attributes.entitlements());
-
- if (attributes.isBundleIdExplicitySpecified()) {
- releaseBundling.setPrimaryBundleId(attributes.bundleId());
- } else {
- releaseBundling.setFallbackBundleId(attributes.bundleId());
- }
-
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
-
- ReleaseBundlingSupport releaseBundlingSupport =
- new ReleaseBundlingSupport(
- ruleContext,
- releaseBundlingObjcProvider,
- LinkedBinary.DEPENDENCIES_ONLY,
- ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT,
- bundleName,
- appleConfiguration.getMinimumOsForPlatformType(PlatformType.WATCHOS),
- releaseBundling.build(),
- appleConfiguration.getMultiArchPlatform(PlatformType.WATCHOS));
-
- releaseBundlingSupport
- .registerActions(DsymOutputType.APP)
- .addFilesToBuild(extensionFilesToBuild, Optional.of(DsymOutputType.APP))
- .validateResources()
- .validateAttributes()
- .addExportedDebugArtifacts(exposedObjcProviderBuilder, DsymOutputType.APP);
- }
-
- /** Rule attributes used for creating watch application bundle. */
- private static class Attributes {
- private final RuleContext ruleContext;
-
- private Attributes(RuleContext ruleContext) {
- this.ruleContext = ruleContext;
- }
-
- @Nullable
- Artifact provisioningProfile() {
- Artifact explicitProvisioningProfile =
- getPrerequisiteArtifact(WATCH_EXT_PROVISIONING_PROFILE_ATTR);
- if (explicitProvisioningProfile != null) {
- return explicitProvisioningProfile;
- }
- return getPrerequisiteArtifact(WATCH_EXT_DEFAULT_PROVISIONING_PROFILE_ATTR);
- }
-
- String bundleId() {
- Preconditions.checkState(
- !Strings.isNullOrEmpty(
- ruleContext.attributes().get(WATCH_EXT_BUNDLE_ID_ATTR, Type.STRING)),
- "requires a bundle_id value");
- return ruleContext.attributes().get(WATCH_EXT_BUNDLE_ID_ATTR, Type.STRING);
- }
-
- ImmutableList<Artifact> infoPlists() {
- return getPrerequisiteArtifacts(WATCH_EXT_INFOPLISTS_ATTR);
- }
-
- ImmutableList<Artifact> strings() {
- return getPrerequisiteArtifacts(WATCH_EXT_STRINGS_ATTR);
- }
-
- ImmutableList<Artifact> resources() {
- return getPrerequisiteArtifacts(WATCH_EXT_RESOURCES_ATTR);
- }
-
- ImmutableList<Artifact> structuredResources() {
- return getPrerequisiteArtifacts(WATCH_EXT_STRUCTURED_RESOURCES_ATTR);
- }
-
- Iterable<ObjcProvider> binaryDependencies() {
- TransitiveInfoCollection info = ruleContext.getPrerequisite("binary", Mode.TARGET);
- AppleExecutableBinaryProvider binaryProvider =
- info.get(AppleExecutableBinaryProvider.SKYLARK_CONSTRUCTOR);
- return ImmutableList.of(binaryProvider.getDepsObjcProvider());
- }
-
- @Nullable
- Artifact entitlements() {
- return getPrerequisiteArtifact(WATCH_EXT_ENTITLEMENTS_ATTR);
- }
-
- private boolean isBundleIdExplicitySpecified() {
- return ruleContext.attributes().isAttributeValueExplicitlySpecified(WATCH_EXT_BUNDLE_ID_ATTR);
- }
-
- private ImmutableList<Artifact> getPrerequisiteArtifacts(String attribute) {
- return ruleContext.getPrerequisiteArtifacts(attribute, Mode.TARGET).list();
- }
-
- @Nullable
- private Artifact getPrerequisiteArtifact(String attribute) {
- return ruleContext.getPrerequisiteArtifact(attribute, Mode.TARGET);
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java
deleted file mode 100644
index 888dac5c22..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java
+++ /dev/null
@@ -1,362 +0,0 @@
-// Copyright 2016 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.ASSET_CATALOG;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_FILE;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_DIR;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_FILE;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MERGE_ZIP;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.STORYBOARD;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.STRINGS;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.XCASSETS_DIR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_ASSET_CATALOGS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_BUNDLE_ID_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_DEFAULT_PROVISIONING_PROFILE_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_ENTITLEMENTS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_ICON_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_INFOPLISTS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_PROVISIONING_PROFILE_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_RESOURCES_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_STORYBOARDS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_STRINGS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchApplicationBundleRule.WATCH_APP_STRUCTURED_RESOURCES_ATTR;
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
-import com.google.devtools.build.lib.analysis.RuleContext;
-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.DottedVersion;
-import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.LinkedBinary;
-import com.google.devtools.build.lib.rules.objc.WatchUtils.WatchOSVersion;
-import com.google.devtools.build.lib.syntax.Type;
-import javax.annotation.Nullable;
-
-/**
- * Contains support methods to build watch application bundle - does normal bundle processing -
- * resources, plists and creates a final (signed if necessary) bundle.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-final class WatchApplicationSupport {
-
- private final RuleContext ruleContext;
- private final WatchOSVersion watchOSVersion;
- private final ImmutableSet<Attribute> dependencyAttributes;
- private final String bundleName;
- private final IntermediateArtifacts intermediateArtifacts;
- private final Attributes attributes;
- private final Artifact ipaArtifact;
- private final String artifactPrefix;
-
- /**
- * @param ruleContext the current rule context
- * @param watchOSVersion the version of watchOS for which to create an application bundle
- * @param dependencyAttributes attributes on the current rule context to obtain transitive
- * resources from
- * @param intermediateArtifacts the utility object to obtain namespacing for intermediate bundling
- * artifacts
- * @param bundleName the name of the bundle
- * @param ipaArtifact the output ipa created by this application bundling
- * @param artifactPrefix the string prefix to prepend to bundling artifacts for the application --
- * this prevents intermediate artifacts under this same rule context (such as watch extension
- * bundling) from conflicting
- */
- WatchApplicationSupport(
- RuleContext ruleContext,
- WatchOSVersion watchOSVersion,
- ImmutableSet<Attribute> dependencyAttributes,
- IntermediateArtifacts intermediateArtifacts,
- String bundleName,
- Artifact ipaArtifact,
- String artifactPrefix) {
- this.ruleContext = ruleContext;
- this.watchOSVersion = watchOSVersion;
- this.dependencyAttributes = dependencyAttributes;
- this.intermediateArtifacts = intermediateArtifacts;
- this.bundleName = bundleName;
- this.ipaArtifact = ipaArtifact;
- this.artifactPrefix = artifactPrefix;
- this.attributes = new Attributes(ruleContext);
- }
-
- /**
- * Registers actions to create a watch application bundle.
- *
- * @param innerBundleZips any zip files to be unzipped and merged into the application bundle
- * @param filesToBuild files to build for the rule; the watchOS application .ipa is added to this
- * set
- */
- void createBundle(
- Iterable<Artifact> innerBundleZips,
- NestedSetBuilder<Artifact> filesToBuild)
- throws InterruptedException {
-
- ObjcProvider objcProvider = objcProvider(innerBundleZips);
-
- 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,
- objcProvider,
- LinkedBinary.DEPENDENCIES_ONLY,
- watchOSVersion.getApplicationBundleDirFormat(),
- bundleName,
- minimumOsVersion,
- releaseBundling.build(),
- appleConfiguration.getMultiArchPlatform(appPlatformType))
- .registerActions(DsymOutputType.APP);
-
- releaseBundlingSupport
- .addFilesToBuild(filesToBuild, Optional.<DsymOutputType>absent())
- .validateResources()
- .validateAttributes();
- }
-
- /**
- * Returns the {@link TargetDeviceFamily} that the watch application bundle is targeting. This
- * is always {@code TargetDeviceFamily.WATCH}, except for WatchOS1, which has the following
- * special rules:
- *
- * For simulator builds, this returns a set of {@code TargetDeviceFamily.IPHONE} and
- * {@code TargetDeviceFamily.WATCH} and for non-simulator builds, this returns
- * {@code TargetDeviceFamily.WATCH}.
- */
- private ImmutableSet<TargetDeviceFamily> families() {
- ApplePlatform platform =
- ruleContext.getFragment(AppleConfiguration.class).getMultiArchPlatform(PlatformType.IOS);
- if (watchOSVersion != WatchOSVersion.OS1 || platform == ApplePlatform.IOS_DEVICE) {
- return ImmutableSet.of(TargetDeviceFamily.WATCH);
- } else {
- return ImmutableSet.of(TargetDeviceFamily.IPHONE, TargetDeviceFamily.WATCH);
- }
- }
-
- /**
- * Registers actions to copy WatchKit stub binary at
- * $(SDK_ROOT)/Library/Application Support/WatchKit/WK as bundle binary and as stub resource.
- *
- * For example, for a bundle named "Foo.app", the contents will be,
- * - Foo.app/Foo (WK stub as binary)
- * - Foo.app/_WatchKitStub/WK (WK stub as resource)
- */
- private void registerActions() {
- Artifact watchKitStubZip = watchKitStubZip();
- String workingDirectory = watchKitStubZip.getExecPathString()
- .substring(0, watchKitStubZip.getExecPathString().lastIndexOf('/'));
- String watchKitStubBinaryPath = workingDirectory + "/" + bundleName;
- String watchKitStubResourcePath = workingDirectory + "/_WatchKitStub";
-
- ImmutableList<String> command = ImmutableList.of(
- // 1. Copy WK stub as binary
- String.format("cp -f %s %s", WatchUtils.WATCH_KIT_STUB_PATH, watchKitStubBinaryPath),
- "&&",
- // 2. Copy WK stub as bundle resource.
- "mkdir -p " + watchKitStubResourcePath,
- "&&",
- String.format("cp -f %s %s", WatchUtils.WATCH_KIT_STUB_PATH, watchKitStubResourcePath),
- // 3. Zip them.
- "&&",
- "cd " + workingDirectory,
- "&&",
- String.format(
- "/usr/bin/zip -q -r -0 %s %s",
- watchKitStubZip.getFilename(),
- Joiner.on(" ").join(ImmutableList.of("_WatchKitStub", bundleName))));
-
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
- ruleContext.registerAction(
- ObjcRuleClasses.spawnAppleEnvActionBuilder(
- appleConfiguration,
- appleConfiguration.getMultiArchPlatform(PlatformType.WATCHOS))
- .setProgressMessage(
- "Copying WatchKit binary and stub resource: " + ruleContext.getLabel())
- .setShellCommand(ImmutableList.of("/bin/bash", "-c", Joiner.on(" ").join(command)))
- .addOutput(watchKitStubZip)
- .build(ruleContext));
- }
-
- private ObjcProvider objcProvider(Iterable<Artifact> innerBundleZips) {
- ObjcProvider.Builder objcProviderBuilder = new ObjcProvider.Builder();
- if (watchOSVersion != WatchOSVersion.OS1) {
- objcProviderBuilder.addAll(MERGE_ZIP, innerBundleZips);
- }
-
- // Add all resource files applicable to watch application from dependency providers.
- for (Attribute attribute : dependencyAttributes) {
- Iterable<ObjcProvider> dependencyObjcProviders = ruleContext.getPrerequisites(
- attribute.getName(), attribute.getAccessMode(), ObjcProvider.class);
- for (ObjcProvider dependencyObjcProvider : dependencyObjcProviders) {
- objcProviderBuilder.addTransitiveAndPropagate(GENERAL_RESOURCE_FILE,
- dependencyObjcProvider);
- objcProviderBuilder.addTransitiveAndPropagate(GENERAL_RESOURCE_DIR,
- dependencyObjcProvider);
- objcProviderBuilder.addTransitiveAndPropagate(BUNDLE_FILE,
- dependencyObjcProvider);
- objcProviderBuilder.addTransitiveAndPropagate(XCASSETS_DIR,
- dependencyObjcProvider);
- objcProviderBuilder.addTransitiveAndPropagate(ASSET_CATALOG,
- dependencyObjcProvider);
- objcProviderBuilder.addTransitiveAndPropagate(STRINGS,
- dependencyObjcProvider);
- objcProviderBuilder.addTransitiveAndPropagate(STORYBOARD,
- dependencyObjcProvider);
- }
- }
- // Add zip containing WatchKit stubs.
- objcProviderBuilder.add(ObjcProvider.MERGE_ZIP, watchKitStubZip());
-
- // Add resource files.
- objcProviderBuilder.addAll(GENERAL_RESOURCE_FILE, attributes.storyboards())
- .addAll(GENERAL_RESOURCE_FILE, attributes.resources())
- .addAll(GENERAL_RESOURCE_FILE, attributes.strings())
- .addAll(GENERAL_RESOURCE_DIR,
- ObjcCommon.xcodeStructuredResourceDirs(attributes.structuredResources()))
- .addAll(BUNDLE_FILE, BundleableFile.flattenedRawResourceFiles(attributes.resources()))
- .addAll(
- BUNDLE_FILE,
- BundleableFile.structuredRawResourceFiles(attributes.structuredResources()))
- .addAll(XCASSETS_DIR, ObjcCommon.uniqueContainers(attributes.assetCatalogs(),
- ObjcCommon.ASSET_CATALOG_CONTAINER_TYPE))
- .addAll(ASSET_CATALOG, attributes.assetCatalogs())
- .addAll(STRINGS, attributes.strings())
- .addAll(STORYBOARD, attributes.storyboards());
-
- return objcProviderBuilder.build();
- }
-
- /**
- * Returns a zip {@link Artifact} containing stub binary and stub resource that are to be added
- * to the bundle.
- */
- private Artifact watchKitStubZip() {
- return ruleContext.getRelatedArtifact(
- ruleContext.getUniqueDirectory("_watch"), "/WatchKitStub.zip");
- }
-
- /**
- * Rule attributes used for creating watch application bundle.
- */
- private static class Attributes {
- private final RuleContext ruleContext;
-
- private Attributes(RuleContext ruleContext) {
- this.ruleContext = ruleContext;
- }
-
- @Nullable
- String appIcon() {
- return Strings.emptyToNull(ruleContext.attributes().get(WATCH_APP_ICON_ATTR, Type.STRING));
- }
-
- @Nullable
- Artifact provisioningProfile() {
- Artifact explicitProvisioningProfile =
- getPrerequisiteArtifact(WATCH_APP_PROVISIONING_PROFILE_ATTR);
- if (explicitProvisioningProfile != null) {
- return explicitProvisioningProfile;
- }
- return getPrerequisiteArtifact(WATCH_APP_DEFAULT_PROVISIONING_PROFILE_ATTR);
- }
-
- String bundleId() {
- Preconditions.checkState(!Strings.isNullOrEmpty(
- ruleContext.attributes().get(WATCH_APP_BUNDLE_ID_ATTR, Type.STRING)),
- "requires a bundle_id value");
- return ruleContext.attributes().get(WATCH_APP_BUNDLE_ID_ATTR, Type.STRING);
- }
-
- ImmutableList<Artifact> infoPlists() {
- return getPrerequisiteArtifacts(WATCH_APP_INFOPLISTS_ATTR);
- }
-
- ImmutableList<Artifact> assetCatalogs() {
- return getPrerequisiteArtifacts(WATCH_APP_ASSET_CATALOGS_ATTR);
- }
-
- ImmutableList<Artifact> strings() {
- return getPrerequisiteArtifacts(WATCH_APP_STRINGS_ATTR);
- }
-
- ImmutableList<Artifact> storyboards() {
- return getPrerequisiteArtifacts(WATCH_APP_STORYBOARDS_ATTR);
- }
-
- ImmutableList<Artifact> resources() {
- return getPrerequisiteArtifacts(WATCH_APP_RESOURCES_ATTR);
- }
-
- ImmutableList<Artifact> structuredResources() {
- return getPrerequisiteArtifacts(WATCH_APP_STRUCTURED_RESOURCES_ATTR);
- }
-
- @Nullable
- Artifact entitlements() {
- return getPrerequisiteArtifact(WATCH_APP_ENTITLEMENTS_ATTR);
- }
-
- private boolean isBundleIdExplicitySpecified() {
- return ruleContext.attributes().isAttributeValueExplicitlySpecified(WATCH_APP_BUNDLE_ID_ATTR);
- }
-
- private ImmutableList<Artifact> getPrerequisiteArtifacts(String attribute) {
- return ruleContext.getPrerequisiteArtifacts(attribute, Mode.TARGET).list();
- }
-
- @Nullable
- private Artifact getPrerequisiteArtifact(String attribute) {
- return ruleContext.getPrerequisiteArtifact(attribute, Mode.TARGET);
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchExtensionSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchExtensionSupport.java
deleted file mode 100644
index 675682c150..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchExtensionSupport.java
+++ /dev/null
@@ -1,269 +0,0 @@
-// Copyright 2016 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.common.base.Preconditions.checkNotNull;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_FILE;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_DIR;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_FILE;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MERGE_ZIP;
-import static com.google.devtools.build.lib.rules.objc.ObjcProvider.STRINGS;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.BundlingRule.FAMILIES_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_BUNDLE_ID_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_DEFAULT_PROVISIONING_PROFILE_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_ENTITLEMENTS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_INFOPLISTS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_PROVISIONING_PROFILE_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_RESOURCES_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_STRINGS_ATTR;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.WatchExtensionBundleRule.WATCH_EXT_STRUCTURED_RESOURCES_ATTR;
-
-import com.dd.plist.NSDictionary;
-import com.dd.plist.NSObject;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
-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.objc.ReleaseBundlingSupport.LinkedBinary;
-import com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.InvalidFamilyNameException;
-import com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.RepeatedFamilyNameException;
-import com.google.devtools.build.lib.syntax.Type;
-import java.util.List;
-import javax.annotation.Nullable;
-
-/**
- * Contains support methods to build WatchOS1 extension bundles - does normal bundle processing -
- * compiling and linking the binary, resources, plists and creates a final (signed if necessary)
- * bundle.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-@Deprecated
-public class WatchExtensionSupport {
-
- private final RuleContext ruleContext;
- private final ImmutableSet<Attribute> dependencyAttributes;
- private final IntermediateArtifacts intermediateArtifacts;
- private final String bundleName;
- private final Artifact ipaArtifact;
- private final Artifact watchApplicationBundle;
- private final Attributes attributes;
-
- WatchExtensionSupport(
- RuleContext ruleContext,
- ImmutableSet<Attribute> dependencyAttributes,
- IntermediateArtifacts intermediateArtifacts,
- String bundleName,
- Artifact ipaArtifact,
- @Nullable Artifact watchApplicationBundle) {
- this.ruleContext = ruleContext;
- this.dependencyAttributes = dependencyAttributes;
- this.intermediateArtifacts = intermediateArtifacts;
- this.bundleName = bundleName;
- this.ipaArtifact = ipaArtifact;
- this.attributes = new Attributes(ruleContext);
- this.watchApplicationBundle = checkNotNull(watchApplicationBundle);
- }
-
- void createBundle(
- NestedSetBuilder<Artifact> filesToBuild, ObjcProvider.Builder exposedObjcProviderBuilder)
- throws InterruptedException {
-
- ObjcProvider releaseBundlingObjcProvider = releaseBundlingObjcProvider();
-
- registerWatchExtensionAutomaticPlistAction();
-
- ImmutableSet<TargetDeviceFamily> families = attributes.families();
-
- if (families.isEmpty()) {
- ruleContext.attributeError(FAMILIES_ATTR, ReleaseBundling.INVALID_FAMILIES_ERROR);
- }
-
- ReleaseBundling.Builder releaseBundling = new ReleaseBundling.Builder()
- .setIpaArtifact(ipaArtifact)
- .setBundleId(attributes.bundleId())
- .setProvisioningProfile(attributes.provisioningProfile())
- .setProvisioningProfileAttributeName(WATCH_EXT_PROVISIONING_PROFILE_ATTR)
- .setTargetDeviceFamilies(families)
- .setIntermediateArtifacts(intermediateArtifacts)
- .setInfoPlistsFromRule(attributes.infoPlists())
- .addInfoplistInput(watchExtensionAutomaticPlist())
- .setEntitlements(attributes.entitlements());
-
- if (attributes.isBundleIdExplicitySpecified()) {
- releaseBundling.setPrimaryBundleId(attributes.bundleId());
- } else {
- releaseBundling.setFallbackBundleId(attributes.bundleId());
- }
-
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
-
- ReleaseBundlingSupport releaseBundlingSupport =
- new ReleaseBundlingSupport(
- ruleContext,
- releaseBundlingObjcProvider,
- LinkedBinary.DEPENDENCIES_ONLY,
- ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT,
- bundleName,
- WatchUtils.determineMinimumIosVersion(
- appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)),
- releaseBundling.build(),
- appleConfiguration.getMultiArchPlatform(PlatformType.IOS));
-
- releaseBundlingSupport.registerActions(DsymOutputType.APP);
-
- releaseBundlingSupport
- .addFilesToBuild(filesToBuild, Optional.of(DsymOutputType.APP))
- .validateResources()
- .validateAttributes()
- .addExportedDebugArtifacts(exposedObjcProviderBuilder, DsymOutputType.APP);
- }
-
- /**
- * Registers an action to generate a plist containing entries required for watch extension that
- * should be added to the merged plist.
- */
- private void registerWatchExtensionAutomaticPlistAction() {
- List<String> uiRequiredDeviceCapabilities = ImmutableList.of("watch-companion");
- NSDictionary watchExtensionAutomaticEntries = new NSDictionary();
- watchExtensionAutomaticEntries.put("UIRequiredDeviceCapabilities",
- NSObject.wrap(uiRequiredDeviceCapabilities.toArray()));
-
- ruleContext.registerAction(
- FileWriteAction.create(
- ruleContext,
- watchExtensionAutomaticPlist(),
- watchExtensionAutomaticEntries.toGnuStepASCIIPropertyList(),
- /*makeExecutable=*/ false));
- }
-
- private Artifact watchExtensionAutomaticPlist() {
- return ruleContext.getRelatedArtifact(
- ruleContext.getUniqueDirectory("plists"), "-automatic-watchExtensionInfo.plist");
- }
-
- private ObjcProvider releaseBundlingObjcProvider() {
- ObjcProvider.Builder objcProviderBuilder = new ObjcProvider.Builder();
- // Add dependency providers.
- for (Attribute attribute : dependencyAttributes) {
- objcProviderBuilder.addTransitiveAndPropagate(
- ruleContext.getPrerequisites(
- attribute.getName(), attribute.getAccessMode(), ObjcProvider.class));
- }
-
- // Expose the generated watch application bundle to the extension bundle.
- objcProviderBuilder.add(MERGE_ZIP, watchApplicationBundle);
-
- // Add resource files.
- objcProviderBuilder.addAll(GENERAL_RESOURCE_FILE, attributes.resources())
- .addAll(GENERAL_RESOURCE_FILE, attributes.strings())
- .addAll(GENERAL_RESOURCE_DIR, ObjcCommon.xcodeStructuredResourceDirs(
- attributes.structuredResources()))
- .addAll(BUNDLE_FILE, BundleableFile.flattenedRawResourceFiles(attributes.resources()))
- .addAll(
- BUNDLE_FILE,
- BundleableFile.structuredRawResourceFiles(attributes.structuredResources()))
- .addAll(STRINGS, attributes.strings());
-
- return objcProviderBuilder.build();
- }
-
- /**
- * Rule attributes used for creating watch application bundle.
- */
- private static class Attributes {
- private final RuleContext ruleContext;
-
- private Attributes(RuleContext ruleContext) {
- this.ruleContext = ruleContext;
- }
-
- /**
- * Returns the value of the {@code families} attribute in a form
- * that is more useful than a list of strings. Returns an empty
- * set for any invalid {@code families} attribute value, including
- * an empty list.
- */
- ImmutableSet<TargetDeviceFamily> families() {
- List<String> rawFamilies = ruleContext.attributes().get(
- AppleWatch1ExtensionRule.WATCH_EXT_FAMILIES_ATTR, Type.STRING_LIST);
- try {
- return ImmutableSet.copyOf(TargetDeviceFamily.fromNamesInRule(rawFamilies));
- } catch (InvalidFamilyNameException | RepeatedFamilyNameException e) {
- return ImmutableSet.of();
- }
- }
-
- @Nullable
- Artifact provisioningProfile() {
- Artifact explicitProvisioningProfile =
- getPrerequisiteArtifact(WATCH_EXT_PROVISIONING_PROFILE_ATTR);
- if (explicitProvisioningProfile != null) {
- return explicitProvisioningProfile;
- }
- return getPrerequisiteArtifact(WATCH_EXT_DEFAULT_PROVISIONING_PROFILE_ATTR);
- }
-
- String bundleId() {
- Preconditions.checkState(!Strings.isNullOrEmpty(
- ruleContext.attributes().get(WATCH_EXT_BUNDLE_ID_ATTR, Type.STRING)),
- "requires a bundle_id value");
- return ruleContext.attributes().get(WATCH_EXT_BUNDLE_ID_ATTR, Type.STRING);
- }
-
- ImmutableList<Artifact> infoPlists() {
- return getPrerequisiteArtifacts(WATCH_EXT_INFOPLISTS_ATTR);
- }
-
- ImmutableList<Artifact> strings() {
- return getPrerequisiteArtifacts(WATCH_EXT_STRINGS_ATTR);
- }
-
- ImmutableList<Artifact> resources() {
- return getPrerequisiteArtifacts(WATCH_EXT_RESOURCES_ATTR);
- }
-
- ImmutableList<Artifact> structuredResources() {
- return getPrerequisiteArtifacts(WATCH_EXT_STRUCTURED_RESOURCES_ATTR);
- }
-
- @Nullable
- Artifact entitlements() {
- return getPrerequisiteArtifact(WATCH_EXT_ENTITLEMENTS_ATTR);
- }
-
- private boolean isBundleIdExplicitySpecified() {
- return ruleContext.attributes().isAttributeValueExplicitlySpecified(WATCH_EXT_BUNDLE_ID_ATTR);
- }
-
- private ImmutableList<Artifact> getPrerequisiteArtifacts(String attribute) {
- return ruleContext.getPrerequisiteArtifacts(attribute, Mode.TARGET).list();
- }
-
- @Nullable
- private Artifact getPrerequisiteArtifact(String attribute) {
- return ruleContext.getPrerequisiteArtifact(attribute, Mode.TARGET);
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java
deleted file mode 100644
index 28d888c021..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2016 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.ROOT_MERGE_ZIP;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Ordering;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleContext;
-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;
-
-/**
- * Contains support methods for common processing and generating of watch extension and application
- * bundles.
- *
- * @deprecated The native bundling rules have been deprecated. This class will be removed in the
- * future.
- */
-// TODO(b/30503590): Refactor this into a support class -- such classes are better than this static
-// utility.
-@Deprecated
-final class WatchUtils {
-
- @VisibleForTesting
- /** Bundle directory format for watch applications for watch OS 2. */
- static final String WATCH2_APP_BUNDLE_DIR_FORMAT = "Watch/%s.app";
-
- /**
- * Supported Apple watch OS versions.
- */
- enum WatchOSVersion {
- OS1(
- ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT,
- "WatchKitSupport"),
- OS2(
- WATCH2_APP_BUNDLE_DIR_FORMAT,
- "WatchKitSupport2");
-
- private final String applicationBundleDirFormat;
- private final String watchKitSupportDirName;
-
- WatchOSVersion(
- String applicationBundleDirFormat,
- String watchKitSupportDirName) {
- this.applicationBundleDirFormat = applicationBundleDirFormat;
- this.watchKitSupportDirName = watchKitSupportDirName;
- }
-
- /** Returns the bundle directory format of the watch application relative to its container. */
- String getApplicationBundleDirFormat() {
- return applicationBundleDirFormat;
- }
-
- /**
- * Returns the name of the directory in the final iOS bundle which should contain the WatchKit
- * support stub.
- */
- String getWatchKitSupportDirName() {
- return watchKitSupportDirName;
- }
- }
-
- @VisibleForTesting
- static final String WATCH_KIT_STUB_PATH =
- "${SDKROOT}/Library/Application\\ Support/WatchKit/WK";
-
- // Apple only accepts watch extension and application starting at 8.2.
- @VisibleForTesting
- static final DottedVersion MINIMUM_OS_VERSION = DottedVersion.fromString("8.2");
-
- /**
- * Watch Extension are not accepted by Apple below iOS version 8.2. While applications built with
- * a minimum iOS version of less than 8.2 may contain watch extension in their bundle, the
- * extension itself needs to be built with 8.2 or higher. This logic overrides (if necessary)
- * any flag-set minimum iOS version for extensions only so that this requirement is not
- * violated.
- */
- static DottedVersion determineMinimumIosVersion(DottedVersion fromFlag) {
- return Ordering.natural().max(fromFlag, MINIMUM_OS_VERSION);
- }
-
- /**
- * Adds WatchKitSupport stub to the final ipa and exposes it to given @{link ObjcProvider.Builder}
- * based on watch OS version.
- *
- * For example, for watch OS 1, the resulting ipa will have:
- * Payload/TestApp.app
- * WatchKitSupport
- * WatchKitSupport/WK
- */
- static void registerActionsToAddWatchSupport(
- RuleContext ruleContext, ObjcProvider.Builder objcProviderBuilder,
- WatchOSVersion watchOSVersion) {
- Artifact watchSupportZip = watchSupportZip(ruleContext);
- String workingDirectory = watchSupportZip.getExecPathString()
- .substring(0, watchSupportZip.getExecPathString().lastIndexOf('/'));
- String watchKitSupportDirName = watchOSVersion.getWatchKitSupportDirName();
- String watchKitSupportPath = workingDirectory + "/" + watchKitSupportDirName;
-
- ImmutableList<String> command = ImmutableList.of(
- // 1. Copy WK stub binary to watchKitSupportPath.
- "mkdir -p " + watchKitSupportPath,
- "&&",
- String.format("cp -f %s %s", WATCH_KIT_STUB_PATH, watchKitSupportPath),
- // 2. cd to working directory.
- "&&",
- "cd " + workingDirectory,
- // 3. Zip watchSupport.
- "&&",
- String.format(
- "/usr/bin/zip -q -r -0 %s %s",
- watchSupportZip.getFilename(),
- watchKitSupportDirName));
-
- AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
- ruleContext.registerAction(
- ObjcRuleClasses.spawnAppleEnvActionBuilder(
- appleConfiguration,
- appleConfiguration.getMultiArchPlatform(PlatformType.WATCHOS))
- .setProgressMessage("Copying Watchkit support to app bundle")
- .setShellCommand(ImmutableList.of("/bin/bash", "-c", Joiner.on(" ").join(command)))
- .addOutput(watchSupportZip)
- .build(ruleContext));
-
- objcProviderBuilder.add(ROOT_MERGE_ZIP, watchSupportZip(ruleContext));
- }
-
- private static Artifact watchSupportZip(RuleContext ruleContext) {
- return ruleContext.getRelatedArtifact(
- ruleContext.getUniqueDirectory("_watch"), "/WatchKitSupport.zip");
- }
-}