Skip to content

Commit

Permalink
adjustments for experimental embedded support (#53)
Browse files Browse the repository at this point in the history
* no print in embedded and renamed env setting

* add embedded wasm CI

* fix github CI file

* ...yaml...

* fixed missing function
  • Loading branch information
sliemeobn authored Oct 16, 2024
1 parent c1d4f5a commit 6d2d244
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci-embedded.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build Embedded Wasm

on:
push:
branches: [main]
paths:
- "**.swift"
- "**.yml"
pull_request:
branches: [main]
workflow_dispatch:

jobs:
linux:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
image: ["swiftlang/swift:nightly-main"]

container:
image: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build
run: |
swift build -c release \
--triple wasm32-unknown-none-wasm \
-Xswiftc -enable-experimental-feature -Xswiftc Embedded \
-Xswiftc -enable-experimental-feature -Xswiftc Extern \
-Xswiftc -wmo -Xswiftc -disable-cmo \
-Xswiftc -cxx-interoperability-mode=default \
-Xcc -fdeclspec
4 changes: 3 additions & 1 deletion Package@swift-6.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import Foundation
import PackageDescription

let shouldBuildForEmbedded = ProcessInfo.processInfo.environment["EXPERIMENTAL_EMBEDDED_WASM"].flatMap(Bool.init) ?? false
let shouldBuildForEmbedded = ProcessInfo.processInfo.environment["JAVASCRIPTKIT_EXPERIMENTAL_EMBEDDED_WASM"].flatMap(Bool.init) ?? false

var featureFlags: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
]

if shouldBuildForEmbedded {
// currently this work-around only works for SwiftPM package dependencies on branches, not version tags
// see https://github.com/swiftlang/swift-package-manager/issues/7612
featureFlags.append(
.unsafeFlags([
"-Xfrontend", "-emit-empty-object-file",
Expand Down
5 changes: 4 additions & 1 deletion Sources/Elementary/Rendering/RenderingUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ extension _RenderingContext {
@inline(__always)
@usableFromInline
func assertionFailureNoAsyncContext(_ type: (some HTML).Type) {
#if hasFeature(Embedded)
assertionFailure("Cannot render async content in a synchronous context, please use .render(into:) or .renderAsync() instead.")
#else
let message = "Cannot render \(type) in a synchronous context, please use .render(into:) or .renderAsync() instead."
print("Elementary rendering error: \(message)")
#if !hasFeature(Embedded)

assertionFailure(message)
#endif
}
Expand Down

0 comments on commit 6d2d244

Please sign in to comment.