Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that familiar with manifests. Why is conditional compilation needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 AFAIK this is used to comfort SwiftPM 5.3 because it doesn't recognize Windows. This workaround is introduced by @compnerd for other projects and I just use it here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this would be needed given the comment below.


let targets: [Target] = [
.target(
name: "SystemPackage",
dependencies: ["CSystem"],
path: "Sources/System",
cSettings: [
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: windowsPlatform)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this unconditionally, it won't impact other targets. Alternatively, we could clean up the cases to use the Microsoft "extensions" (technically I believe that they are part of Annex G, so they should be portable).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. Fixed

],
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