Commit 692f8090 authored by Drew's avatar Drew

Support for bridging headers

parent fbe50a7e
Pipeline #2767 passed with stage
in 1 minute and 50 seconds
......@@ -108,15 +108,9 @@ 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 otherFiles: [PbxFileReference] = []
if let header = task["umbrella-header"]?.string {
otherFiles.append(PbxHeaderFileReference(path: header))
}
let target = PbxNativeTarget(productReference: product, outputType: outputType, sourceFiles: sourceRefs, linkFiles: linkWith, otherFiles: otherFiles, appTarget: nil, xcodeprojGUID: xcodeprojGUID )
let target = PbxNativeTarget(productReference: product, outputType: outputType, sourceFiles: sourceRefs, linkFiles: linkWith, otherFiles: [], bridgingHeader: task["umbrella-header"]?.string, appTarget: nil, xcodeprojGUID: xcodeprojGUID )
objects.append(target)
objects.append(product)
......@@ -124,7 +118,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: [], appTarget: target, xcodeprojGUID: xcodeprojGUID)
let testTarget = PbxNativeTarget(productReference: testProduct, outputType: .TestTarget, sourceFiles: sources, linkFiles: [], otherFiles: [], bridgingHeader: 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], appTarget: PbxNativeTarget?, xcodeprojGUID: String) {
init(productReference: PbxProductReference, outputType: OutputType, sourceFiles: [PbxSourceFileReference], linkFiles:[PbxProductReference], otherFiles: [PbxFileReference], bridgingHeader: String?, appTarget: PbxNativeTarget?, xcodeprojGUID: String) {
if let a = appTarget {
self.appTarget = TargetWrapper(target: a)
}
......@@ -310,6 +310,9 @@ struct PbxNativeTarget: PbxprojSerializable {
self.phases = PbxPhases(sourceFiles: sourceFiles, linkFiles: linkFiles)
self.sourceFiles = sourceFiles
self.linkFiles = linkFiles
let plistFileRef: PbxPlistFileReference?
switch (outputType) {
case .Application:
var s = ""
......@@ -341,8 +344,8 @@ struct PbxNativeTarget: PbxprojSerializable {
s += "</plist>\n"
let plistName = "\(productReference.name)-xcode-emit-Info.plist"
try! s.write(to: Path(plistName))
self.otherFiles = [PbxPlistFileReference(path: plistName)]
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: nil)
plistFileRef = PbxPlistFileReference(path: plistName)
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: nil, bridgingHeader: bridgingHeader)
self.dependencies = []
case .TestTarget:
var s = ""
......@@ -374,15 +377,25 @@ struct PbxNativeTarget: PbxprojSerializable {
s += "</plist>\n"
let plistName = "\(productReference.name)-xcode-emit-Info.plist"
try! s.write(to: Path(plistName))
self.otherFiles = [PbxPlistFileReference(path: plistName)] + otherFiles
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: appTarget!.name)
plistFileRef = PbxPlistFileReference(path: plistName)
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: appTarget!.name, bridgingHeader: bridgingHeader)
self.dependencies = [PbxTargetDependency(target: appTarget!, projectGUID: xcodeprojGUID)]
case .StaticLibrary, .Executable:
self.configurationList = PbxTargetConfigurations(plistPath: nil, testThisApp: nil)
self.otherFiles = otherFiles
self.configurationList = PbxTargetConfigurations(plistPath: nil, testThisApp: nil, bridgingHeader: bridgingHeader)
self.dependencies = []
plistFileRef = nil
}
//configure the other files
var of = otherFiles
if let b = bridgingHeader {
of.append(PbxHeaderFileReference(path: b))
}
if let p = plistFileRef {
of.append(p)
}
self.otherFiles = of
}
func serialize() -> String {
var s = ""
......@@ -438,7 +451,7 @@ struct PbxTargetConfigurations: PbxprojSerializable {
let plistPath: String?
///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?
func serialize() -> String {
......@@ -459,6 +472,9 @@ struct PbxTargetConfigurations: PbxprojSerializable {
sx += " LD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n"
sx += " TEST_HOST = \"$(BUILT_PRODUCTS_DIR)/\(t).app/\(t)\";\n"
}
if let bridgingHeader = bridgingHeader {
sx += " SWIFT_OBJC_BRIDGING_HEADER = \"\(bridgingHeader)\";\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