aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java13
-rw-r--r--src/main/protobuf/xcodegen.proto4
-rw-r--r--src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/LibraryObjects.java14
-rw-r--r--src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java21
4 files changed, 24 insertions, 28 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index 57de1fdd9d..1ea050a779 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -722,11 +722,11 @@ public final class CompilationSupport {
.add(IosSdkCommands.DEFAULT_LINKER_FLAGS)
.addBeforeEach("-framework", frameworkNames(objcProvider))
.addBeforeEach("-weak_framework", SdkFramework.names(objcProvider.get(WEAK_SDK_FRAMEWORK)))
+ .addFormatEach("-l%s", libraryNames(objcProvider))
.addExecPath("-o", linkedBinary)
.addExecPaths(objcProvider.get(LIBRARY))
.addExecPaths(objcProvider.get(IMPORTED_LIBRARY))
.addExecPaths(ccLibraries)
- .add(dylibPaths(objcProvider))
.addBeforeEach("-force_load", Artifact.toExecPaths(objcProvider.get(FORCE_LOAD_LIBRARY)))
.add(extraLinkArgs)
.build();
@@ -785,12 +785,15 @@ public final class CompilationSupport {
}
}
- private Iterable<String> dylibPaths(ObjcProvider objcProvider) {
- ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
+ private Iterable<String> libraryNames(ObjcProvider objcProvider) {
ImmutableList.Builder<String> args = new ImmutableList.Builder<>();
for (String dylib : objcProvider.get(SDK_DYLIB)) {
- args.add(String.format(
- "%s/usr/lib/%s.dylib", IosSdkCommands.sdkDir(objcConfiguration), dylib));
+ if (dylib.startsWith("lib")) {
+ // remove lib prefix if it exists which is standard
+ // for libraries (libxml.dylib -> -lxml).
+ dylib = dylib.substring(3);
+ }
+ args.add(dylib);
}
return args.build();
}
diff --git a/src/main/protobuf/xcodegen.proto b/src/main/protobuf/xcodegen.proto
index 23d3362928..5aa4c593b7 100644
--- a/src/main/protobuf/xcodegen.proto
+++ b/src/main/protobuf/xcodegen.proto
@@ -172,8 +172,8 @@ message TargetControl {
// SDK .dylib files to link with this target. Each name should not include the
// the path or the .dylib extension, e.g. "libz" to link in
// "SDKROOT/usr/lib/libz.dylib". For all targets, this causes the library to
- // appear in the Project Navigator. For binary targets, this causes the
- // library to be linked with the final binary.
+ // appear in the Project Build Settings under OTHER_LDFLAGS. For binary
+ // targets, this causes the library to be linked with the final binary.
repeated string sdk_dylib = 19;
}
diff --git a/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/LibraryObjects.java b/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/LibraryObjects.java
index f751d9d48b..11c738a33d 100644
--- a/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/LibraryObjects.java
+++ b/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/LibraryObjects.java
@@ -43,7 +43,6 @@ import java.util.LinkedHashSet;
public final class LibraryObjects implements HasProjectNavigatorFiles {
@VisibleForTesting static final String FRAMEWORK_FILE_TYPE = "wrapper.framework";
- @VisibleForTesting static final String DYLIB_FILE_TYPE = "compiled.mach-o.dylib";
private final LinkedHashMap<FileReference, PBXReference> fileToMainGroupReferences =
new LinkedHashMap<>();
@@ -67,19 +66,6 @@ public final class LibraryObjects implements HasProjectNavigatorFiles {
private BuildPhaseBuilder() {} // Don't allow instantiation from outside the enclosing class.
/**
- * Creates a new dylib library based on the passed name.
- *
- * @param name simple dylib without ".dylib" suffix, e.g. "libz"
- */
- public BuildPhaseBuilder addDylib(String name) {
- FileReference reference =
- FileReference.of(String.format("usr/lib/%s.dylib", name), SourceTree.SDKROOT)
- .withExplicitFileType(DYLIB_FILE_TYPE);
- fileReferences.add(reference);
- return this;
- }
-
- /**
* Creates a new SDK framework based on the passed name.
*
* @param name simple framework name without ".framework" suffix, e.g. "Foundation"
diff --git a/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java b/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java
index 2fae52f4c0..6e69f6fb19 100644
--- a/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java
+++ b/src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java
@@ -348,14 +348,9 @@ public class XcodeprojGeneration {
}
}
- private static PBXFrameworksBuildPhase buildLibraryInfo(
+ private static PBXFrameworksBuildPhase buildFrameworksInfo(
LibraryObjects libraryObjects, TargetControl target) {
BuildPhaseBuilder builder = libraryObjects.newBuildPhase();
- if (Containing.item(PRODUCT_TYPES_THAT_HAVE_A_BINARY, productType(target))) {
- for (String dylib : target.getSdkDylibList()) {
- builder.addDylib(dylib);
- }
- }
for (String sdkFramework : target.getSdkFrameworkList()) {
builder.addSdkFramework(sdkFramework);
}
@@ -374,6 +369,15 @@ public class XcodeprojGeneration {
flags.add("$(WORKSPACE_ROOT)/" + importedLibrary);
}
}
+ if (Containing.item(PRODUCT_TYPES_THAT_HAVE_A_BINARY, productType(targetControl))) {
+ for (String dylib : targetControl.getSdkDylibList()) {
+ if (dylib.startsWith("lib")) {
+ dylib = dylib.substring(3);
+ }
+ flags.add("-l" + dylib);
+ }
+ }
+
return flags.build();
}
@@ -530,7 +534,10 @@ public class XcodeprojGeneration {
}
target.setProductReference(productReference);
- PBXFrameworksBuildPhase frameworksPhase = buildLibraryInfo(libraryObjects, targetControl);
+ // We only add frameworks here and not dylibs because of differences in how
+ // Xcode 6 and Xcode 7 specify dylibs in the project organizer.
+ // (Xcode 6 -> *.dylib, Xcode 7 -> *.tbd)
+ PBXFrameworksBuildPhase frameworksPhase = buildFrameworksInfo(libraryObjects, targetControl);
PBXResourcesBuildPhase resourcesPhase = resources.resourcesBuildPhase(targetControl);
for (String importedArchive : targetControl.getImportedLibraryList()) {