Skip to content

Commit 3f57061

Browse files
authored
windows CI (#10)
* windows CI * move macros * clean action file
1 parent 37df606 commit 3f57061

File tree

7 files changed

+110
-12
lines changed

7 files changed

+110
-12
lines changed

.github/workflows/swift.yml

+30
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,33 @@ jobs:
3232
run: swift build -v
3333
- name: Run tests
3434
run: swift test -v
35+
36+
build-windows:
37+
38+
runs-on: windows-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: seanmiddleditch/gha-setup-vsdevenv@master
43+
44+
- name: Install swift-DEVELOPMENT-SNAPSHOT-2020-11-17-a
45+
run: |
46+
Install-Binary -Url "https://swift.org/builds/development/windows10/swift-DEVELOPMENT-SNAPSHOT-2020-11-17-a/swift-DEVELOPMENT-SNAPSHOT-2020-11-17-a-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
47+
- name: Set Environment Variables
48+
run: |
49+
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
50+
echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
51+
- name: Adjust Paths
52+
run: |
53+
echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
54+
echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
55+
- name: Install Supporting Files
56+
run: |
57+
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
58+
Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap"
59+
Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes"
60+
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
61+
- name: Build
62+
run: swift build -v
63+
- name: Run tests
64+
run: swift test -v

Sources/Vector2+nosimd.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#if NOSIMD
1010

1111
#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
12-
import Darwin
13-
#else
14-
import Glibc
12+
import Darwin
13+
#elseif os(Linux) || os(Android)
14+
import Glibc
1515
#endif
16+
1617
@frozen
1718
public struct Vector2f {
1819
public var x: Float = 0.0

Sources/Vector3+nosimd.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#if NOSIMD
1010

1111
#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
12-
import Darwin
13-
#else
14-
import Glibc
12+
import Darwin
13+
#elseif os(Linux) || os(Android)
14+
import Glibc
1515
#endif
1616

1717
@frozen

Sources/Vector4+nosimd.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
1111
import Darwin
12-
#else
12+
#elseif os(Linux) || os(Android)
1313
import Glibc
1414
#endif
1515

Sources/easing.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
1010
import Darwin
11-
#else
11+
#elseif os(Linux) || os(Android)
1212
import Glibc
1313
#endif
1414

Sources/platform.swift

+60-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,67 @@
22
// License: https://github.com/SwiftGFX/SwiftMath#license-bsd-2-clause
33
//
44

5-
#if !(os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
6-
5+
#if os(Linux) || os(Android)
76
import Glibc
7+
#elseif os(Windows)
8+
9+
import ucrt
10+
11+
@inline(__always)
12+
internal func sin(_ a: Float) -> Float {
13+
return ucrt.sinf(a)
14+
}
15+
16+
@inline(__always)
17+
internal func sin(_ a: Double) -> Double {
18+
return ucrt.sin(a)
19+
}
20+
21+
@inline(__always)
22+
internal func cos(_ a: Float) -> Float {
23+
return ucrt.cosf(a)
24+
}
25+
26+
@inline(__always)
27+
internal func cos(_ a: Double) -> Double {
28+
return ucrt.cos(a)
29+
}
30+
31+
@inline(__always)
32+
internal func tan(_ a: Float) -> Float {
33+
return ucrt.tanf(a)
34+
}
35+
36+
@inline(__always)
37+
internal func tan(_ a: Double) -> Double {
38+
return ucrt.tan(a)
39+
}
40+
41+
@inline(__always)
42+
internal func sqrtf(_ a: Float) -> Float {
43+
return ucrt.sqrtf(a)
44+
}
45+
46+
@inline(__always)
47+
internal func sqrt(_ a: Float) -> Float {
48+
return ucrt.sqrtf(a)
49+
}
50+
51+
@inline(__always)
52+
internal func sqrt(_ a: Double) -> Double {
53+
return ucrt.sqrt(a)
54+
}
55+
56+
@inline(__always)
57+
internal func powf(_ a: Float, _ b: Float) -> Float {
58+
return ucrt.powf(a, b)
59+
}
60+
61+
#endif
862

63+
64+
#if (os(Linux) || os(Android) || os(Windows))
65+
966
@inline(__always)
1067
internal func __sincospif(_ a: Float, _ sina: inout Float, _ cosa: inout Float) {
1168
sina = sin(a * Float.pi)
@@ -28,7 +85,7 @@ internal func __tanpif(_ a: Float) -> Float {
2885
return tan(a * Float.pi)
2986
}
3087

31-
#else
88+
#elseif (os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
3289

3390
import Darwin
3491

Sources/random.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS))
1212
import Darwin
13-
#else
13+
#elseif os(Linux) || os(Android)
1414
import Glibc
1515
import SwiftGlibc
1616

@@ -21,6 +21,16 @@ internal func arc4random() -> UInt32 {
2121
internal func arc4random_uniform(_ val: UInt32) -> UInt32 {
2222
return UInt32(random()) % val
2323
}
24+
25+
#elseif os(Windows)
26+
27+
internal func arc4random() -> UInt32 {
28+
return UInt32.random(in: UInt32.min...UInt32.max)
29+
}
30+
31+
internal func arc4random_uniform(_ val: UInt32) -> UInt32 {
32+
return UInt32.random(in: 0...val)
33+
}
2434
#endif
2535

2636
// each type has its own random

0 commit comments

Comments
 (0)