Commit fbe50a7e authored by Drew's avatar Drew

Support miscellaneous files in xcode projects

We need this to attach a bridging header
parent 86281517
......@@ -109,9 +109,14 @@ 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, appTarget: nil, xcodeprojGUID: xcodeprojGUID )
let target = PbxNativeTarget(productReference: product, outputType: outputType, sourceFiles: sourceRefs, linkFiles: linkWith, otherFiles: otherFiles, appTarget: nil, xcodeprojGUID: xcodeprojGUID )
objects.append(target)
objects.append(product)
......@@ -119,7 +124,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: [], appTarget: target, xcodeprojGUID: xcodeprojGUID)
let testTarget = PbxNativeTarget(productReference: testProduct, outputType: .TestTarget, sourceFiles: sources, linkFiles: [], otherFiles: [], appTarget: target, xcodeprojGUID: xcodeprojGUID)
objects.append(testProduct)
objects.append(testTarget)
for o in sources {
......
......@@ -296,11 +296,11 @@ struct PbxNativeTarget: PbxprojSerializable {
let appTarget: TargetWrapper?
//todo: This should be a more generic type than plists
let otherFiles: [PbxPlistFileReference]
let otherFiles: [PbxFileReference]
let phases: PbxPhases
init(productReference: PbxProductReference, outputType: OutputType, sourceFiles: [PbxSourceFileReference], linkFiles:[PbxProductReference], appTarget: PbxNativeTarget?, xcodeprojGUID: String) {
init(productReference: PbxProductReference, outputType: OutputType, sourceFiles: [PbxSourceFileReference], linkFiles:[PbxProductReference], otherFiles: [PbxFileReference], appTarget: PbxNativeTarget?, xcodeprojGUID: String) {
if let a = appTarget {
self.appTarget = TargetWrapper(target: a)
}
......@@ -374,13 +374,13 @@ 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.otherFiles = [PbxPlistFileReference(path: plistName)] + otherFiles
self.configurationList = PbxTargetConfigurations(plistPath: plistName, testThisApp: appTarget!.name)
self.dependencies = [PbxTargetDependency(target: appTarget!, projectGUID: xcodeprojGUID)]
case .StaticLibrary, .Executable:
self.configurationList = PbxTargetConfigurations(plistPath: nil, testThisApp: nil)
self.otherFiles = []
self.otherFiles = otherFiles
self.dependencies = []
}
}
......@@ -571,6 +571,13 @@ struct PbxProductReference: PbxprojSerializable {
}
}
///a generic type for anything in the PBXFileReference section
///todo: consider reparenting existing types to this
protocol PbxFileReference: PbxprojSerializable {
var guid: String { get }
var path: String { get }
}
struct PbxBuildFile: PbxprojSerializable {
let guid = xcodeguid()
let path: String
......@@ -595,7 +602,7 @@ struct PbxStaticLibraryFileReference: PbxprojSerializable {
}
}
struct PbxPlistFileReference: PbxprojSerializable {
struct PbxPlistFileReference: PbxFileReference {
let path: String
let guid = xcodeguid()
init(path: String) {
......@@ -607,6 +614,18 @@ struct PbxPlistFileReference: PbxprojSerializable {
}
}
struct PbxHeaderFileReference: PbxFileReference {
let path: String
let guid = xcodeguid()
init(path: String) {
self.path = path
}
func serialize() -> String {
var s = "\(guid) /* \(path) */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = \(path); path = \"\(path)\"; sourceTree = \"<group>\"; };"
return s
}
}
struct PbxTargetDependency : PbxprojSerializable {
let guid = xcodeguid()
let target : PbxNativeTarget
......
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