Skip to content

Commit

Permalink
Remove Xcodege integration from Blaze.
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 157857216
  • Loading branch information
aragos authored and katre committed Jun 5, 2017
1 parent d3581d2 commit 85b0ad2
Show file tree
Hide file tree
Showing 47 changed files with 128 additions and 2,079 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
import com.google.devtools.build.lib.rules.test.SkylarkTestingModule;
import com.google.devtools.build.lib.rules.test.TestSuiteRule;
import com.google.devtools.build.lib.util.ResourceFileLoader;

import java.io.IOException;

/** A rule class provider implementing the rules Bazel knows. */
Expand Down Expand Up @@ -585,7 +586,6 @@ public void init(Builder builder) {
builder.addRuleDefinition(new ObjcRuleClasses.LinkingRule(objcProtoAspect));
builder.addRuleDefinition(new ObjcRuleClasses.MultiArchPlatformRule());
builder.addRuleDefinition(new ObjcRuleClasses.ResourcesRule());
builder.addRuleDefinition(new ObjcRuleClasses.XcodegenRule());
builder.addRuleDefinition(new ObjcRuleClasses.AlwaysLinkRule());
builder.addRuleDefinition(new ObjcRuleClasses.SdkFrameworksDependerRule());
builder.addRuleDefinition(new ObjcRuleClasses.CompileDependencyRule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,22 @@ public ConfiguredTarget create(RuleContext ruleContext)
+ "(https://github.com/bazelbuild/rules_apple) to build Apple targets.");

ObjcProvider.Builder extensionObjcProviderBuilder = new ObjcProvider.Builder();
XcodeProvider.Builder applicationXcodeProviderBuilder = new XcodeProvider.Builder();
XcodeProvider.Builder extensionXcodeProviderBuilder = new XcodeProvider.Builder();
NestedSetBuilder<Artifact> applicationFilesToBuild = NestedSetBuilder.stableOrder();
NestedSetBuilder<Artifact> extensionfilesToBuild = NestedSetBuilder.stableOrder();

// 1. Build watch application bundle.
createWatchApplicationBundle(
ruleContext,
applicationXcodeProviderBuilder,
applicationFilesToBuild);

// 2. Build watch extension bundle.
createWatchExtensionBundle(ruleContext, extensionXcodeProviderBuilder,
applicationXcodeProviderBuilder, extensionObjcProviderBuilder, extensionfilesToBuild);
createWatchExtensionBundle(ruleContext, extensionObjcProviderBuilder, extensionfilesToBuild);

// 3. Extract the watch application bundle into the extension bundle.
registerWatchApplicationUnBundlingAction(ruleContext);

RuleConfiguredTargetBuilder targetBuilder =
ObjcRuleClasses.ruleConfiguredTarget(ruleContext, extensionfilesToBuild.build())
.addProvider(XcodeProvider.class, extensionXcodeProviderBuilder.build())
.addProvider(
InstrumentedFilesProvider.class,
InstrumentedFilesCollector.forward(ruleContext, "binary"));
Expand Down Expand Up @@ -119,37 +114,30 @@ private void exposeObjcProvider(
* Creates a watch extension bundle.
*
* @param ruleContext rule context in which to create the bundle
* @param extensionXcodeProviderBuilder {@link XcodeProvider.Builder} for the extension
* @param applicationXcodeProviderBuilder {@link XcodeProvider.Builder} for the watch application
* 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,
XcodeProvider.Builder extensionXcodeProviderBuilder,
XcodeProvider.Builder applicationXcodeProviderBuilder,
ObjcProvider.Builder objcProviderBuilder,
NestedSetBuilder<Artifact> filesToBuild) throws InterruptedException {
new WatchExtensionSupport(ruleContext,
extensionDependencyAttributes,
ObjcRuleClasses.intermediateArtifacts(ruleContext),
watchExtensionBundleName(ruleContext),
watchExtensionIpaArtifact(ruleContext),
watchApplicationBundle(ruleContext),
applicationXcodeProviderBuilder.build(),
ConfigurationDistinguisher.WATCH_OS1_EXTENSION)
.createBundle(filesToBuild, objcProviderBuilder, extensionXcodeProviderBuilder);
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 xcodeProviderBuilder {@link XcodeProvider.Builder} for the application
* @param filesToBuild the list to contain the files to be built for this bundle
*/
private void createWatchApplicationBundle(
RuleContext ruleContext,
XcodeProvider.Builder xcodeProviderBuilder,
NestedSetBuilder<Artifact> filesToBuild)
throws InterruptedException {
new WatchApplicationSupport(
Expand All @@ -160,10 +148,7 @@ private void createWatchApplicationBundle(
watchApplicationBundleName(ruleContext),
watchApplicationIpaArtifact(ruleContext),
watchApplicationBundleName(ruleContext))
.createBundleAndXcodeproj(
xcodeProviderBuilder,
ImmutableList.<Artifact>of(),
filesToBuild);
.createBundle(ImmutableList.<Artifact>of(), filesToBuild);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public Metadata getMetadata() {
.name("apple_watch1_extension")
.factoryClass(AppleWatch1Extension.class)
.ancestors(BaseRuleClasses.BaseRule.class,
ObjcRuleClasses.XcodegenRule.class,
ObjcRuleClasses.WatchApplicationBundleRule.class,
ObjcRuleClasses.WatchExtensionBundleRule.class)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public Metadata getMetadata() {
.factoryClass(AppleWatch2Extension.class)
.ancestors(
BaseRuleClasses.BaseRule.class,
ObjcRuleClasses.XcodegenRule.class,
ObjcRuleClasses.WatchApplicationBundleRule.class,
ObjcRuleClasses.WatchExtensionBundleRule.class)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class AppleWatchExtensionBinary extends BinaryLinkingTargetFactory {

public AppleWatchExtensionBinary() {
super(HasReleaseBundlingSupport.NO, XcodeProductType.LIBRARY_STATIC);
super(HasReleaseBundlingSupport.NO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public Metadata getMetadata() {
return RuleDefinition.Metadata.builder()
.name("apple_watch_extension_binary")
.factoryClass(AppleWatchExtensionBinary.class)
.ancestors(BaseRuleClasses.BaseRule.class, ObjcRuleClasses.LinkingRule.class,
ObjcRuleClasses.XcodegenRule.class)
.ancestors(BaseRuleClasses.BaseRule.class, ObjcRuleClasses.LinkingRule.class)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,9 @@ enum HasReleaseBundlingSupport {
}

private final HasReleaseBundlingSupport hasReleaseBundlingSupport;
private final XcodeProductType productType;

protected BinaryLinkingTargetFactory(
HasReleaseBundlingSupport hasReleaseBundlingSupport, XcodeProductType productType) {
protected BinaryLinkingTargetFactory(HasReleaseBundlingSupport hasReleaseBundlingSupport) {
this.hasReleaseBundlingSupport = hasReleaseBundlingSupport;
this.productType = productType;
}

/**
Expand Down Expand Up @@ -100,24 +97,20 @@ public final ConfiguredTarget create(RuleContext ruleContext)
.registerCompilationActions();

Optional<ObjcProvider> protosObjcProvider = protoSupport.getObjcProvider();
Optional<XcodeProvider> protosXcodeProvider = protoSupport.getXcodeProvider();

ObjcCommon common = common(ruleContext, protosObjcProvider);

ObjcProvider objcProvider = common.getObjcProvider();
assertLibraryOrSources(objcProvider, ruleContext);

XcodeProvider.Builder xcodeProviderBuilder =
new XcodeProvider.Builder().addPropagatedDependencies(protosXcodeProvider.asSet());

IntermediateArtifacts intermediateArtifacts =
ObjcRuleClasses.intermediateArtifacts(ruleContext);

NestedSetBuilder<Artifact> filesToBuild =
NestedSetBuilder.<Artifact>stableOrder()
.add(intermediateArtifacts.strippedSingleArchitectureBinary());

new ResourceSupport(ruleContext).validateAttributes().addXcodeSettings(xcodeProviderBuilder);
new ResourceSupport(ruleContext).validateAttributes();

ruleContext.assertNoErrors();

Expand All @@ -139,7 +132,6 @@ public final ConfiguredTarget create(RuleContext ruleContext)

compilationSupport
.validateAttributes()
.addXcodeSettings(xcodeProviderBuilder, common)
.registerCompileAndArchiveActions(common)
.registerFullyLinkAction(
common.getObjcProvider(),
Expand Down Expand Up @@ -168,7 +160,6 @@ public final ConfiguredTarget create(RuleContext ruleContext)
appleConfiguration.getSingleArchPlatform());
releaseBundlingSupport
.registerActions(DsymOutputType.APP)
.addXcodeSettings(xcodeProviderBuilder)
.addFilesToBuild(filesToBuild, Optional.of(DsymOutputType.APP))
.validateResources()
.validateAttributes();
Expand All @@ -188,26 +179,8 @@ public final ConfiguredTarget create(RuleContext ruleContext)
throw new AssertionError();
}

XcodeSupport xcodeSupport =
new XcodeSupport(ruleContext)
// TODO(bazel-team): Use LIBRARY_STATIC as parameter instead of APPLICATION once
// objc_binary no longer creates an application bundle.
.addXcodeSettings(xcodeProviderBuilder, objcProvider, productType)
.addDependencies(xcodeProviderBuilder, new Attribute("bundles", Mode.TARGET))
.addDependencies(xcodeProviderBuilder, new Attribute("deps", Mode.TARGET))
.addNonPropagatedDependencies(
xcodeProviderBuilder, new Attribute("non_propagated_deps", Mode.TARGET))
.addFilesToBuild(filesToBuild);

if (productType != XcodeProductType.LIBRARY_STATIC) {
xcodeSupport.generateCompanionLibXcodeTarget(xcodeProviderBuilder);
}
XcodeProvider xcodeProvider = xcodeProviderBuilder.build();
xcodeSupport.registerActions(xcodeProvider);

RuleConfiguredTargetBuilder targetBuilder =
ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build())
.addProvider(XcodeProvider.class, xcodeProvider)
.addProvider(ObjcProvider.class, objcProvider)
.addProvider(
InstrumentedFilesProvider.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.Platform;
import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.objc.XcodeProvider.Builder;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.PathFragment;

Expand Down Expand Up @@ -119,18 +118,6 @@ BundleSupport registerActions(ObjcProvider objcProvider) {
return this;
}

/**
* Adds any Xcode settings related to this bundle to the given provider builder.
*
* @return this bundle support
*/
BundleSupport addXcodeSettings(Builder xcodeProviderBuilder) {
if (bundling.getBundleInfoplist().isPresent()) {
xcodeProviderBuilder.setBundleInfoplist(bundling.getBundleInfoplist().get());
}
return this;
}

/**
* Validates the platform for this build is either simulator or device, and does not
* contain architectures for both platforms.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FORCE_LOAD_LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FRAMEWORK_SEARCH_PATH_ONLY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.IMPORTED_LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE_SYSTEM;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.SDK_DYLIB;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.SDK_FRAMEWORK;
Expand Down Expand Up @@ -181,14 +180,6 @@ public static final FilesToRunProvider libtool(RuleContext ruleContext) {
HEADERS))
.withSourceAttributes("srcs", "non_arc_srcs", "hdrs")
.withDependencyAttributes("deps", "data", "binary", "xctest_app");

private static final Predicate<String> INCLUDE_DIR_OPTION_IN_COPTS =
new Predicate<String>() {
@Override
public boolean apply(String copt) {
return copt.startsWith("-I") && copt.length() > 2;
}
};

/**
* Defines a library that contains the transitive closure of dependencies.
Expand Down Expand Up @@ -734,52 +725,6 @@ CompilationSupport validateAttributes() throws RuleErrorException {
return this;
}

/**
* Sets compilation-related Xcode project information on the given provider builder.
*
* @param common common information about this rule's attributes and its dependencies
* @return this compilation support
*/
CompilationSupport addXcodeSettings(
XcodeProvider.Builder xcodeProviderBuilder, ObjcCommon common) {
for (CompilationArtifacts artifacts : common.getCompilationArtifacts().asSet()) {
xcodeProviderBuilder.setCompilationArtifacts(artifacts);
}

// The include directory options ("-I") are parsed out of copts. The include directories are
// added as non-propagated header search paths local to the associated Xcode target.
Iterable<String> copts = Iterables.concat(objcConfiguration.getCopts(), attributes.copts());
Iterable<String> includeDirOptions = Iterables.filter(copts, INCLUDE_DIR_OPTION_IN_COPTS);
Iterable<String> coptsWithoutIncludeDirs = Iterables.filter(
copts, Predicates.not(INCLUDE_DIR_OPTION_IN_COPTS));
ImmutableList.Builder<PathFragment> nonPropagatedHeaderSearchPaths =
new ImmutableList.Builder<>();
for (String includeDirOption : includeDirOptions) {
nonPropagatedHeaderSearchPaths.add(PathFragment.create(includeDirOption.substring(2)));
}

// We also need to add the -isystem directories from the CC header providers. ObjCommon
// adds these to the objcProvider, so let's just get them from there.
Iterable<PathFragment> includeSystemPaths = common.getObjcProvider().get(INCLUDE_SYSTEM);

xcodeProviderBuilder
.addHeaders(attributes.hdrs())
.addHeaders(attributes.textualHdrs())
.addUserHeaderSearchPaths(
ObjcCommon.userHeaderSearchPaths(common.getObjcProvider(), buildConfiguration))
.addHeaderSearchPaths(
"$(WORKSPACE_ROOT)",
attributes.headerSearchPaths(buildConfiguration.getGenfilesFragment()))
.addHeaderSearchPaths("$(WORKSPACE_ROOT)", includeSystemPaths)
.addHeaderSearchPaths("$(SDKROOT)/usr/include", attributes.sdkIncludes())
.addNonPropagatedHeaderSearchPaths(
"$(WORKSPACE_ROOT)", nonPropagatedHeaderSearchPaths.build())
.addCompilationModeCopts(objcConfiguration.getCoptsForCompilationMode())
.addCopts(coptsWithoutIncludeDirs);

return this;
}

/**
* Registers all actions necessary to compile this rule's sources and archive them.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
Expand Down Expand Up @@ -140,15 +139,6 @@ private Artifact appendExtension(String extension) {
return scopedArtifact(name.replaceName(addOutputPrefix(name.getBaseName(), extension)));
}

/**
* A dummy .c file to be included in xcode projects. This is needed if the target does not have
* any source files but Xcode requires one.
*/
public Artifact dummySource() {
return scopedArtifact(
ruleContext.getPrerequisiteArtifact("$dummy_source", Mode.TARGET).getRootRelativePath());
}

/**
* Returns a derived artifact in the genfiles directory obtained by appending some extension to
* the end of the {@link PathFragment} corresponding to the owner {@link Label}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.devtools.build.lib.analysis.config.BuildOptions;
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.AppleConfiguration.ConfigurationDistinguisher;
import com.google.devtools.build.lib.rules.apple.Platform;
import com.google.devtools.build.lib.rules.apple.Platform.PlatformType;
import com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag;
Expand Down Expand Up @@ -54,8 +53,7 @@ public class IosApplication extends ReleaseBundlingTargetFactory {
new Attribute("extensions", Mode.TARGET));

public IosApplication() {
super(ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT, XcodeProductType.APPLICATION,
DEPENDENCY_ATTRIBUTES, ConfigurationDistinguisher.IOS_APPLICATION);
super(ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT, DEPENDENCY_ATTRIBUTES);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public Metadata getMetadata() {
.ancestors(
BaseRuleClasses.BaseRule.class,
ObjcRuleClasses.ReleaseBundlingRule.class,
ObjcRuleClasses.XcodegenRule.class,
ObjcRuleClasses.SimulatorRule.class,
IpaRule.class)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public class IosExtension extends ReleaseBundlingTargetFactory {
ConfigurationDistinguisher.IOS_EXTENSION);

public IosExtension() {
super(ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT, XcodeProductType.EXTENSION,
ImmutableSet.of(new Attribute("binary", Mode.SPLIT)),
ConfigurationDistinguisher.IOS_EXTENSION);
super(
ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT,
ImmutableSet.of(new Attribute("binary", Mode.SPLIT)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Deprecated
public class IosExtensionBinary extends BinaryLinkingTargetFactory {
public IosExtensionBinary() {
super(HasReleaseBundlingSupport.NO, XcodeProductType.LIBRARY_STATIC);
super(HasReleaseBundlingSupport.NO);
}

@Override
Expand Down
Loading

0 comments on commit 85b0ad2

Please sign in to comment.