Skip to content

Commit 3fdb5a6

Browse files
committed
Init commit
0 parents  commit 3fdb5a6

File tree

16 files changed

+1323
-0
lines changed

16 files changed

+1323
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Compatibility tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
compatibility_tests_macos:
11+
name: Execute compatibility tests
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: macos-15
17+
xcode-version: "16.4" # Swift 6.1.2
18+
runs-on: ${{ matrix.os }}
19+
env:
20+
OPENGRAPHICS_BUILD_FOR_DARWIN_PLATFORM: 1
21+
OPENGRAPHICS_WERROR: 1
22+
OPENGRAPHICS_COREGRAPHICS: 1
23+
GH_TOKEN: ${{ github.token }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Setup Xcode
27+
uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main
28+
with:
29+
xcode-version: ${{ matrix.xcode-version }}
30+
- name: Swift version
31+
run: swift --version
32+
- name: Run tests against Apple's CoreGraphics on macOS via SwiftPM
33+
env:
34+
OPENRENDERBOX_LIBRARY_EVOLUTION: 0
35+
run: |
36+
swift test \
37+
--build-path .build-compatibility-test-debug

.github/workflows/macos.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: macOS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
macos_test:
11+
name: Execute tests on macOS
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [macos-15]
16+
xcode-version: [16.4] # Swift 6.1.2
17+
runs-on: ${{ matrix.os }}
18+
env:
19+
OPENGRAPHICS_BUILD_FOR_DARWIN_PLATFORM: 1
20+
OPENGRAPHICS_WERROR: 1
21+
OPENGRAPHICS_COREGRAPHICS: 0
22+
GH_TOKEN: ${{ github.token }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup Xcode
26+
uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main
27+
with:
28+
xcode-version: ${{ matrix.xcode-version }}
29+
- name: Swift version
30+
run: swift --version
31+
- name: Build and run tests in debug mode with coverage
32+
env:
33+
OPENRENDERBOX_LIBRARY_EVOLUTION: 0
34+
run: |
35+
swift test \
36+
-c debug \
37+
--enable-code-coverage \
38+
--build-path .build-test-debug
39+
xcrun llvm-cov show \
40+
-instr-profile=.build-test-debug/debug/codecov/default.profdata \
41+
.build-test-debug/debug/OPENRENDERBOXPackageTests.xctest/Contents/MacOS/OPENRENDERBOXPackageTests \
42+
> coverage.txt
43+
- name: Build and run tests in release mode
44+
env:
45+
OPENRENDERBOX_LIBRARY_EVOLUTION: 0
46+
run: |
47+
swift test \
48+
-c release \
49+
--build-path .build-test-release
50+
- uses: codecov/codecov-action@v5
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
verbose: true

.github/workflows/ubuntu.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Ubuntu
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ubuntu_test:
11+
name: Execute tests on Ubuntu
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
swift_version: ["6.1.2"]
16+
runs-on: ubuntu-22.04
17+
env:
18+
OPENGRAPHICS_BUILD_FOR_DARWIN_PLATFORM: 0
19+
OPENGRAPHICS_WERROR: 1
20+
OPENGRAPHICS_COREGRAPHICS: 0
21+
container: swift:${{ matrix.swift_version }}-jammy
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Swift version
25+
run: |
26+
which swift && swift --version
27+
- name: Building and running tests in debug mode with coverage
28+
run: |
29+
swift test \
30+
-c debug \
31+
--enable-code-coverage \
32+
--build-path .build-test-debug
33+
llvm-cov show \
34+
-instr-profile=.build-test-debug/debug/codecov/default.profdata \
35+
.build-test-debug/debug/OpenRenderBoxPackageTests.xctest \
36+
> coverage.txt
37+
- name: Building and running tests in release mode
38+
run: |
39+
swift test \
40+
-c release \
41+
--build-path .build-test-release
42+
- uses: codecov/codecov-action@v3
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
verbose: true

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Kyle-Ye
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Package.resolved

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// swift-tools-version: 6.1
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
7+
guard let value = Context.environment[key] else {
8+
return defaultValue
9+
}
10+
if value == "1" {
11+
return true
12+
} else if value == "0" {
13+
return false
14+
} else {
15+
return defaultValue
16+
}
17+
}
18+
19+
var sharedSwiftSettings: [SwiftSetting] = [
20+
.swiftLanguageMode(.v6),
21+
]
22+
23+
#if os(macOS)
24+
// NOTE: #if os(macOS) check is not accurate if we are cross compiling for Linux platform. So we add an env key to specify it.
25+
let buildForDarwinPlatform = envEnable("OPENGRAPHICS_BUILD_FOR_DARWIN_PLATFORM", default: true)
26+
#else
27+
let buildForDarwinPlatform = envEnable("OPENGRAPHICS_BUILD_FOR_DARWIN_PLATFORM")
28+
#endif
29+
30+
let coreGraphicsCondition = envEnable("OPENGRAPHICS_COREGRAPHICS", default: buildForDarwinPlatform)
31+
if coreGraphicsCondition {
32+
sharedSwiftSettings.append(.define("OPENGRAPHICS_COREGRAPHICS"))
33+
}
34+
35+
let warningsAsErrorsCondition = envEnable("OPENGRAPHICS_WERROR", default: true)
36+
if warningsAsErrorsCondition {
37+
sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"]))
38+
}
39+
40+
let package = Package(
41+
name: "OpenGraphics",
42+
products: [
43+
.library(name: "OpenGraphics", targets: ["OpenGraphics"]),
44+
.library(name: "OpenGraphicsShims", targets: ["OpenGraphicsShims"]),
45+
],
46+
dependencies: [
47+
.package(url: "https://github.com/apple/swift-numerics", from: "1.0.3"),
48+
],
49+
targets: [
50+
.target(name: "OpenGraphics"),
51+
.target(
52+
name: "OpenGraphicsShims",
53+
dependencies: ["OpenGraphics"],
54+
swiftSettings: sharedSwiftSettings,
55+
linkerSettings: [
56+
.linkedFramework("CoreGraphics", .when(platforms: .darwinPlatforms)),
57+
]
58+
),
59+
.testTarget(
60+
name: "OpenGraphicsShimsTests",
61+
dependencies: [
62+
"OpenGraphicsShims",
63+
.product(name: "Numerics", package: "swift-numerics"),
64+
],
65+
swiftSettings: sharedSwiftSettings
66+
),
67+
]
68+
)
69+
70+
extension [Platform] {
71+
static var darwinPlatforms: [Platform] {
72+
[.iOS, .macOS, .tvOS, .watchOS, .visionOS, .macCatalyst]
73+
}
74+
75+
static var nonDarwinPlatforms: [Platform] {
76+
[.linux, .android, .wasi, .openbsd, .windows]
77+
}
78+
}

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# OpenGraphics
2+
3+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenGraphics%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenGraphics)
4+
5+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenGraphics%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenGraphics)
6+
7+
[![codecov](https://codecov.io/github/OpenSwiftUIProject/OpenGraphics/graph/badge.svg?token=1JKUXEZRCB)](https://codecov.io/github/OpenSwiftUIProject/OpenGraphics)
8+
9+
OpenGraphics provides an alternative implementation of Apple's CoreGraphics framework which is not available on non-Apple platforms.
10+
11+
Currently, this project is in early development.
12+
13+
## Build
14+
15+
The current suggested toolchain to build the project is Swift 6.1.2 / Xcode 16.4.
16+
17+
## TODO
18+
19+
- [ ] Add more API and types.
20+
21+
Ref: https://github.com/PureSwift/Silicae
22+
23+
## Supported platforms
24+
25+
| **CI Status** |
26+
|---|
27+
|[![Compatibility tests](https://github.com/OpenSwiftUIProject/OpenGraphics/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraphics/actions/workflows/compatibility_tests.yml)|
28+
|[![macOS](https://github.com/OpenSwiftUIProject/OpenGraphics/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraphics/actions/workflows/macos.yml)|
29+
|[![Ubuntu](https://github.com/OpenSwiftUIProject/OpenGraphics/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraphics/actions/workflows/ubuntu.yml)|
30+
31+
## License
32+
33+
See LICENSE file - MIT

0 commit comments

Comments
 (0)