Commit 10896a07 authored by Drew's avatar Drew

Linux port

parent 573176c4
Pipeline #720 failed with stage
FROM drewcrawford/swift:latest
ADD . /atbuild
WORKDIR atbuild
RUN bootstrap/build.sh linux
\ No newline at end of file
RUN bootstrap/build.sh linux
RUN bin/atbuild atbuild
\ No newline at end of file
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//SR-138
#if os(Linux)
extension String {
@warn_unused_result
public func substringFromIndex(index: Index) -> String {
return self.bridge().substringFromIndex(index._utf16Index)
}
}
#endif
......@@ -18,6 +18,12 @@ import Foundation
import atpkg
import attools
#if os(Linux)
//we need to get exit somehow
//https://bugs.swift.org/browse/SR-567
import Glibc
#endif
let defaultBuildFile = "build.atpkg"
func loadPackageFile() -> Package {
......
Subproject commit eb09cb50c7c551bf736028f9136bb058bcff5442
Subproject commit af99b66c84d3a52a015615ce3e29b4c5097df8bc
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import Foundation
//SR-138
extension String {
var toNSString: NSString {
#if os(Linux)
return self.bridge()
#elseif os(OSX)
return (self as NSString)
#endif
}
#if os(Linux)
func writeToFile(path: String, atomically useAuxiliaryFile: Bool, encoding enc: NSStringEncoding) throws {
try self.toNSString.writeToFile(path, atomically: useAuxiliaryFile, encoding: enc)
}
#endif
}
extension NSString {
var toString: String {
#if os(Linux)
return self.bridge()
#elseif os(OSX)
return (self as String)
#endif
}
}
\ No newline at end of file
......@@ -19,4 +19,7 @@ import Foundation
let SDKPath = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"
let SwiftCPath = "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc"
let SwiftBuildToolpath = "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift-build-tool"
#elseif os(Linux)
let SwiftCPath = "/usr/local/bin/swiftc"
let SwiftBuildToolpath = "/usr/local/bin/swift-build-tool"
#endif
\ No newline at end of file
......@@ -15,6 +15,10 @@
import Foundation
import atpkg
#if os(Linux)
import Glibc //need sleep
#endif
/**The ATllbuild tool builds a swift module via llbuild.
For more information on this tool, see `docs/attllbuild.md` */
final class ATllbuild : Tool {
......@@ -54,7 +58,7 @@ final class ATllbuild : Tool {
//swiftPM wants "objects" which is just a list of %.swift.o files. We have to put them in a temp directory though.
let objects = sources.map { (source) -> String in
workdir + "objects/" + (source as NSString).lastPathComponent + ".o"
workdir + "objects/" + source.toNSString.lastPathComponent + ".o"
}
yaml += " objects: \(objects)\n"
//this crazy syntax is how llbuild specifies outputs
......@@ -78,7 +82,9 @@ final class ATllbuild : Tool {
args.appendContentsOf(["-j8", "-D","ATBUILD","-I",workdir+"products/"])
if linkSDK {
#if os(OSX) //we don't have SDKPath on linux
args.appendContentsOf(["-sdk", SDKPath])
#endif
}
args.appendContentsOf(compileOptions)
......@@ -208,12 +214,10 @@ final class ATllbuild : Tool {
let _ = try? yaml.writeToFile(llbuildyamlpath, atomically: false, encoding: NSUTF8StringEncoding)
if bootstrapOnly { return }
//now we try running sbt
let args = ["-f", llbuildyamlpath]
let sbt = NSTask.launchedTaskWithLaunchPath(SwiftBuildToolpath, arguments: args)
sbt.waitUntilExit()
if sbt.terminationStatus != 0 {
fatalError("\(SwiftBuildToolpath) " + args.joinWithSeparator(" "))
//SR-566
let cmd = "\(SwiftBuildToolpath) -f \(llbuildyamlpath)"
if system(cmd) != 0 {
fatalError(cmd)
}
}
}
\ No newline at end of file
client:
name: swift-build
tools: {}
targets:
"": [<atllbuild>]
atllbuild: [<atllbuild>]
commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/usr/local/bin/swiftc"
inputs: ["atpkg/src/CollectSources.swift", "atpkg/src/ICantBelieveItsNotFoundation.swift", "atpkg/src/Package.swift", "atpkg/src/parsing/Parser.swift", "atpkg/src/parsing/Scanner.swift", "atpkg/src/parsing/Tokenization.swift", "atpkg/src/PathWithTrailingSlash.swift"]
sources: ["atpkg/src/CollectSources.swift", "atpkg/src/ICantBelieveItsNotFoundation.swift", "atpkg/src/Package.swift", "atpkg/src/parsing/Parser.swift", "atpkg/src/parsing/Scanner.swift", "atpkg/src/parsing/Tokenization.swift", "atpkg/src/PathWithTrailingSlash.swift"]
objects: [".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/PathWithTrailingSlash.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/PathWithTrailingSlash.swift.o"]
is-library: true
module-name: atpkg
module-output-path: .atllbuild/products/atpkg.swiftmodule
temps-path: .atllbuild//llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/PathWithTrailingSlash.swift.o"]
outputs: ["<atllbuild>", ".atllbuild/products/atpkg.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/atpkg.a; ar cr '.atllbuild/products/atpkg.a' '.atllbuild/objects/CollectSources.swift.o' '.atllbuild/objects/ICantBelieveItsNotFoundation.swift.o' '.atllbuild/objects/Package.swift.o' '.atllbuild/objects/Parser.swift.o' '.atllbuild/objects/Scanner.swift.o' '.atllbuild/objects/Tokenization.swift.o' '.atllbuild/objects/PathWithTrailingSlash.swift.o']
description: "Linking Library: .atllbuild/products/atpkg.a"
\ No newline at end of file
client:
name: swift-build
tools: {}
targets:
"": [<atllbuild>]
atllbuild: [<atllbuild>]
commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/usr/local/bin/swiftc"
inputs: ["attools/src/atllbuild.swift", "attools/src/ICantBelieveItsNotFoundation.swift", "attools/src/Nop.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift"]
sources: ["attools/src/atllbuild.swift", "attools/src/ICantBelieveItsNotFoundation.swift", "attools/src/Nop.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift"]
objects: [".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/Nop.swift.o", ".atllbuild/objects/PlatformPaths.swift.o", ".atllbuild/objects/Shell.swift.o", ".atllbuild/objects/TaskRunner.swift.o", ".atllbuild/objects/Tools.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/Nop.swift.o", ".atllbuild/objects/PlatformPaths.swift.o", ".atllbuild/objects/Shell.swift.o", ".atllbuild/objects/TaskRunner.swift.o", ".atllbuild/objects/Tools.swift.o"]
is-library: true
module-name: attools
module-output-path: .atllbuild/products/attools.swiftmodule
temps-path: .atllbuild//llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/Nop.swift.o", ".atllbuild/objects/PlatformPaths.swift.o", ".atllbuild/objects/Shell.swift.o", ".atllbuild/objects/TaskRunner.swift.o", ".atllbuild/objects/Tools.swift.o"]
outputs: ["<atllbuild>", ".atllbuild/products/attools.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/attools.a; ar cr '.atllbuild/products/attools.a' '.atllbuild/objects/atllbuild.swift.o' '.atllbuild/objects/ICantBelieveItsNotFoundation.swift.o' '.atllbuild/objects/Nop.swift.o' '.atllbuild/objects/PlatformPaths.swift.o' '.atllbuild/objects/Shell.swift.o' '.atllbuild/objects/TaskRunner.swift.o' '.atllbuild/objects/Tools.swift.o']
description: "Linking Library: .atllbuild/products/attools.a"
\ No newline at end of file
......@@ -10,17 +10,17 @@ commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/usr/local/bin/swiftc"
inputs: ["atbuild/src/main.swift"]
sources: ["atbuild/src/main.swift"]
objects: [".atllbuild/objects/main.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o"]
inputs: ["atbuild/src/ICantBelieveItsNotFoundation.swift", "atbuild/src/main.swift"]
sources: ["atbuild/src/ICantBelieveItsNotFoundation.swift", "atbuild/src/main.swift"]
objects: [".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/main.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/main.swift.o"]
module-name: atbuild
module-output-path: .atllbuild/products/atbuild.swiftmodule
temps-path: .atllbuild//llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"]
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a"]
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a"]
outputs: ["<atllbuild>", ".atllbuild/products/atbuild"]
args: ["/usr/local/bin/swiftc", "-o", ".atllbuild/products/atbuild", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a"]
args: ["/usr/local/bin/swiftc", "-o", ".atllbuild/products/atbuild", ".atllbuild/objects/ICantBelieveItsNotFoundation.swift.o", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a"]
description: Linking executable .atllbuild/products/atbuild
......@@ -35,13 +35,14 @@
:bootstrapOnly true
:llbuildyaml "bootstrap/bootstrap-linux-attools.swift-build"
:swiftCPath "/usr/local/bin/swiftc"
:linkSDK false
}
:atbuild {
:bootstrapOnly true
:llbuildyaml "bootstrap/bootstrap-linux.swift-build"
:swiftCPath "/usr/local/bin/swiftc"
:linkSDK false
}
}
}
......
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