Commit af99b66c authored by Drew's avatar Drew

Linux port

parent eb09cb50
Pipeline #719 passed with stage
......@@ -29,6 +29,7 @@
:bootstrapOnly true
:llbuildyaml "bootstrap/bootstrap-linux-atpkg.swift-build"
:swiftCPath "/usr/local/bin/swiftc"
:linkSDK false
}
}
}
......
......@@ -24,10 +24,11 @@ public func collectSources(sourceDescriptions: [String], task: Task) -> [String]
if description.hasSuffix("**.swift") {
let basepath = String(Array(description.characters)[0..<description.characters.count - 9])
let manager = NSFileManager.defaultManager()
guard let enumerator = manager.enumeratorAtPath(basepath) else {
guard let enumerator = ICantBelieveItsNotFoundation_enumeratorAtPath(basepath) else {
fatalError("Invalid path \(basepath)")
}
while let source = enumerator.nextObject() as? String {
while let source_ns = enumerator.nextObject() as? NSString {
let source = source_ns.toString
if source.hasSuffix("swift") {
sources.append(basepath + "/" + source)
}
......
// 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)
public func stringByReplacingOccurrencesOfString(target: String, withString replacement: String) -> String {
return self.bridge().stringByReplacingOccurrencesOfString(target, withString: replacement)
}
#endif
}
extension NSString {
var toString: String {
#if os(Linux)
return self.bridge()
#elseif os(OSX)
return (self as String)
#endif
}
}
//enumeratorAtPath isn't implemented
class ICantBelieveItsNotNSDirectoryEnumerator {
let baseURL: NSURL
let innerEnumerator : NSDirectoryEnumerator
var fileAttributes: [String : AnyObject]? {
fatalError("Not implemented")
}
var directoryAttributes: [String : AnyObject]? {
fatalError("Not implemented")
}
/* This method returns the number of levels deep the current object is in the directory hierarchy being enumerated. The directory passed to -enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: is considered to be level 0.
*/
var level: Int {
fatalError("Not implemented")
}
func skipDescendants() {
fatalError("Not implemented")
}
init?(path: String) {
let url = NSURL(fileURLWithPath: path)
self.baseURL = url
guard let ie = NSFileManager.defaultManager().enumeratorAtURL(url, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions(), errorHandler: nil) else {
return nil
}
self.innerEnumerator = ie
}
func nextObject() -> AnyObject? {
let o = innerEnumerator.nextObject()
guard let url = o as? NSURL else {
return nil
}
let path = url.path!.stringByReplacingOccurrencesOfString(baseURL.path!+"/", withString: "")
return NSString(string: path)
}
}
func ICantBelieveItsNotFoundation_enumeratorAtPath(path: String) -> ICantBelieveItsNotNSDirectoryEnumerator? {
return ICantBelieveItsNotNSDirectoryEnumerator(path: path)
}
......@@ -77,7 +77,7 @@ final public class Package {
do {
let result = try parser.parse()
let basepath = (filepath as NSString).stringByDeletingLastPathComponent
let basepath = filepath.toNSString.stringByDeletingLastPathComponent
self.init(type: result, configurations: configurations, pathOnDisk:basepath)
}
catch {
......@@ -136,8 +136,8 @@ final public class Package {
if let imports = type.properties["import"]?.vector {
for importFile in imports {
guard let importFileString = importFile.string else { fatalError("Non-string import \(importFile)")}
let adjustedImportPath = (pathOnDisk.pathWithTrailingSlash + importFileString as NSString).stringByDeletingLastPathComponent.pathWithTrailingSlash
let adjustedFileName = (importFileString as NSString).lastPathComponent
let adjustedImportPath = (pathOnDisk.pathWithTrailingSlash + importFileString).toNSString.stringByDeletingLastPathComponent.pathWithTrailingSlash
let adjustedFileName = importFileString.toNSString.lastPathComponent
guard let remotePackage = Package(filepath: adjustedImportPath + adjustedFileName, configurations: configurations) else {
fatalError("Can't load remote package \(adjustedImportPath + adjustedFileName)")
}
......
......@@ -85,7 +85,7 @@ final public class Parser {
return nil
}
let scanner = Scanner(content: content as String)
let scanner = Scanner(content: content.toString)
self.lexer = Lexer(scanner: scanner)
}
......
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