-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 93754bf
Showing
1,530 changed files
with
695,381 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# This workflow will build a Swift project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift | ||
|
||
name: Swift | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
macos: | ||
runs-on: macos-15 | ||
|
||
steps: | ||
- uses: maxim-lobanov/setup-xcode@v1 | ||
with: | ||
xcode-version: "16.1.0" | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Skia | ||
run: swift package plugin --allow-writing-to-package-directory --allow-network-connections all setup-skia | ||
|
||
- name: Build | ||
run: swift build | ||
|
||
- name: Run tests | ||
run: swift test | ||
|
||
windows: | ||
# runs-on: [self-hosted, Windows] | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: SwiftyLab/setup-swift@latest | ||
with: | ||
swift-version: https://download.swift.org/development/windows10/swift-DEVELOPMENT-SNAPSHOT-2024-10-25-a/swift-DEVELOPMENT-SNAPSHOT-2024-10-25-a-windows10.exe | ||
development: true | ||
|
||
- name: Get swift version | ||
run: swift --version | ||
|
||
- name: Setup Skia | ||
run: swift package plugin --allow-writing-to-package-directory --allow-network-connections all setup-skia | ||
|
||
- name: Build | ||
run: swift build | ||
|
||
# - name: Run tests | ||
# run: swift test | ||
|
||
linux: | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install dependencies | ||
run: sudo apt-get update && sudo apt-get install -y ninja-build pkg-config libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libusb-1.0-0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev libunwind-dev libpipewire-0.3-dev libdecor-0-dev libfontconfig-dev | ||
|
||
- uses: SwiftyLab/setup-swift@latest | ||
|
||
- name: Get swift version | ||
run: swift --version | ||
|
||
- name: Setup Skia | ||
run: swift package plugin --allow-writing-to-package-directory --allow-network-connections all setup-skia | ||
|
||
- name: Build | ||
run: swift build | ||
|
||
# - name: Run tests | ||
# run: swift test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc | ||
.vscode | ||
.shaft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": 1, | ||
"lineLength": 100, | ||
"indentation": { | ||
"spaces": 4 | ||
}, | ||
"maximumBlankLines": 1, | ||
"respectsExistingLineBreaks": true, | ||
"lineBreakBeforeControlFlowKeywords": false, | ||
"lineBreakBeforeEachArgument": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright 2014 The Flutter Authors. | ||
Copyright 2024 The Shaft Authors. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "csprogress", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/gregcotten/CSProgress", | ||
"state" : { | ||
"revision" : "b831bb234a8a2af02ccc04d6e91a62f7dabb7de4", | ||
"version" : "0.0.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "rainbow", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/onevcat/Rainbow", | ||
"state" : { | ||
"revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3", | ||
"version" : "4.0.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "splash", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/ShaftUI/Splash", | ||
"state" : { | ||
"branch" : "master", | ||
"revision" : "ed08785980b61de9b98306434410ce7fc10572ea" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-collections", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-collections", | ||
"state" : { | ||
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192", | ||
"version" : "1.0.6" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-system", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-system", | ||
"state" : { | ||
"revision" : "c8a44d836fe7913603e246acab7c528c2e780168", | ||
"version" : "1.4.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swiftmath", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/ShaftUI/SwiftMath", | ||
"state" : { | ||
"revision" : "034d9010448694872655731129a7599bb27d5b01", | ||
"version" : "3.3.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "swiftsdl3", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/ShaftUI/SwiftSDL3", | ||
"state" : { | ||
"branch" : "main", | ||
"revision" : "a56a797f584de4e4cf3470f2e2dbf2e7fba6edf0" | ||
} | ||
}, | ||
{ | ||
"identity" : "zipfoundationmodern", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/gregcotten/ZIPFoundationModern", | ||
"state" : { | ||
"revision" : "97755f1b1217dc2aa1ca9219630c1ba450519313", | ||
"version" : "0.0.3" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import Foundation | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Shaft", | ||
|
||
platforms: [ | ||
.macOS(.v14), | ||
.iOS(.v13), | ||
.tvOS(.v13), | ||
], | ||
|
||
products: [ | ||
.executable(name: "Playground", targets: ["Playground"]), | ||
.library(name: "Shaft", targets: ["Shaft"]), | ||
.plugin(name: "CSkiaSetupPlugin", targets: ["CSkiaSetupPlugin"]), | ||
], | ||
|
||
dependencies: [ | ||
.package( | ||
url: "https://github.com/ShaftUI/SwiftMath", | ||
.upToNextMajor(from: "3.3.2") | ||
), | ||
.package( | ||
url: "https://github.com/ShaftUI/SwiftSDL3", | ||
// .upToNextMinor(from: "0.0.4") | ||
branch: "main" | ||
), | ||
.package( | ||
url: "https://github.com/onevcat/Rainbow", | ||
.upToNextMajor(from: "4.0.0") | ||
), | ||
.package( | ||
url: "https://github.com/apple/swift-collections", | ||
.upToNextMinor(from: "1.0.0") // or `.upToNextMajor | ||
), | ||
.package( | ||
url: "https://github.com/gregcotten/ZIPFoundationModern", | ||
.upToNextMajor(from: "0.0.1") | ||
), | ||
.package( | ||
url: "https://github.com/ShaftUI/Splash", | ||
branch: "master" | ||
), | ||
], | ||
|
||
targets: [ | ||
.executableTarget( | ||
name: "Playground", | ||
dependencies: [ | ||
"CSkia", | ||
"SwiftMath", | ||
"Shaft", | ||
"ShaftCodeHighlight", | ||
], | ||
swiftSettings: [ | ||
.interoperabilityMode(.Cxx) | ||
] | ||
), | ||
|
||
.target( | ||
name: "CSkia", | ||
sources: [ | ||
"utils.cpp" | ||
], | ||
publicHeadersPath: ".", | ||
cxxSettings: [ | ||
.define("SK_FONTMGR_FONTCONFIG_AVAILABLE", .when(platforms: [.linux])) | ||
], | ||
linkerSettings: [ | ||
.linkedLibrary("d3d12", .when(platforms: [.windows])), | ||
.linkedLibrary("d3dcompiler", .when(platforms: [.windows])), | ||
.linkedLibrary("openGL32", .when(platforms: [.windows])), | ||
.linkedLibrary("stdc++", .when(platforms: [.windows])), | ||
.linkedLibrary("dxgi", .when(platforms: [.windows])), | ||
|
||
.linkedFramework("CoreGraphics", .when(platforms: [.macOS])), | ||
.linkedFramework("CoreText", .when(platforms: [.macOS])), | ||
.linkedFramework("CoreFoundation", .when(platforms: [.macOS])), | ||
.linkedFramework("Metal", .when(platforms: [.macOS])), | ||
|
||
.linkedLibrary("fontconfig", .when(platforms: [.linux])), | ||
.linkedLibrary("freetype", .when(platforms: [.linux])), | ||
.linkedLibrary("GL", .when(platforms: [.linux])), | ||
.linkedLibrary("GLX", .when(platforms: [.linux])), | ||
.linkedLibrary("wayland-client", .when(platforms: [.linux])), | ||
|
||
.unsafeFlags(["-L.shaft/skia"]), | ||
] | ||
), | ||
|
||
.target( | ||
name: "CSkiaResource", | ||
resources: [ | ||
.copy("icudtl.dat") | ||
] | ||
), | ||
|
||
.plugin( | ||
name: "CSkiaSetupPlugin", | ||
capability: .command( | ||
intent: .custom(verb: "setup-skia", description: "Download prebuilt Skia binaries"), | ||
permissions: [ | ||
.allowNetworkConnections( | ||
scope: .all(), | ||
reason: "To download the Skia binaries" | ||
), | ||
.writeToPackageDirectory(reason: "To extract the Skia binaries"), | ||
] | ||
), | ||
dependencies: [ | ||
"CSkiaSetup" | ||
] | ||
), | ||
|
||
.executableTarget( | ||
name: "CSkiaSetup", | ||
dependencies: [ | ||
.product(name: "ZIPFoundation", package: "zipfoundationmodern") | ||
] | ||
), | ||
|
||
.target( | ||
name: "Shaft", | ||
dependencies: [ | ||
"SwiftMath", | ||
"CSkia", | ||
"CSkiaResource", | ||
"Rainbow", | ||
"SwiftSDL3", | ||
.product(name: "Collections", package: "swift-collections"), | ||
], | ||
swiftSettings: [.interoperabilityMode(.Cxx)] | ||
), | ||
|
||
.target( | ||
name: "ShaftCodeHighlight", | ||
dependencies: [ | ||
"Splash", | ||
"Shaft", | ||
], | ||
swiftSettings: [.interoperabilityMode(.Cxx)] | ||
), | ||
|
||
.testTarget( | ||
name: "ShaftTests", | ||
dependencies: ["Shaft"], | ||
swiftSettings: [ | ||
.interoperabilityMode(.Cxx) | ||
] | ||
), | ||
], | ||
cxxLanguageStandard: .cxx17 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Foundation | ||
import PackagePlugin | ||
|
||
@main | ||
struct CSkiaSetupPlugin: CommandPlugin { | ||
|
||
func performCommand( | ||
context: PluginContext, | ||
arguments: [String] | ||
) async throws { | ||
print("Setting up Skia") | ||
|
||
let tool = try context.tool(named: "CSkiaSetup") | ||
let process = Process() | ||
process.executableURL = URL(fileURLWithPath: tool.path.string) | ||
process.arguments = [context.package.directory.string] | ||
|
||
// let the process inherit stdout and stderr | ||
// process.standardOutput = FileHandle.standardOutput | ||
// process.standardError = FileHandle.standardError | ||
|
||
try process.run() | ||
} | ||
} |
Oops, something went wrong.