diff --git a/ScriptWorker.xcodeproj/project.pbxproj b/ScriptWorker.xcodeproj/project.pbxproj
index 926cea8..4e2d04e 100644
--- a/ScriptWorker.xcodeproj/project.pbxproj
+++ b/ScriptWorker.xcodeproj/project.pbxproj
@@ -379,16 +379,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
- LastUpgradeCheck = 0800;
+ LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Stephen Marquis";
TargetAttributes = {
AA514C971D6900BE00D563F2 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0830;
+ LastSwiftMigration = 0930;
};
AA514CA11D6900BE00D563F2 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0800;
+ LastSwiftMigration = 0930;
};
AA514CC81D6927C500D563F2 = {
CreatedOnToolsVersion = 7.3.1;
@@ -396,6 +396,7 @@
};
B15A76B81E9558EF00AEABA3 = {
CreatedOnToolsVersion = 8.2.1;
+ LastSwiftMigration = 0930;
ProvisioningStyle = Automatic;
};
B15A76D91E959C9A00AEABA3 = {
@@ -404,6 +405,7 @@
};
B1D5BD511DF2219000E93D97 = {
CreatedOnToolsVersion = 8.1;
+ LastSwiftMigration = 0930;
ProvisioningStyle = Automatic;
};
};
@@ -558,14 +560,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -609,14 +619,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -663,7 +681,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -685,7 +703,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.BobDevil.ScriptWorker;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -697,6 +715,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.BobDevil.ScriptWorkerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -708,6 +727,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.BobDevil.ScriptWorkerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -743,7 +763,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -753,7 +773,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -792,7 +812,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -802,7 +822,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/ScriptWorker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ScriptWorker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/ScriptWorker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/ScriptWorker.xcodeproj/xcshareddata/xcschemes/ScriptWorker.xcscheme b/ScriptWorker.xcodeproj/xcshareddata/xcschemes/ScriptWorker.xcscheme
index 9bd5d3e..1b536d8 100644
--- a/ScriptWorker.xcodeproj/xcshareddata/xcschemes/ScriptWorker.xcscheme
+++ b/ScriptWorker.xcodeproj/xcshareddata/xcschemes/ScriptWorker.xcscheme
@@ -1,6 +1,6 @@
((Void) -> Void) {
+ private func setup(pipe: Pipe, stdout: Bool) -> (() -> Void) {
let readHandle = pipe.fileHandleForReading
let semaphore = DispatchSemaphore(value: 1)
@@ -260,7 +260,8 @@ public class ScriptTask {
semaphore.signal()
}
- return { [weak self] in
+ return {
+ [weak self] in
// The 'readabilityHandler' for a file handle doesn't get triggered for EOF for whatever reason, so we clear out the readability handler and read the last available data when the task is done.
semaphore.wait()
readHandle.readabilityHandler = nil
diff --git a/ScriptWorker/trap.swift b/ScriptWorker/trap.swift
index 65ba5bc..1ce8f76 100755
--- a/ScriptWorker/trap.swift
+++ b/ScriptWorker/trap.swift
@@ -12,7 +12,7 @@ enum Signal: Int32 {
case TERM = 15
}
-func trap(signal: Signal, action: @convention(c) (Int32) -> ()) {
+func trap(signal: Signal, action: @escaping @convention(c) (Int32) -> ()) {
// From Swift, sigaction.init() collides with the Darwin.sigaction() function.
// This local typealias allows us to disambiguate them.
typealias SignalAction = sigaction
diff --git a/swiftscript/SwiftScript.swift b/swiftscript/SwiftScript.swift
index 3d78bed..3b8c4f0 100644
--- a/swiftscript/SwiftScript.swift
+++ b/swiftscript/SwiftScript.swift
@@ -23,7 +23,7 @@ class SwiftScript {
return nil
}
- var path = trimmedLine.substring(from: range.upperBound).trimmingCharacters(in: .whitespaces)
+ var path = String(trimmedLine[range.upperBound...]).trimmingCharacters(in: .whitespaces)
path = (path as NSString).expandingTildeInPath
let url: URL
if (path as NSString).isAbsolutePath {
diff --git a/swiftscript/main.swift b/swiftscript/main.swift
index c9cd650..0dbcf6a 100644
--- a/swiftscript/main.swift
+++ b/swiftscript/main.swift
@@ -38,28 +38,33 @@ func runExec(task: String, args: [String], overrideExecutablePath: String? = nil
// Returns the path to the executable in the temporary directory
func setup(file: URL, withAdditionalFiles additionalFiles: [URL], searchPaths: [URL]) -> URL {
let workingDirectoryTemplate = NSTemporaryDirectory() + "/swiftscript-XXX"
- guard let cstring = mkdtemp(UnsafeMutablePointer(mutating: workingDirectoryTemplate.cString(using: .utf8))) else {
- print("Failed to create temporary directory for compilation: errno \(errno)")
- exit(1)
- }
-
- let workingDirectory = URL(fileURLWithPath: String(cString: cstring))
- let swiftFiles = SwiftScript.swiftURLs(for: additionalFiles)
+ print("working dir template = \(workingDirectoryTemplate)")
- let (mainFile, compiledFiles) = SwiftScript.setup(workingDirectory: workingDirectory, for: file, with: swiftFiles)
+ return workingDirectoryTemplate.withCString { workingDirCString in
+ guard let cstring = mkdtemp(UnsafeMutablePointer(mutating:workingDirCString)) else {
+ print("Failed to create temporary directory for compilation: errno \(errno)")
+ exit(1)
+ }
+
+ let workingDirectory = URL(fileURLWithPath: String(cString: cstring))
- let process = Process()
- process.launchPath = "/usr/bin/xcrun"
+ let swiftFiles = SwiftScript.swiftURLs(for: additionalFiles)
- let executableURL = workingDirectory.appendingPathComponent(file.deletingPathExtension().lastPathComponent)
+ let (mainFile, compiledFiles) = SwiftScript.setup(workingDirectory: workingDirectory, for: file, with: swiftFiles)
- let args = ["swiftc", "-o", executableURL.path] + SwiftScript.swiftArguments(for: mainFile, additionalFiles: compiledFiles, searchPaths: searchPaths)
- process.arguments = args
- process.launch()
- process.waitUntilExit()
+ let process = Process()
+ process.launchPath = "/usr/bin/xcrun"
+
+ let executableURL = workingDirectory.appendingPathComponent(file.deletingPathExtension().lastPathComponent)
+
+ let args = ["swiftc", "-o", executableURL.path] + SwiftScript.swiftArguments(for: mainFile, additionalFiles: compiledFiles, searchPaths: searchPaths)
+ process.arguments = args
+ process.launch()
+ process.waitUntilExit()
- return executableURL
+ return executableURL
+ }
}
guard CommandLine.arguments.count >= 2 else {