Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Revert "Include headers in search path during swift compilation"
Browse files Browse the repository at this point in the history
Summary:
This reverts #911, with some minor fixes after merging.

The reason is here: #983 (comment)

/cc ryu2
Closes #1007

Reviewed By: ryu2

fbshipit-source-id: 98e69f5
  • Loading branch information
Tho Nguyen authored and Facebook Github Bot committed Nov 11, 2016
1 parent 5763ab6 commit 62ee3be
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 141 deletions.
8 changes: 6 additions & 2 deletions src/com/facebook/buck/apple/AppleTestDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public class AppleTestDescription implements
/**
* Flavors for the additional generated build rules.
*/
static final Flavor LIBRARY_FLAVOR = ImmutableFlavor.of("apple-test-library");
static final Flavor BUNDLE_FLAVOR = ImmutableFlavor.of("apple-test-bundle");
private static final Flavor UNZIP_XCTOOL_FLAVOR = ImmutableFlavor.of("unzip-xctool");

private static final ImmutableSet<Flavor> SUPPORTED_FLAVORS = ImmutableSet.of(BUNDLE_FLAVOR);
private static final ImmutableSet<Flavor> SUPPORTED_FLAVORS = ImmutableSet.of(
LIBRARY_FLAVOR, BUNDLE_FLAVOR);

/**
* Auxiliary build modes which makes this description emit just the results of the underlying
Expand Down Expand Up @@ -168,7 +170,9 @@ public <A extends Arg> BuildRule createBuildRule(
boolean addDefaultPlatform = libraryFlavors.isEmpty();
ImmutableSet.Builder<Flavor> extraFlavorsBuilder = ImmutableSet.builder();
if (createBundle) {
extraFlavorsBuilder.add(CxxDescriptionEnhancer.MACH_O_BUNDLE_FLAVOR);
extraFlavorsBuilder.add(
LIBRARY_FLAVOR,
CxxDescriptionEnhancer.MACH_O_BUNDLE_FLAVOR);
}
extraFlavorsBuilder.add(debugFormat.getFlavor());
if (addDefaultPlatform) {
Expand Down
13 changes: 0 additions & 13 deletions src/com/facebook/buck/swift/SwiftCompile.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import com.facebook.buck.cxx.CxxPlatform;
import com.facebook.buck.cxx.CxxPreprocessables;
import com.facebook.buck.cxx.CxxPreprocessorInput;
import com.facebook.buck.cxx.HeaderVisibility;
import com.facebook.buck.io.ProjectFilesystem;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.parser.NoSuchBuildTargetException;
import com.facebook.buck.rules.AbstractBuildRule;
import com.facebook.buck.rules.AddToRuleKey;
Expand Down Expand Up @@ -136,17 +134,6 @@ private SwiftCompileStep makeCompileStep() {
compilerCommand.add(
"-import-objc-header",
getResolver().getRelativePath(bridgingHeader.get()).toString());

// bridging header needs exported headers for imports
for (HeaderVisibility headerVisibility : HeaderVisibility.values()) {
Path headerPath = CxxDescriptionEnhancer.getHeaderSymlinkTreePath(
getProjectFilesystem(),
BuildTarget.builder(getBuildTarget().getUnflavoredBuildTarget()).build(),
cxxPlatform.getFlavor(),
headerVisibility);

compilerCommand.add(INCLUDE_FLAG, headerPath.toString());
}
}

final Function<FrameworkPath, Path> frameworkPathToSearchPath =
Expand Down
9 changes: 1 addition & 8 deletions src/com/facebook/buck/swift/SwiftDescriptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import com.facebook.buck.cxx.CxxLibraryDescription;
import com.facebook.buck.io.MorePaths;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.rules.PathSourcePath;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.SourcePathResolver;
import com.facebook.buck.rules.SourceWithFlags;
import com.google.common.base.Preconditions;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;

Expand Down Expand Up @@ -58,12 +55,8 @@ static <A extends CxxLibraryDescription.Arg> void populateSwiftLibraryDescriptio
SwiftLibraryDescription.Arg output,
final A args,
BuildTarget buildTarget) {

output.srcs = filterSwiftSources(sourcePathResolver, args.srcs);
output.headersSearchPath = FluentIterable.from(args.exportedHeaders.getPaths())
.uniqueIndex(path -> {
Preconditions.checkArgument(path instanceof PathSourcePath);
return ((PathSourcePath) path).getRelativePath();
});
output.compilerFlags = args.compilerFlags;
output.frameworks = args.frameworks;
output.libraries = args.libraries;
Expand Down
19 changes: 0 additions & 19 deletions src/com/facebook/buck/swift/SwiftLibraryDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.facebook.buck.cxx.CxxLibraryDescription;
import com.facebook.buck.cxx.CxxLinkableEnhancer;
import com.facebook.buck.cxx.CxxPlatform;
import com.facebook.buck.cxx.HeaderVisibility;
import com.facebook.buck.cxx.Linker;
import com.facebook.buck.cxx.NativeLinkable;
import com.facebook.buck.cxx.NativeLinkableInput;
Expand All @@ -33,7 +32,6 @@
import com.facebook.buck.model.FlavorDomain;
import com.facebook.buck.model.Flavored;
import com.facebook.buck.model.ImmutableFlavor;
import com.facebook.buck.model.UnflavoredBuildTarget;
import com.facebook.buck.parser.NoSuchBuildTargetException;
import com.facebook.buck.rules.AbstractDescriptionArg;
import com.facebook.buck.rules.BuildRule;
Expand All @@ -53,7 +51,6 @@
import com.google.common.base.Suppliers;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Ordering;
Expand Down Expand Up @@ -225,21 +222,6 @@ public <A extends SwiftLibraryDescription.Arg> BuildRule createBuildRule(
.transform(Optional::get)
.toSortedSet(Ordering.natural()));

UnflavoredBuildTarget unflavoredBuildTarget =
params.getBuildTarget().getUnflavoredBuildTarget();

for (HeaderVisibility headerVisibility : HeaderVisibility.values()) {
// unflavoredBuildTarget because #headers can collide with any other flavor
// from the same domain.
CxxDescriptionEnhancer.requireHeaderSymlinkTree(
params.copyWithBuildTarget(BuildTarget.builder(unflavoredBuildTarget).build()),
resolver,
new SourcePathResolver(resolver),
cxxPlatform,
args.headersSearchPath,
headerVisibility);
}

return new SwiftCompile(
cxxPlatform,
swiftBuckConfig,
Expand Down Expand Up @@ -365,7 +347,6 @@ public static class Arg extends AbstractDescriptionArg {
public Optional<SourcePath> bridgingHeader;
public ImmutableSortedSet<BuildTarget> deps = ImmutableSortedSet.of();
public Optional<NativeLinkable.Linkage> preferredLinkage;
public ImmutableMap<Path, SourcePath> headersSearchPath = ImmutableMap.of();
}

}
4 changes: 3 additions & 1 deletion test/com/facebook/buck/apple/AppleTestIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,9 @@ public void appleTestWithoutTestHostMultiarchShouldHaveMultiarchDsym() throws Ex
result.assertSuccess();

BuildTarget libraryTarget =
target.withAppendedFlavors(CxxDescriptionEnhancer.MACH_O_BUNDLE_FLAVOR);
target.withAppendedFlavors(
AppleTestDescription.LIBRARY_FLAVOR,
CxxDescriptionEnhancer.MACH_O_BUNDLE_FLAVOR);
Path output = workspace.getDestPath().resolve(
BuildTargets.getGenPath(
filesystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public void headersOfDependentTargetsAreIncluded() throws Exception {
args.libraries = ImmutableSortedSet.of();
args.enableObjcInterop = Optional.empty();
args.supportedPlatformsRegex = Optional.empty();
args.headersSearchPath = ImmutableMap.of();

SwiftCompile buildRule = (SwiftCompile) FakeAppleRuleDescriptions.SWIFT_LIBRARY_DESCRIPTION
.createBuildRule(TargetGraph.EMPTY, params, resolver, args);
Expand Down
15 changes: 0 additions & 15 deletions test/com/facebook/buck/swift/SwiftTestIOSIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.junit.Rule;
import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -99,18 +98,4 @@ public void testAppleTestToWorkWithSwift() throws Exception {
workspace.runCommand("otool", "-l", binaryOutput.toString()).getStdout().get(),
containsString("@loader_path/Frameworks"));
}

@Test
public void swiftCallingComplexObjCRunsAndPrintsMessageOnOSX() throws IOException {
assumeThat(
AppleNativeIntegrationTestUtils.isSwiftAvailable(ApplePlatform.MACOSX),
is(true));
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(
this, "swift_calls_complex_objc", tmp);
workspace.setUp();

ProjectWorkspace.ProcessResult runResult = workspace.runBuckCommand(
"build", ":SwiftCallsComplexObjC#iphonesimulator-x86_64");
runResult.assertSuccess();
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 62ee3be

Please sign in to comment.