Commit e5c155c9 authored by Drew's avatar Drew

Support header paths / other LD

Support new AT package features:

* `include-with-user` becomes `HEADER_SEARCH_PATH`
* `link-options` becomes `OTHER_LD_FLAGS`
parent 692f8090
......@@ -109,8 +109,23 @@ func process(tasks: [Task], testTask: Task?, package: Package, xcodeprojGUID: St
let product = PbxProductReference(name: taskname, type:type)
let sourceRefs = sources.map() {PbxSourceFileReference(path:$0.description)}
var ldFlags: [String]? = nil
if let flags = task["link-options"]?.vector {
ldFlags = []
for flag in flags.flatMap({$0.string}){
ldFlags!.append(flag)
}
}
var headerSearchPaths: [String]? = nil
if let paths = task["include-with-user"]?.vector {
headerSearchPaths = []
for header in paths.flatMap({$0.string}) {
headerSearchPaths!.append(header)
}
}
let target = PbxNativeTarget(productReference: product, outputType: outputType, sourceFiles: sourceRefs, linkFiles: linkWith, otherFiles: [], bridgingHeader: task["umbrella-header"]?.string, appTarget: nil, xcodeprojGUID: xcodeprojGUID )
let target = PbxNativeTarget(productReference: product, outputType: outputType, sourceFiles: sourceRefs, linkFiles: linkWith, otherFiles: [], bridgingHeader: task["umbrella-header"]?.string, headerSearchPaths: headerSearchPaths, otherLdFlags: ldFlags, appTarget: nil, xcodeprojGUID: xcodeprojGUID )
objects.append(target)
objects.append(product)
......@@ -118,7 +133,7 @@ func process(tasks: [Task], testTask: Task?, package: Package, xcodeprojGUID: St
guard let testSourceDescriptions = testTask["sources"]?.vector?.flatMap({$0.string}) else { fatalError("Can't find sources for atllbuild.") }
let sources = collectSources(sourceDescriptions: testSourceDescriptions, taskForCalculatingPath: testTask).map() {PbxSourceFileReference(path: $0.description)}
let testProduct = PbxProductReference(name: taskname+"Tests", type: .TestTarget)
let testTarget = PbxNativeTarget(productReference: testProduct, outputType: .TestTarget, sourceFiles: sources, linkFiles: [], otherFiles: [], bridgingHeader: nil, appTarget: target, xcodeprojGUID: xcodeprojGUID)
let testTarget = PbxNativeTarget(productReference: testProduct, outputType: .TestTarget, sourceFiles: sources, linkFiles: [], otherFiles: [], bridgingHeader: nil, headerSearchPaths: nil, otherLdFlags: nil, appTarget: target, xcodeprojGUID: xcodeprojGUID)
objects.append(testProduct)
objects.append(testTarget)
for o in sources {
......
......@@ -300,7 +300,7 @@ struct PbxNativeTarget: PbxprojSerializable {
let phases: PbxPhases
init(productReference: PbxProductReference, outputType: OutputType, sourceFiles: [PbxSourceFileReference], linkFiles:[PbxProductReference], otherFiles: [PbxFileReference], bridgingHeader: String?, appTarget: PbxNativeTarget?, xcodeprojGUID: String) {
init(productReference: PbxProductReference, outputType: OutputType, sourceFiles: [PbxSourceFileReference], linkFiles:[PbxProductReference], otherFiles: [PbxFileReference], bridgingHeader: String?, headerSearchPaths: [String]?, otherLdFlags: [String]?, appTarget: PbxNativeTarget?, xcodeprojGUID: String) {
if let a = appTarget {
self.appTarget = TargetWrapper(target: a)
}
......@@ -345,7 +345,7 @@ struct PbxNativeTarget: PbxprojSerializable {
let plistName = "\(productReference.name)-xcode-emit-Info.plist"
try! s.write(to: Path(plistName))
plistFileRef = PbxPlistFileReference(path: plistName)
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: nil, bridgingHeader: bridgingHeader)
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: nil, bridgingHeader: bridgingHeader, headerSearchPaths: headerSearchPaths, otherLdFlags: otherLdFlags)
self.dependencies = []
case .TestTarget:
var s = ""
......@@ -378,11 +378,11 @@ struct PbxNativeTarget: PbxprojSerializable {
let plistName = "\(productReference.name)-xcode-emit-Info.plist"
try! s.write(to: Path(plistName))
plistFileRef = PbxPlistFileReference(path: plistName)
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: appTarget!.name, bridgingHeader: bridgingHeader)
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: appTarget!.name, bridgingHeader: bridgingHeader, headerSearchPaths: headerSearchPaths, otherLdFlags: otherLdFlags)
self.dependencies = [PbxTargetDependency(target: appTarget!, projectGUID: xcodeprojGUID)]
case .StaticLibrary, .Executable:
self.configurationList = PbxTargetConfigurations(plistPath: nil, testThisApp: nil, bridgingHeader: bridgingHeader)
self.configurationList = PbxTargetConfigurations(plistPath: nil, testThisApp: nil, bridgingHeader: bridgingHeader, headerSearchPaths: headerSearchPaths, otherLdFlags: otherLdFlags)
self.dependencies = []
plistFileRef = nil
}
......@@ -452,6 +452,8 @@ struct PbxTargetConfigurations: PbxprojSerializable {
///If non-nil, we will emit a test target to test the given app. Use the name of the executable, a.k.a. the app name without `.app` extension
let testThisApp: String?
let bridgingHeader: String?
let headerSearchPaths: [String]?
let otherLdFlags: [String]?
func serialize() -> String {
......@@ -475,6 +477,18 @@ struct PbxTargetConfigurations: PbxprojSerializable {
if let bridgingHeader = bridgingHeader {
sx += " SWIFT_OBJC_BRIDGING_HEADER = \"\(bridgingHeader)\";\n"
}
if let of = otherLdFlags {
//SR-3026
let lexp1 = of.map{"\"\($0)\""}
let lexp2 = lexp1.joined(separator: ",")
sx += " OTHER_LDFLAGS = ( \(lexp2) );\n"
}
if let searchPaths = headerSearchPaths {
//SR-3026
let lexp1 = searchPaths.map{"\"\($0)\""}
let lexp2 = lexp1.joined(separator: ",")
sx += " HEADER_SEARCH_PATHS = ( \(lexp2) );\n"
}
var s = ""
s += "\(guid) /* Build configuration list for PBXNativeTarget */ = {\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment