Commit 1af94907 authored by Johannes Schriewer's avatar Johannes Schriewer

Update atfoundation, use operator overloads for path joining

parent 72168af5
Pipeline #1654 failed with stage
......@@ -46,7 +46,7 @@ enum Options: String {
}
}
let defaultPackageFile = Path(string: "build.atpkg")
let defaultPackageFile = Path("build.atpkg")
var focusOnTask : String? = nil
......@@ -54,7 +54,7 @@ var packageFile = defaultPackageFile
var toolchain = Platform.buildPlatform.defaultToolchainPath
for (i, x) in Process.arguments.enumerated() {
if x == Options.CustomFile.rawValue {
packageFile = Path(string: Process.arguments[i+1])
packageFile = Path(Process.arguments[i+1])
}
if x == Options.Toolchain.rawValue {
toolchain = Process.arguments[i+1]
......
Subproject commit 9a6d4437013e7577b998c096bbbb2b8eb28b1a6c
Subproject commit 82283da76054b51328d82648cfb2a5a7a582325a
......@@ -62,16 +62,16 @@ class PackageFramework: Tool {
}
//rm framework if it exists
let frameworkPath = Path(string: "bin/\(name).framework")
let frameworkPath = Path("bin/\(name).framework")
let _ = try? FS.removeItem(path: frameworkPath)
try! FS.createDirectory(path: frameworkPath)
//'a' version
let relativeAVersionPath = Path(string: "Versions/A")
let AVersionPath = frameworkPath.join(path: relativeAVersionPath)
let relativeAVersionPath = Path("Versions/A")
let AVersionPath = frameworkPath + relativeAVersionPath
try! FS.createDirectory(path: AVersionPath, intermediate: true)
//'current' (produces code signing failures if absent)
try! FS.symlinkItem(from: frameworkPath.join(path: Path(string: "Versions/Current")), to: Path(string: "A"))
try! FS.symlinkItem(from: frameworkPath + "Versions/Current", to: Path("A"))
//copy payload
let payloadPath = task.importedPath.appending("bin").appending(name + Platform.targetPlatform.dynamicLibraryExtension)
......@@ -82,17 +82,17 @@ class PackageFramework: Tool {
//copy modules
let modulePath = AVersionPath.appending("Modules").appending(name + ".swiftmodule")
try! FS.createDirectory(path: modulePath, intermediate: true)
try! FS.copyItem(from: Path(string: "bin/\(name).swiftmodule"), to: modulePath.appending(Platform.targetPlatform.architecture + ".swiftmodule"))
try! FS.copyItem(from: Path(string: "bin/\(name).swiftdoc"), to: modulePath.appending(Platform.targetPlatform.architecture + ".swiftdoc"))
try! FS.copyItem(from: Path("bin/\(name).swiftmodule"), to: modulePath.appending(Platform.targetPlatform.architecture + ".swiftmodule"))
try! FS.copyItem(from: Path("bin/\(name).swiftdoc"), to: modulePath.appending(Platform.targetPlatform.architecture + ".swiftdoc"))
try! FS.symlinkItem(from: frameworkPath.appending("Modules"), to: relativeAVersionPath.appending("Modules"))
//copy resources
let resourcesPath = AVersionPath.appending("Resources")
try! FS.createDirectory(path: resourcesPath, intermediate: true)
for resource in resources {
try! FS.copyItem(from: task.importedPath.join(path: Path(string: resource)), to: resourcesPath.join(path: Path(string: resource)))
try! FS.copyItem(from: task.importedPath + resource, to: resourcesPath + resource)
}
try! FS.symlinkItem(from: frameworkPath.appending("Resources"), to: relativeAVersionPath.appending("Resources"))
try! FS.symlinkItem(from: frameworkPath + "Resources", to: relativeAVersionPath + "Resources")
//codesign
let cmd = "codesign --force --deep --sign - --timestamp=none '\(AVersionPath)'"
......
......@@ -108,23 +108,23 @@ func findToolPath(toolName: String, toolchain: String) -> Path {
if Platform.buildPlatform == Platform.hostPlatform {
//poke around on the filesystem
//look in /usr/bin
let usrBin = Path(string: "\(toolchain)/usr/bin/\(toolName)")
let usrBin = Path("\(toolchain)/usr/bin/\(toolName)")
if FS.fileExists(path: usrBin) { return usrBin }
//look in /usr/local/bin
let usrLocalBin = Path(string: "\(toolchain)/usr/local/bin/\(toolName)")
let usrLocalBin = Path("\(toolchain)/usr/local/bin/\(toolName)")
if FS.fileExists(path: usrLocalBin) { return usrLocalBin }
//swift-build-tool isn't available in 2.2.
//If we're looking for SBT, try in the default location
if toolName == "swift-build-tool" {
let sbtPath = Path(string: "\(Platform.hostPlatform.defaultToolchainPath)/usr/bin/\(toolName)")
let sbtPath = Path("\(Platform.hostPlatform.defaultToolchainPath)/usr/bin/\(toolName)")
if FS.fileExists(path: sbtPath) { return sbtPath }
}
}
else {
//file system isn't live; hope the path is in a typical place
return Path(string: "\(Platform.buildPlatform.defaultToolchainBinaryPath)\(toolName)")
return Path("\(Platform.buildPlatform.defaultToolchainBinaryPath)\(toolName)")
}
fatalError("Can't find a path for \(toolName)")
......
......@@ -28,9 +28,9 @@ class XCTestRun : Tool {
case .OSX:
let workingDirectory = try! FS.temporaryDirectory(prefix: "XCTest-\(task)")
let executablePath = workingDirectory.join(path: Path(string: "XCTestRun.xctest/Contents/MacOS"))
let executablePath = workingDirectory + "XCTestRun.xctest/Contents/MacOS"
try! FS.createDirectory(path: executablePath, intermediate: true)
try! FS.copyItem(from: Path(string: testExecutable), to: executablePath.appending("XCTestRun"))
try! FS.copyItem(from: Path(testExecutable), to: executablePath.appending("XCTestRun"))
var s = ""
s += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
s += "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
......@@ -60,7 +60,7 @@ class XCTestRun : Tool {
s += "<string>1</string>\n"
s += "</dict>\n"
s += "</plist>\n"
try! s.write(to: workingDirectory.join(path: Path(string: "XCTestRun.xctest/Contents/Info.plist")))
try! s.write(to: workingDirectory + "XCTestRun.xctest/Contents/Info.plist")
anarchySystem("xcrun xctest \(workingDirectory)/XCTestRun.xctest")
case .Linux:
......
......@@ -135,7 +135,7 @@ final class ATllbuild : Tool {
//this crazy syntax is how sbt declares a dependency
var llbuild_inputs = ["<atllbuild-swiftc>"]
llbuild_inputs += objects
let builtProducts = linkWithProduct.map { workdir.join(path: Path(string: "products/"+$0)).description }
let builtProducts = linkWithProduct.map { (workdir + ("products/"+$0)).description }
llbuild_inputs += builtProducts
let executablePath = productPath.appending(modulename)
yaml += " inputs: \(llbuild_inputs)\n"
......@@ -172,7 +172,7 @@ final class ATllbuild : Tool {
yaml += " tool: shell\n"
var llbuild_inputs = ["<atllbuild-swiftc>"]
llbuild_inputs += objects
let builtProducts = linkWithProduct.map { workdir.join(path: Path(string: "products/"+$0)).description }
let builtProducts = linkWithProduct.map { (workdir + ("products/"+$0)).description }
llbuild_inputs += builtProducts
yaml += " inputs: \(llbuild_inputs)\n"
let libPath = productPath.appending(modulename + Platform.targetPlatform.dynamicLibraryExtension)
......@@ -252,7 +252,7 @@ final class ATllbuild : Tool {
}
//create the working directory
let workDirectory = Path(string: ".atllbuild")
let workDirectory = Path(".atllbuild")
//NSFileManager is pretty anal about throwing errors if we try to remove something that doesn't exist, etc.
//We just want to create a state where .atllbuild/objects and .atllbuild/llbuildtmp and .atllbuild/products exists.
......@@ -316,7 +316,7 @@ final class ATllbuild : Tool {
for path_s in includePaths {
guard let path = path_s.string else { fatalError("Non-string path \(path_s)") }
compileOptions.append("-I")
compileOptions.append(userPath().join(path: Path(string: path)).description)
compileOptions.append((userPath() + path).description)
}
}
var linkOptions: [String] = []
......@@ -330,13 +330,13 @@ final class ATllbuild : Tool {
//check for modulemaps
for product in linkWithProduct {
let productName = product.split(character: ".")[0]
let moduleMapPath = workDirectory.join(path: Path(string: "products/\(productName).modulemap"))
let moduleMapPath = workDirectory + "products/\(productName).modulemap"
if FS.fileExists(path: moduleMapPath) {
/*per http://clang.llvm.org/docs/Modules.html#command-line-parameters, pretty much
the only way to do this is to create a file called `module.modulemap`. That
potentially conflicts with other modulemaps, so we give it its own directory, namespaced
by the product name. */
let pathName = workDirectory.join(path: Path(string: "include/\(productName)"))
let pathName = workDirectory + "include/\(productName)"
try! FS.createDirectory(path: pathName)
try! FS.copyItem(from: moduleMapPath, to: pathName.appending("module.modulemap"))
compileOptions.append(contentsOf: ["-I", pathName.description])
......@@ -395,8 +395,8 @@ final class ATllbuild : Tool {
if let umbrellaHeader = task[Options.UmbrellaHeader.rawValue]?.string {
precondition(moduleMap == .Synthesized, ":\(Options.ModuleMap.rawValue) \"synthesized\" must be used with the \(Options.UmbrellaHeader.rawValue) option")
let s = synthesizeModuleMap(name: name, umbrellaHeader: "Umbrella.h")
try! s.write(to: workDirectory.join(path: Path(string: "include/module.modulemap")))
try! FS.copyItem(from: task.importedPath.join(path: Path(string: umbrellaHeader)), to: workDirectory.join(path: Path(string: "include/Umbrella.h")))
try! s.write(to: workDirectory + "include/module.modulemap")
try! FS.copyItem(from: task.importedPath + umbrellaHeader, to: workDirectory + "include/Umbrella.h")
compileOptions.append("-I")
compileOptions.append(workDirectory.appending("include").description + "/")
compileOptions.append("-import-underlying-module")
......@@ -425,7 +425,7 @@ final class ATllbuild : Tool {
let llbuildyamlpath : Path
if let value = task[Options.llBuildYaml.rawValue]?.string {
llbuildyamlpath = Path(string: value)
llbuildyamlpath = Path(value)
}
else {
llbuildyamlpath = workDirectory.appending("llbuild.yaml")
......@@ -433,7 +433,7 @@ final class ATllbuild : Tool {
let swiftCPath: Path
if let c = task[Options.SwiftCPath.rawValue]?.string {
print("Warning: \(Options.SwiftCPath.rawValue) is deprecated and will be removed in a future release of atbuild. Use --toolchain to specify a different toolchain, or --platform when bootstrapping to a different platform.")
swiftCPath = Path(string: c)
swiftCPath = Path(c)
}
else {
swiftCPath = findToolPath(toolName: "swiftc", toolchain: toolchain)
......@@ -448,31 +448,31 @@ final class ATllbuild : Tool {
break
case .Synthesized:
let s = synthesizeModuleMap(name: name, umbrellaHeader: nil)
try! s.write(to: workDirectory.join(path: Path(string: "products/\(name).modulemap")))
try! s.write(to: workDirectory + "products/\(name).modulemap")
}
//SR-566
let cmd = "\(findToolPath(toolName: "swift-build-tool",toolchain: toolchain)) -f \(llbuildyamlpath)"
anarchySystem(cmd)
if task[Options.PublishProduct.rawValue]?.bool == true {
if !FS.isDirectory(path: Path(string: "bin")) {
try! FS.createDirectory(path: Path(string: "bin"))
if !FS.isDirectory(path: Path("bin")) {
try! FS.createDirectory(path: Path("bin"))
}
try! FS.copyItem(from: workDirectory.join(path: Path(string: "products/\(name).swiftmodule")), to: Path(string: "bin/\(name).swiftmodule"))
try! FS.copyItem(from: workDirectory.join(path: Path(string: "products/\(name).swiftdoc")), to: Path(string: "bin/\(name).swiftdoc"))
try! FS.copyItem(from: workDirectory + "products/\(name).swiftmodule", to: Path("bin/\(name).swiftmodule"))
try! FS.copyItem(from: workDirectory + "products/\(name).swiftdoc", to: Path("bin/\(name).swiftdoc"))
switch outputType {
case .Executable:
try! FS.copyItem(from: workDirectory.join(path: Path(string: "products/\(name)")), to: Path(string: "bin/\(name)"))
try! FS.copyItem(from: workDirectory + "products/\(name)", to: Path("bin/\(name)"))
case .StaticLibrary:
try! FS.copyItem(from: workDirectory.join(path: Path(string: "products/\(name).a")), to: Path(string: "bin/\(name).a"))
try! FS.copyItem(from: workDirectory + "products/\(name).a", to: Path("bin/\(name).a"))
case .DynamicLibrary:
try! FS.copyItem(from: workDirectory.join(path: Path(string: "products/\(name)." + Platform.targetPlatform.dynamicLibraryExtension)) , to: Path(string: "bin/\(name)." + Platform.targetPlatform.dynamicLibraryExtension))
try! FS.copyItem(from: workDirectory + ("products/\(name)." + Platform.targetPlatform.dynamicLibraryExtension) , to: Path("bin/\(name)." + Platform.targetPlatform.dynamicLibraryExtension))
}
switch moduleMap {
case .None:
break
case .Synthesized:
try! FS.copyItem(from: workDirectory.join(path: Path(string: "products/\(name).modulemap")), to: Path(string: "bin/\(name).modulemap"))
try! FS.copyItem(from: workDirectory + "products/\(name).modulemap", to: Path("bin/\(name).modulemap"))
}
}
......
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