Skip to content

Fix build on Windows #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/SwiftDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ add_library(SwiftDriver

target_link_libraries(SwiftDriver PUBLIC
TSCBasic
TSCUtility
SwiftOptions
llbuildSwift
CYaml
Expand All @@ -87,3 +88,9 @@ set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftDriver)
set_target_properties(SwiftDriver PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
install(TARGETS SwiftDriver
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
endif()
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Driver/ToolExecutionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ public struct ToolExecutionDelegate: JobExecutionDelegate {
let finishedMessage = FinishedMessage(exitStatus: Int(code), pid: pid, output: output)
message = ParsableMessage(name: job.kind.rawValue, kind: .finished(finishedMessage))

#if !os(Windows)
case .signalled(let signal):
let errorMessage = strsignal(signal).map { String(cString: $0) } ?? ""
let signalledMessage = SignalledMessage(pid: pid, output: output, errorMessage: errorMessage, signal: Int(signal))
message = ParsableMessage(name: job.kind.rawValue, kind: .signalled(signalledMessage))
#endif
}
emit(message)
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Execution/DriverExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ extension DriverExecutor {
switch result.exitStatus {
case .terminated(let code):
returnCode = Int(code)
#if !os(Windows)
case .signalled(let signal):
returnCode = Int(signal)
#endif
}
throw JobExecutionError.jobFailedWithNonzeroExitCode(returnCode, try result.utf8stderrOutput())
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Execution/MultiJobExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,10 @@ class ExecuteJobRule: LLBuildRule {
if !job.kind.isCompile || code != EXIT_FAILURE {
context.diagnosticsEngine.emit(.error_command_failed(kind: job.kind, code: code))
}
#if !os(Windows)
case let .signalled(signal):
context.diagnosticsEngine.emit(.error_command_signalled(kind: job.kind, signal: signal))
#endif
}
}

Expand Down
7 changes: 7 additions & 0 deletions Sources/SwiftOptions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftOptions)
# NOTE: workaround for CMake not setting up include flags yet
set_target_properties(SwiftOptions PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
install(TARGETS SwiftOptions
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
endif()