aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc_tools
diff options
context:
space:
mode:
authorGravatar Rumou Duan <rduan@google.com>2015-10-02 20:12:27 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-10-05 08:00:30 +0000
commitd900d54d60a256d2d2859d029c300e6d9dd61e22 (patch)
tree46d5b9e48a6aa7d2c7d4b0dd5c2f8871d79fef8b /src/objc_tools
parent9e54af373d33ec2eadafe1b8dbec3b70a5f1d4ef (diff)
Add imported static libraries to the list of libraries to link, instead of specifying them as linker flags, and also add their associated library search paths. This makes sure the link order for libraries is consistent with Bazel build.
-- MOS_MIGRATED_REVID=104524532
Diffstat (limited to 'src/objc_tools')
-rw-r--r--src/objc_tools/xcodegen/java/com/google/devtools/build/xcode/xcodegen/XcodeprojGeneration.java33
1 files changed, 27 insertions, 6 deletions
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 198d4f991b..b0ed080222 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
@@ -332,6 +332,18 @@ public class XcodeprojGeneration {
}
/**
+ * Returns the {@code LIBRARY_SEARCH_PATHS} array for a target's imported static libraries.
+ */
+ private static NSArray librarySearchPaths(Iterable<String> importedLibraries) {
+ ImmutableSet.Builder<NSString> result = new ImmutableSet.Builder<>();
+ for (String importedLibrary : importedLibraries) {
+ result.add(new NSString("$(WORKSPACE_ROOT)/" + Paths.get(importedLibrary).getParent()));
+ }
+
+ return (NSArray) NSObject.wrap(result.build().asList());
+ }
+
+ /**
* Returns the {@code ARCHS} array for a target's build config given the list of architecture
* strings. If none is given, an array with default architectures "armv7" and "arm64" will be
* returned.
@@ -364,11 +376,6 @@ public class XcodeprojGeneration {
Iterable<String> givenFlags = targetControl.getLinkoptList();
ImmutableList.Builder<String> flags = new ImmutableList.Builder<>();
flags.addAll(givenFlags);
- if (!Equaling.of(ProductType.STATIC_LIBRARY, productType(targetControl))) {
- for (String importedLibrary : targetControl.getImportedLibraryList()) {
- 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")) {
@@ -513,6 +520,11 @@ public class XcodeprojGeneration {
targetBuildConfigMap.put(name, value);
}
+ if (!Equaling.of(ProductType.STATIC_LIBRARY, productType(targetControl))) {
+ targetBuildConfigMap.put("LIBRARY_SEARCH_PATHS",
+ librarySearchPaths(targetControl.getImportedLibraryList()));
+ }
+
// Note that HFS+ (the Mac filesystem) is usually case insensitive, so we cast all target
// names to lower case before checking for duplication because otherwise users may end up
// having duplicated intermediate build directories that can interfere with the build.
@@ -586,9 +598,18 @@ public class XcodeprojGeneration {
Iterables.addAll(project.getMainGroup().getChildren(), processedProjectFiles);
for (TargetInfo targetInfo : targetInfoByLabel.values()) {
- for (DependencyControl dependency : targetInfo.control.getDependencyList()) {
+ TargetControl targetControl = targetInfo.control;
+ for (DependencyControl dependency : targetControl.getDependencyList()) {
targetInfo.addDependencyInfo(dependency, targetInfoByLabel);
}
+
+ if (!Equaling.of(ProductType.STATIC_LIBRARY, productType(targetControl))) {
+ for (String importedLibrary : targetControl.getImportedLibraryList()) {
+ FileReference fileReference = FileReference.of(importedLibrary, SourceTree.GROUP)
+ .withExplicitFileType(FILE_TYPE_ARCHIVE_LIBRARY);
+ targetInfo.frameworksPhase.getFiles().add(pbxBuildFiles.getStandalone(fileReference));
+ }
+ }
}
return project;