Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 7c91394

Browse files
committed
[packages,XcodeBuilder] Fixes #209. Xcode generation now supports identifying .tbd files, new in Xcode 7, which are text based dylib definition files. The LinkPrebuiltLibrary exercises this when targeting Xcode7.
1 parent f9e6878 commit 7c91394

File tree

3 files changed

+67
-60
lines changed

3 files changed

+67
-60
lines changed

Changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
11-Apr-2016 Fixes #209. Xcode generation now supports identifying .tbd files, new in Xcode 7, which are text based dylib definition files. The LinkPrebuiltLibrary exercises this when targeting Xcode7.
2+
13
11-Apr-2016 Fixes #218. Removed unused code from Bam.Core.TimingProfileUtilities that had been identified by Coverity scan.
24

35
11-Apr-2016 Fixes #217. Fetching the rank of a ModuleCollection from the Bam.Core.DependencyGraph used a comparison for a default System.Collections.Generic.Dictionary<int, ModuleCollection> which Coverity scan identified as logically dead code (equivalent to null, even though that doesn't compile), suggesting all ModuleCollections should have a valid rank index (which isn't true). Regardless, the code has been tidied up to eliminate ambiguity.

packages/ClangCommon/bam/Scripts/LinkerSettings/Xcode/C/ICommonLinkerSettings.cs

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -40,113 +40,114 @@ private static XcodeBuilder.BuildFile
4040
{
4141
var fileRef = target.Project.EnsureFileReferenceExists(
4242
Bam.Core.TokenizedString.CreateVerbatim(pathToLibrary),
43-
XcodeBuilder.FileReference.EFileType.Archive,
43+
type,
4444
true,
4545
sourcetree);
4646
var buildFile = target.EnsureFrameworksBuildFileExists(
4747
fileRef.Path,
48-
XcodeBuilder.FileReference.EFileType.Archive);
48+
type);
4949
target.Project.MainGroup.AddChild(fileRef);
5050
return buildFile;
5151
}
5252

53-
private static XcodeBuilder.BuildFile
54-
FindLibraryInLibrarySearchPaths(
55-
XcodeBuilder.Target target,
56-
C.ICommonLinkerSettings settings,
53+
private static System.Tuple<string,XcodeBuilder.FileReference.EFileType>
54+
SearchForLibraryPath(
55+
string searchPath,
5756
string libname)
5857
{
59-
foreach (var searchPath in settings.LibraryPaths)
58+
// look for dylibs first
59+
var pattern = System.String.Format("lib{0}.dylib", libname);
60+
Bam.Core.Log.DebugMessage("Searching {0} for {1}", searchPath, pattern);
61+
var results = System.IO.Directory.GetFiles(searchPath, pattern);
62+
if (results.Length > 0)
6063
{
61-
var realSearchpath = searchPath.Parse();
62-
// some lib paths might not exist yet
63-
if (!System.IO.Directory.Exists(realSearchpath))
64+
if (results.Length > 1)
6465
{
65-
continue;
66+
throw new Bam.Core.Exception("Found {0} instances of {1} dynamic libraries in {2}. Which was intended?", results.Length, libname, searchPath);
6667
}
67-
// look for dylibs first
68-
var pattern = System.String.Format("lib{0}.dylib", libname);
69-
Bam.Core.Log.DebugMessage("Searching {0} for {1}", realSearchpath, pattern);
70-
var results = System.IO.Directory.GetFiles(realSearchpath, pattern);
68+
return System.Tuple.Create(results[0], XcodeBuilder.FileReference.EFileType.DynamicLibrary);
69+
}
70+
else
71+
{
72+
// then static libs
73+
pattern = System.String.Format("lib{0}.a", libname);
74+
Bam.Core.Log.DebugMessage("Searching {0} for {1}", searchPath, pattern);
75+
results = System.IO.Directory.GetFiles(searchPath, pattern);
7176
if (results.Length > 0)
7277
{
7378
if (results.Length > 1)
7479
{
75-
throw new Bam.Core.Exception("Found {0} instances of {1} dynamic libraries in {2}. Which was intended?", results.Length, libname, realSearchpath);
80+
throw new Bam.Core.Exception("Found {0} instances of {1} static libraries in {2}. Which was intended?", results.Length, libname, searchPath);
7681
}
77-
return CreateLinkableReferences(
78-
target,
79-
System.String.Format("{0}/lib{1}.dylib", realSearchpath, libname),
80-
XcodeBuilder.FileReference.EFileType.DynamicLibrary,
81-
XcodeBuilder.FileReference.ESourceTree.Absolute);
82+
return System.Tuple.Create(results[0], XcodeBuilder.FileReference.EFileType.Archive);
8283
}
8384
else
8485
{
85-
// then static libs
86-
pattern = System.String.Format("lib{0}.a", libname);
87-
Bam.Core.Log.DebugMessage("Searching {0} for {1}", realSearchpath, pattern);
88-
results = System.IO.Directory.GetFiles(realSearchpath, pattern);
86+
// then text based dylib definitions (Xcode7+)
87+
pattern = System.String.Format("lib{0}.tbd", libname);
88+
Bam.Core.Log.DebugMessage("Searching {0} for {1}", searchPath, pattern);
89+
results = System.IO.Directory.GetFiles(searchPath, pattern);
8990
if (results.Length > 0)
9091
{
9192
if (results.Length > 1)
9293
{
93-
throw new Bam.Core.Exception("Found {0} instances of {1} static libraries in {2}. Which was intended?", results.Length, libname, realSearchpath);
94+
throw new Bam.Core.Exception("Found {0} instances of {1} text based dylib definition libraries in {2}. Which was intended?", results.Length, libname, searchPath);
9495
}
95-
return CreateLinkableReferences(
96-
target,
97-
System.String.Format("{0}/lib{1}.a", realSearchpath, libname),
98-
XcodeBuilder.FileReference.EFileType.Archive,
99-
XcodeBuilder.FileReference.ESourceTree.Absolute);
96+
return System.Tuple.Create(results[0], XcodeBuilder.FileReference.EFileType.TextBasedDylibDefinition);
10097
}
10198
}
10299
}
103100
return null;
104101
}
105102

106103
private static XcodeBuilder.BuildFile
107-
FindLibraryInSDKSearchPaths(
104+
FindLibraryInLibrarySearchPaths(
108105
XcodeBuilder.Target target,
109106
C.ICommonLinkerSettings settings,
110107
string libname)
111108
{
112-
var meta = Bam.Core.Graph.Instance.PackageMetaData<Clang.MetaData>("Clang");
113-
var searchPath = System.String.Format("{0}/usr/lib", meta.SDKPath);
114-
var pattern = System.String.Format("lib{0}.dylib", libname);
115-
Bam.Core.Log.DebugMessage("Searching {0} for {1}", searchPath, pattern);
116-
var results = System.IO.Directory.GetFiles(searchPath, pattern);
117-
if (results.Length > 0)
109+
foreach (var searchPath in settings.LibraryPaths)
118110
{
119-
if (results.Length > 1)
111+
var realSearchpath = searchPath.Parse();
112+
// some lib paths might not exist yet
113+
if (!System.IO.Directory.Exists(realSearchpath))
120114
{
121-
throw new Bam.Core.Exception("Found {0} instances of {1} dynamic libraries in {2}. Which was intended?", results.Length, libname, searchPath);
115+
continue;
122116
}
123-
return CreateLinkableReferences(
124-
target,
125-
System.String.Format("usr/lib/lib{0}.dylib", libname),
126-
XcodeBuilder.FileReference.EFileType.DynamicLibrary,
127-
XcodeBuilder.FileReference.ESourceTree.SDKRoot);
128-
}
129-
else
130-
{
131-
pattern = System.String.Format("lib{0}.a", libname);
132-
Bam.Core.Log.DebugMessage("Searching {0} for {1}", searchPath, pattern);
133-
results = System.IO.Directory.GetFiles(searchPath, pattern);
134-
if (results.Length > 0)
117+
118+
var results = SearchForLibraryPath(realSearchpath, libname);
119+
if (null != results)
135120
{
136-
if (results.Length > 1)
137-
{
138-
throw new Bam.Core.Exception("Found {0} instances of {1} static libraries in {2}. Which was intended?", results.Length, libname, searchPath);
139-
}
140121
return CreateLinkableReferences(
141122
target,
142-
System.String.Format("usr/lib/lib{0}.a", libname),
143-
XcodeBuilder.FileReference.EFileType.Archive,
144-
XcodeBuilder.FileReference.ESourceTree.SDKRoot);
123+
results.Item1,
124+
results.Item2,
125+
XcodeBuilder.FileReference.ESourceTree.Absolute);
145126
}
146127
}
147128
return null;
148129
}
149130

131+
private static XcodeBuilder.BuildFile
132+
FindLibraryInSDKSearchPaths(
133+
XcodeBuilder.Target target,
134+
C.ICommonLinkerSettings settings,
135+
string libname)
136+
{
137+
var meta = Bam.Core.Graph.Instance.PackageMetaData<Clang.MetaData>("Clang");
138+
var searchPath = System.String.Format("{0}/usr/lib", meta.SDKPath);
139+
var results = SearchForLibraryPath(searchPath, libname);
140+
if (null != results)
141+
{
142+
return CreateLinkableReferences(
143+
target,
144+
results.Item1.Replace(meta.SDKPath,string.Empty).TrimStart(new [] { '/'}),
145+
results.Item2,
146+
XcodeBuilder.FileReference.ESourceTree.Absolute);
147+
}
148+
return null;
149+
}
150+
150151
public static void
151152
Convert(
152153
this C.ICommonLinkerSettings settings,

packages/XcodeBuilder/bam/Scripts/FileReference.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public static string
7676
case FileReference.EFileType.YaccFile:
7777
return "sourcecode.yacc";
7878

79+
case FileReference.EFileType.TextBasedDylibDefinition:
80+
return "sourcecode.text-based-dylib-definition";
81+
7982
default:
8083
throw new Bam.Core.Exception("Unrecognized file type {0}", type.ToString());
8184
}
@@ -131,7 +134,8 @@ public enum EFileType
131134
ApplicationBundle,
132135
Project,
133136
YaccFile,
134-
LexFile
137+
LexFile,
138+
TextBasedDylibDefinition
135139
}
136140

137141
public enum ESourceTree

0 commit comments

Comments
 (0)