Skip to content

Commit

Permalink
Fix building on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Jun 8, 2021
1 parent 2bc160b commit d9ef817
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@

import PackageDescription

let targets: [PackageDescription.Target] = [
var windowsPlatform: [Platform] = []
#if os(Windows)
windowsPlatform.append(.windows)
#endif

let targets: [Target] = [
.target(
name: "SystemPackage",
dependencies: ["CSystem"],
path: "Sources/System",
cSettings: [
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: windowsPlatform)),
],
swiftSettings: [
.define("SYSTEM_PACKAGE"),
.define("ENABLE_MOCKING", .when(configuration: .debug))
Expand Down
8 changes: 4 additions & 4 deletions Sources/System/Internals/Mocking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private func originalSyscallName(_ function: String) -> String {

private func mockImpl(
name: String,
path: UnsafePointer<CChar>?,
path: UnsafePointer<CInterop.PlatformChar>?,
_ args: [AnyHashable]
) -> CInt {
precondition(mockingEnabled)
Expand Down Expand Up @@ -177,18 +177,18 @@ private func mockImpl(
}

internal func _mock(
name: String = #function, path: UnsafePointer<CChar>? = nil, _ args: AnyHashable...
name: String = #function, path: UnsafePointer<CInterop.PlatformChar>? = nil, _ args: AnyHashable...
) -> CInt {
return mockImpl(name: name, path: path, args)
}
internal func _mockInt(
name: String = #function, path: UnsafePointer<CChar>? = nil, _ args: AnyHashable...
name: String = #function, path: UnsafePointer<CInterop.PlatformChar>? = nil, _ args: AnyHashable...
) -> Int {
Int(mockImpl(name: name, path: path, args))
}

internal func _mockOffT(
name: String = #function, path: UnsafePointer<CChar>? = nil, _ args: AnyHashable...
name: String = #function, path: UnsafePointer<CInterop.PlatformChar>? = nil, _ args: AnyHashable...
) -> _COffT {
_COffT(mockImpl(name: name, path: path, args))
}
Expand Down

0 comments on commit d9ef817

Please sign in to comment.