diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..600f00a --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,69 @@ +name: Swift + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + cancel_previous: + runs-on: ubuntu-latest + steps: + - uses: styfle/cancel-workflow-action@0.12.0 + with: + workflow_id: ${{ github.event.workflow.id }} + + generate_code_coverage: + needs: cancel_previous + runs-on: macos-15 + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "16.2" + - uses: actions/checkout@v2 + - name: Build & Run tests + run: swift test --enable-code-coverage + - name: Convert coverage report + run: xcrun llvm-cov export -format="lcov" .build/debug/SubstrataPackageTests.xctest/Contents/MacOS/SubstrataPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: segmentio/substrata-swift + + build_and_test_spm_mac: + needs: cancel_previous + runs-on: macos-15 + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "16.2" + - uses: actions/checkout@v2 + - name: Build & Run tests + run: swift test + + build_and_test_ios: + needs: cancel_previous + runs-on: macos-15 + steps: + - name: Install yeetd + run: | + wget https://github.com/biscuitehh/yeetd/releases/download/1.0/yeetd-normal.pkg + sudo installer -pkg yeetd-normal.pkg -target / + yeetd & + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "16.2" + - uses: actions/checkout@v2 + - run: xcodebuild -scheme Substrata-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 16' + + build_and_test_tvos: + needs: cancel_previous + runs-on: macos-15 + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "16.2" + - uses: actions/checkout@v2 + - run: xcodebuild -scheme Substrata-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' diff --git a/Package.swift b/Package.swift index 6797500..572a8d3 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [ .macOS("10.15"), .iOS("13.0"), - .tvOS("12.0") + .tvOS("12.0"), ], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. @@ -35,13 +35,13 @@ let package = Package( ] ), .target( - name: "Substrata", + name: "Substrata", dependencies: ["SubstrataQuickJS"]), .testTarget( name: "SubstrataTests", dependencies: ["Substrata"], resources: [ .copy("Support/ConversionTestData.js") - ]) + ]), ] ) diff --git a/Sources/Substrata/Engine.swift b/Sources/Substrata/Engine.swift index 822fc6f..3b60de8 100644 --- a/Sources/Substrata/Engine.swift +++ b/Sources/Substrata/Engine.swift @@ -28,8 +28,6 @@ public class JSEngine { } deinit { - JS_RunGC(runtime) - context.shutdown() JS_FreeRuntime(runtime) } diff --git a/Sources/SubstrataQuickJS/include/SubstrataQuickJS.h b/Sources/SubstrataQuickJS/include/SubstrataQuickJS.h index f388146..b3fedd3 100644 --- a/Sources/SubstrataQuickJS/include/SubstrataQuickJS.h +++ b/Sources/SubstrataQuickJS/include/SubstrataQuickJS.h @@ -69,4 +69,18 @@ static void js_decrement_refcount(JSValue v) { ... }*/ +// comment out in quickjs.c in JS_FreeRuntime +//assert(list_empty(&rt->gc_obj_list)); + +// in quickjs-libc.c, add this after all the #includes and #defines. +// -- this enables us to work on tvOS. these functions are only used +// for the file-io capabilities that we don't access. +/* +#include +#if TARGET_OS_TV +#define execve(file, argv, envp) ({ assert(!"execve() is not supported on tvOS"); -1; }) +#define fork() ({ assert(!"fork() is not supported on tvOS"); -1; }) +#endif + */ + #endif // SEGMENT_H diff --git a/Sources/SubstrataQuickJS/quickjs-libc.c b/Sources/SubstrataQuickJS/quickjs-libc.c index 6dbe501..2663b9c 100644 --- a/Sources/SubstrataQuickJS/quickjs-libc.c +++ b/Sources/SubstrataQuickJS/quickjs-libc.c @@ -104,6 +104,12 @@ extern char **environ; #endif #endif +#include +#if TARGET_OS_TV +#define execve(file, argv, envp) ({ assert(!"execve() is not supported on tvOS"); -1; }) +#define fork() ({ assert(!"fork() is not supported on tvOS"); -1; }) +#endif + /* TODO: - add socket calls */ diff --git a/Sources/SubstrataQuickJS/quickjs.c b/Sources/SubstrataQuickJS/quickjs.c index 3de7a10..2fb74af 100644 --- a/Sources/SubstrataQuickJS/quickjs.c +++ b/Sources/SubstrataQuickJS/quickjs.c @@ -2137,7 +2137,7 @@ void JS_FreeRuntime(JSRuntime *rt) } #endif - assert(list_empty(&rt->gc_obj_list)); + //assert(list_empty(&rt->gc_obj_list)); /* free the classes */ for(i = 0; i < rt->class_count; i++) { diff --git a/Sources/SubstrataQuickJS/quickjs_info.md b/Sources/SubstrataQuickJS/quickjs_info.md index 2b41b17..46e37f8 100644 --- a/Sources/SubstrataQuickJS/quickjs_info.md +++ b/Sources/SubstrataQuickJS/quickjs_info.md @@ -1,3 +1,5 @@ QuickJS-NG https://github.com/quickjs-ng/quickjs v0.8.0 + +See include/SubstrataQuickJS.h diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..7f7ece5 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,23 @@ +ignore: + - "Tests" # ignore all tests + +coverage: + status: + project: + default: + target: 50% + threshold: 5% + informational: false + patch: + default: + target: 80% + informational: false + +comment: + layout: "diff, flags, files" + behavior: default + require_changes: false # learn more in the Requiring Changes section below + require_base: false # [true :: must have a base report to post] + require_head: true # [true :: must have a head report to post] + hide_project_coverage: false # [true :: only show coverage on the git diff] +