Commit aced9d16 authored by Drew's avatar Drew

Merge branch 'swift3-parameter-renaming'

Thanks to @dunkelstern for his assistance with this.
It required a few minor tweaks.
parents 8f7175e3 ae0ef38f
......@@ -77,8 +77,8 @@ if Process.arguments.contains("--help") {
func runTask(taskName: String, package: Package) {
guard let task = package.tasks[taskName] else { fatalError("No \(taskName) task in build configuration.") }
for task in package.prunedDependencyGraph(task) {
TaskRunner.runTask(task, package: package, toolchain: toolchain)
for task in package.prunedDependencyGraph(task: task) {
TaskRunner.runTask(task: task, package: package, toolchain: toolchain)
}
}
......@@ -103,7 +103,7 @@ if focusOnTask == nil {
print("Building package \(package.name)...")
runTask(focusOnTask!, package: package)
runTask(taskName: focusOnTask!, package: package)
//success message
print("Built package \(package.name).")
\ No newline at end of file
Subproject commit d6ea8b9fea7af70e3d16c9f1485738d5ba2db7bb
Subproject commit 57c9722c0a41fa3329b63a2aa90594f27a18275c
......@@ -56,7 +56,7 @@ extension NSFileManager {
let permission_ = (try! attributesOfItem(atPath: srcPath)[NSFilePosixPermissions] as! NSNumber)
#if os(OSX) || os(iOS)
let permission = permission_.unsignedShortValue
let permission = permission_.uint16Value
#elseif os(Linux)
let permission = permission_.unsignedIntValue
#endif
......@@ -92,26 +92,6 @@ extension NSFileManager {
//These parts of Swift 3 Renaming are not yet implemented on Linux
#if os(Linux)
extension NSFileManager {
func enumerator(atPath path: String) -> NSDirectoryEnumerator? {
return self.enumeratorAtPath(path)
}
func createSymbolicLink(atPath path: String, withDestinationPath destPath: String) throws {
return try self.createSymbolicLinkAtPath(path, withDestinationPath: destPath)
}
func createDirectory(atPath path: String, withIntermediateDirectories createIntermediates: Bool, attributes: [String : AnyObject]? = [:]) throws {
return try self.createDirectoryAtPath(path, withIntermediateDirectories: createIntermediates, attributes: attributes)
}
func attributesOfItem(atPath path: String) throws -> [String : Any] {
return try self.attributesOfItemAtPath(path)
}
func removeItem(atPath path: String) throws {
return try self.removeItemAtPath(path)
}
func fileExists(atPath path: String) -> Bool {
return self.fileExistsAtPath(path)
}
}
extension String {
func componentsSeparated(by separator: String) -> [String] {
return self.componentsSeparatedByString(separator)
......@@ -124,3 +104,12 @@ extension String {
}
}
#endif
//These parts are possibly? not yet implemented on OSX
#if os(OSX)
extension String {
func componentsSeparated(by string: String) -> [String] {
return self.components(separatedBy: string)
}
}
#endif
\ No newline at end of file
......@@ -70,21 +70,21 @@ class PackageFramework: Tool {
//copy payload
let payloadPath = task.importedPath + "bin/" + name + DynamicLibraryExtension
print(payloadPath)
try! manager.copyItemAtPath_SWIFTBUG(payloadPath, toPath: "\(AVersionPath)/\(name)")
try! manager.copyItemAtPath_SWIFTBUG(srcPath: payloadPath, toPath: "\(AVersionPath)/\(name)")
try! manager.createSymbolicLink(atPath: "\(frameworkPath)/\(name)", withDestinationPath: "\(relativeAVersionPath)/\(name)")
//copy modules
let modulePath = "\(AVersionPath)/Modules/\(name).swiftmodule"
try! manager.createDirectory(atPath: modulePath, withIntermediateDirectories: true, attributes: nil)
try! manager.copyItemAtPath_SWIFTBUG("bin/\(name).swiftmodule", toPath: "\(modulePath)/\(Architecture).swiftmodule")
try! manager.copyItemAtPath_SWIFTBUG("bin/\(name).swiftdoc", toPath: "\(modulePath)/\(Architecture).swiftdoc")
try! manager.copyItemAtPath_SWIFTBUG(srcPath: "bin/\(name).swiftmodule", toPath: "\(modulePath)/\(Architecture).swiftmodule")
try! manager.copyItemAtPath_SWIFTBUG(srcPath: "bin/\(name).swiftdoc", toPath: "\(modulePath)/\(Architecture).swiftdoc")
try! manager.createSymbolicLink(atPath: "\(frameworkPath)/Modules", withDestinationPath: "\(relativeAVersionPath)/Modules")
//copy resources
let resourcesPath = AVersionPath + "/Resources"
try! manager.createDirectory(atPath: resourcesPath, withIntermediateDirectories: true, attributes: nil)
for resource in resources {
try! manager.copyItemAtPath_SWIFTBUG(task.importedPath + resource, toPath: "\(resourcesPath)/\(resource)")
try! manager.copyItemAtPath_SWIFTBUG(srcPath: task.importedPath + resource, toPath: "\(resourcesPath)/\(resource)")
}
try! manager.createSymbolicLink(atPath: "\(frameworkPath)/Resources", withDestinationPath: "\(relativeAVersionPath)/Resources")
......
......@@ -25,7 +25,7 @@ final class Shell : Tool {
func run(task: Task, toolchain: String) {
setenv("ATBUILD_USER_PATH", userPath(), 1)
guard var script = task["script"]?.string else { fatalError("Invalid 'script' argument to shell tool.") }
script = evaluateSubstitutions(script, package: task.package)
script = evaluateSubstitutions(input: script, package: task.package)
do {
let oldPath = NSFileManager.defaultManager().currentDirectoryPath
defer { NSFileManager.defaultManager().changeCurrentDirectoryPath(oldPath) }
......
......@@ -24,8 +24,8 @@ final public class TaskRunner {
static public func runTask(task: Task, package: Package, toolchain: String) {
print("Running task \(task.qualifiedName) with overlays \(task.appliedOverlays)")
let tool = toolByName(task.tool)
tool.run(task, toolchain: toolchain)
let tool = toolByName(name: task.tool)
tool.run(task: task, toolchain: toolchain)
print("Completed task \(task.qualifiedName).")
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ class XCTestRun : Tool {
}
#if os(OSX)
var workingDirectory = "/tmp/XXXXXXXXXXX"
var template = workingDirectory.cString(usingEncoding: NSUTF8StringEncoding)!
var template = workingDirectory.cString(using: NSUTF8StringEncoding)!
workingDirectory = String(cString: mkdtemp(&template), encoding: NSUTF8StringEncoding)!
let manager = NSFileManager.defaultManager()
......
......@@ -43,11 +43,11 @@ final class ATllbuild : Tool {
private static let xcTestCaseProvider: String = { () -> String in
var s = ""
s += "import XCTest\n"
s += "public func testCase<T: XCTestCase>(allTests: [(String, T -> () throws -> Void)]) -> XCTestCase {\n"
s += "public func testCase<T: XCTestCase>(_ allTests: [(String, T -> () throws -> Void)]) -> XCTestCase {\n"
s += " fatalError(\"Can't get here.\")\n"
s += "}\n"
s += "\n"
s += "public func XCTMain(testCases: [XCTestCase]) {\n"
s += "public func XCTMain(_ testCases: [XCTestCase]) {\n"
s += " fatalError(\"Can't get here.\")\n"
s += "}\n"
s += "\n"
......@@ -235,7 +235,7 @@ final class ATllbuild : Tool {
}
func run(task: Task, toolchain: String) {
run(task, toolchain: toolchain, wmoHack: false)
run(task: task, toolchain: toolchain, wmoHack: false)
}
func run(task: Task, toolchain: String, wmoHack : Bool = false) {
......@@ -339,13 +339,13 @@ final class ATllbuild : Tool {
by the product name. */
let pathName = workDirectory + "/include/\(productName)"
try! manager.createDirectory(atPath: pathName, withIntermediateDirectories:false, attributes: nil)
try! manager.copyItemAtPath_SWIFTBUG(moduleMapPath, toPath: pathName + "/module.modulemap")
try! manager.copyItemAtPath_SWIFTBUG(srcPath: moduleMapPath, toPath: pathName + "/module.modulemap")
compileOptions.append(contentsOf: ["-I",pathName])
}
}
guard let sourceDescriptions = task[Options.Source.rawValue]?.vector?.flatMap({$0.string}) else { fatalError("Can't find sources for atllbuild.") }
var sources = collectSources(sourceDescriptions, taskForCalculatingPath: task)
var sources = collectSources(sourceDescriptions: sourceDescriptions, taskForCalculatingPath: task)
//xctestify
if task[Options.XCTestify.rawValue]?.bool == true {
......@@ -360,7 +360,7 @@ final class ATllbuild : Tool {
#if os(OSX)
//inject XCTestCaseProvider.swift
var xcTestCaseProviderPath = "/tmp/XXXXXXX"
var template = xcTestCaseProviderPath.cString(usingEncoding: NSUTF8StringEncoding)!
var template = xcTestCaseProviderPath.cString(using: NSUTF8StringEncoding)!
xcTestCaseProviderPath = String(cString: mkdtemp(&template), encoding: NSUTF8StringEncoding)!
xcTestCaseProviderPath += "/XCTestCaseProvider.swift"
......@@ -391,9 +391,9 @@ final class ATllbuild : Tool {
if let umbrellaHeader = task[Options.UmbrellaHeader.rawValue]?.string {
precondition(moduleMap == .Synthesized, ":\(Options.UmbrellaHeader.rawValue) \"synthesized\" must be used with the \(Options.UmbrellaHeader.rawValue) option")
let s = synthesizeModuleMap(name, umbrellaHeader: "Umbrella.h")
let s = synthesizeModuleMap(name: name, umbrellaHeader: "Umbrella.h")
try! s.write(toFile: workDirectory+"/include/module.modulemap", atomically: false, encoding: NSUTF8StringEncoding)
try! manager.copyItemAtPath_SWIFTBUG(task.importedPath + umbrellaHeader, toPath: workDirectory + "/include/Umbrella.h")
try! manager.copyItemAtPath_SWIFTBUG(srcPath: task.importedPath + umbrellaHeader, toPath: workDirectory + "/include/Umbrella.h")
compileOptions.append("-I")
compileOptions.append(workDirectory + "/include/")
compileOptions.append("-import-underlying-module")
......@@ -428,10 +428,10 @@ final class ATllbuild : Tool {
swiftCPath = c
}
else {
swiftCPath = findToolPath("swiftc",toolchain: toolchain)
swiftCPath = findToolPath(toolName: "swiftc",toolchain: toolchain)
}
let yaml = llbuildyaml(sources, workdir: workDirectory, modulename: name, linkSDK: sdk, compileOptions: compileOptions, linkOptions: linkOptions, outputType: outputType, linkWithProduct: linkWithProduct, swiftCPath: swiftCPath)
let yaml = llbuildyaml(sources: sources, workdir: workDirectory, modulename: name, linkSDK: sdk, compileOptions: compileOptions, linkOptions: linkOptions, outputType: outputType, linkWithProduct: linkWithProduct, swiftCPath: swiftCPath)
let _ = try? yaml.write(toFile: llbuildyamlpath, atomically: false, encoding: NSUTF8StringEncoding)
if bootstrapOnly { return }
......@@ -439,12 +439,12 @@ final class ATllbuild : Tool {
case .None:
break
case .Synthesized:
let s = synthesizeModuleMap(name, umbrellaHeader: nil)
let s = synthesizeModuleMap(name: name, umbrellaHeader: nil)
try! s.write(toFile: workDirectory + "/products/\(name).modulemap", atomically: false, encoding: NSUTF8StringEncoding)
}
//SR-566
let cmd = "\(findToolPath("swift-build-tool",toolchain: toolchain)) -f \(llbuildyamlpath)"
let cmd = "\(findToolPath(toolName: "swift-build-tool",toolchain: toolchain)) -f \(llbuildyamlpath)"
if system(cmd) != 0 {
fatalError(cmd)
}
......@@ -452,27 +452,27 @@ final class ATllbuild : Tool {
if !manager.fileExists(atPath: "bin") {
try! manager.createDirectory(atPath: "bin", withIntermediateDirectories: false, attributes: nil)
}
try! copyByOverwriting("\(workDirectory)/products/\(name).swiftmodule", toPath: "bin/\(name).swiftmodule")
try! copyByOverwriting("\(workDirectory)/products/\(name).swiftdoc", toPath: "bin/\(name).swiftdoc")
try! copyByOverwriting(fromPath: "\(workDirectory)/products/\(name).swiftmodule", toPath: "bin/\(name).swiftmodule")
try! copyByOverwriting(fromPath: "\(workDirectory)/products/\(name).swiftdoc", toPath: "bin/\(name).swiftdoc")
switch outputType {
case .Executable:
try! copyByOverwriting("\(workDirectory)/products/\(name)", toPath: "bin/\(name)")
try! copyByOverwriting(fromPath: "\(workDirectory)/products/\(name)", toPath: "bin/\(name)")
case .StaticLibrary:
try! copyByOverwriting("\(workDirectory)/products/\(name).a", toPath: "bin/\(name).a")
try! copyByOverwriting(fromPath: "\(workDirectory)/products/\(name).a", toPath: "bin/\(name).a")
case .DynamicLibrary:
try! copyByOverwriting("\(workDirectory)/products/\(name)\(DynamicLibraryExtension)", toPath: "bin/\(name)\(DynamicLibraryExtension)")
try! copyByOverwriting(fromPath: "\(workDirectory)/products/\(name)\(DynamicLibraryExtension)", toPath: "bin/\(name)\(DynamicLibraryExtension)")
}
switch moduleMap {
case .None:
break
case .Synthesized:
try! copyByOverwriting("\(workDirectory)/products/\(name).modulemap", toPath: "bin/\(name).modulemap")
try! copyByOverwriting(fromPath: "\(workDirectory)/products/\(name).modulemap", toPath: "bin/\(name).modulemap")
}
}
if task[Options.WholeModuleOptimization.rawValue]?.bool == true && !wmoHack {
print("Work around SR-881")
run(task, toolchain: toolchain, wmoHack: true)
run(task: task, toolchain: toolchain, wmoHack: true)
}
}
......@@ -483,5 +483,5 @@ private func copyByOverwriting(fromPath: String, toPath: String) throws {
if manager.fileExists(atPath: toPath) {
try manager.removeItem(atPath: toPath)
}
try! manager.copyItemAtPath_SWIFTBUG(fromPath, toPath: toPath)
try! manager.copyItemAtPath_SWIFTBUG(srcPath: fromPath, toPath: toPath)
}
\ No newline at end of file
......@@ -31,8 +31,9 @@ echo "****************COLLECT SOURCES TEST**************"
cd $DIR/tests/fixtures/collect_sources
$ATBUILD collect-sources 2&> /tmp/sources.txt
if ! grep "sources src/a.swift src/b.swift" /tmp/sources.txt; then
echo "Unexpected sources $COLLECT_SOURCES"
if ! grep "sources src/b.swift src/a.swift" /tmp/sources.txt; then
exit 1
fi
fi
echo "****************DYNAMIC LIBRARY TEST**************"
......
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