diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 350639eac2fd4..a6baaa1930b52 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -153,32 +153,44 @@ jobs: uses: actions/download-artifact@v1 with: name: macos-installable - - name: Build hello.wasm - shell: bash + - name: Unpack toolchain run: | set -x tar xf $(find . -name "swift-wasm-*.tar.gz" -type f) - TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d) + echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-*" -type d)" >> $GITHUB_ENV + - name: Build hello.wasm + shell: bash + run: | echo 'print("Hello, world!")' > hello.swift - $TOOLCHAIN_PATH/usr/bin/swiftc \ + $TOOLCHAIN/usr/bin/swiftc \ -target wasm32-unknown-wasi \ - -sdk $TOOLCHAIN_PATH/usr/share/wasi-sysroot \ + -sdk $TOOLCHAIN/usr/share/wasi-sysroot \ hello.swift -o hello.wasm && \ echo "Successfully linked hello.wasm" - name: Test SwiftPM shell: bash run: | set -x - TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d) mkdir test cd test - $TOOLCHAIN_PATH/usr/bin/swift package init - $TOOLCHAIN_PATH/usr/bin/swift build --triple wasm32-unknown-wasi + $TOOLCHAIN/usr/bin/swift package init + $TOOLCHAIN/usr/bin/swift build --triple wasm32-unknown-wasi - name: Upload hello.wasm compiled with macOS package uses: actions/upload-artifact@v1 with: name: macos-hello.wasm path: hello.wasm + - name: Checkout integration-tests + uses: actions/checkout@v2 + with: + repository: swiftwasm/integration-tests + path: integration-tests + ref: release/5.3 + - name: Run integration tests + run: | + sudo xcode-select --switch /Applications/Xcode_12.2.app/Contents/Developer/ + swift run # Use TOOLCHAIN env value + working-directory: ${{ github.workspace }}/integration-tests ubuntu1804_smoke_test: name: Run smoke tests on Ubuntu 18.04 @@ -189,32 +201,42 @@ jobs: uses: actions/download-artifact@v1 with: name: ubuntu18.04-installable - - name: Build hello.wasm - shell: bash + - name: Unpack toolchain run: | set -x tar xf $(find . -name "swift-wasm-*.tar.gz" -type f) - TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d) + echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-*" -type d)" >> $GITHUB_ENV + - name: Build hello.wasm + shell: bash + run: | echo 'print("Hello, world!")' > hello.swift - $TOOLCHAIN_PATH/usr/bin/swiftc \ + $TOOLCHAIN/usr/bin/swiftc \ -target wasm32-unknown-wasi \ - -sdk $TOOLCHAIN_PATH/usr/share/wasi-sysroot \ + -sdk $TOOLCHAIN/usr/share/wasi-sysroot \ hello.swift -o hello.wasm && \ echo "Successfully linked hello.wasm" - name: Test SwiftPM shell: bash run: | set -x - TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d) mkdir test cd test - $TOOLCHAIN_PATH/usr/bin/swift package init - $TOOLCHAIN_PATH/usr/bin/swift build --triple wasm32-unknown-wasi + $TOOLCHAIN/usr/bin/swift package init + $TOOLCHAIN/usr/bin/swift build --triple wasm32-unknown-wasi - name: Upload hello.wasm compiled with Ubuntu 18.04 package uses: actions/upload-artifact@v1 with: name: ubuntu18.04-hello.wasm path: hello.wasm + - name: Checkout integration-tests + uses: actions/checkout@v2 + with: + repository: swiftwasm/integration-tests + path: integration-tests + ref: release/5.3 + - name: Run integration tests + run: swift run # Use TOOLCHAIN env value + working-directory: ${{ github.workspace }}/integration-tests ubuntu2004_smoke_test: name: Run smoke tests on Ubuntu 20.04 @@ -225,29 +247,39 @@ jobs: uses: actions/download-artifact@v1 with: name: ubuntu20.04-installable - - name: Build hello.wasm - shell: bash + - name: Unpack toolchain run: | set -x tar xf $(find . -name "swift-wasm-*.tar.gz" -type f) - TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d) + echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-*" -type d)" >> $GITHUB_ENV + - name: Build hello.wasm + shell: bash + run: | echo 'print("Hello, world!")' > hello.swift - $TOOLCHAIN_PATH/usr/bin/swiftc \ + $TOOLCHAIN/usr/bin/swiftc \ -target wasm32-unknown-wasi \ - -sdk $TOOLCHAIN_PATH/usr/share/wasi-sysroot \ + -sdk $TOOLCHAIN/usr/share/wasi-sysroot \ hello.swift -o hello.wasm && \ echo "Successfully linked hello.wasm" - name: Test SwiftPM shell: bash run: | set -x - TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d) mkdir test cd test - $TOOLCHAIN_PATH/usr/bin/swift package init - $TOOLCHAIN_PATH/usr/bin/swift build --triple wasm32-unknown-wasi + $TOOLCHAIN/usr/bin/swift package init + $TOOLCHAIN/usr/bin/swift build --triple wasm32-unknown-wasi - name: Upload hello.wasm compiled with Ubuntu 20.04 package uses: actions/upload-artifact@v1 with: name: ubuntu20.04-hello.wasm path: hello.wasm + - name: Checkout integration-tests + uses: actions/checkout@v2 + with: + repository: swiftwasm/integration-tests + path: integration-tests + ref: release/5.3 + - name: Run integration tests + run: swift run # Use TOOLCHAIN env value + working-directory: ${{ github.workspace }}/integration-tests diff --git a/utils/webassembly/build-foundation.sh b/utils/webassembly/build-foundation.sh index be517ad788881..4cb1dfe0233e8 100755 --- a/utils/webassembly/build-foundation.sh +++ b/utils/webassembly/build-foundation.sh @@ -21,10 +21,10 @@ cmake -G Ninja \ ninja -v ninja -v install -# On macOS the target CoreFoundation shadows the CoreFoundation suppplied by Xcode. -# On Linux though there's no system CoreFoundation, its headers have to be shipped -# in the installable archive and serve for both host and target. -if [[ "$(uname)" == "Darwin" ]]; then - mv $DESTINATION_TOOLCHAIN/usr/lib/swift/CoreFoundation \ - $DESTINATION_TOOLCHAIN/usr/lib/swift/wasi/wasm32/CoreFoundation -fi +mv $DESTINATION_TOOLCHAIN/usr/lib/swift/CoreFoundation \ + $DESTINATION_TOOLCHAIN/usr/lib/swift_static/CoreFoundation + +mv $DESTINATION_TOOLCHAIN/usr/lib/swift/wasi/wasm32/Foundation.swiftmodule \ + $DESTINATION_TOOLCHAIN/usr/lib/swift_static/wasi/wasm32/Foundation.swiftmodule +mv $DESTINATION_TOOLCHAIN/usr/lib/swift/wasi/wasm32/Foundation.swiftdoc \ + $DESTINATION_TOOLCHAIN/usr/lib/swift_static/wasi/wasm32/Foundation.swiftdoc diff --git a/utils/webassembly/build-toolchain.sh b/utils/webassembly/build-toolchain.sh index 447c0e4bb8755..1527e51e764c8 100755 --- a/utils/webassembly/build-toolchain.sh +++ b/utils/webassembly/build-toolchain.sh @@ -121,7 +121,10 @@ merge_toolchains() { rsync -v -a $TARGET_TOOLCHAIN_SDK/usr/bin/ $DIST_TOOLCHAIN_SDK/usr/bin/ # Replace absolute sysroot path with relative path - sed -i -e "s@\".*/include@\"../../../../share/wasi-sysroot/include@g" $DIST_TOOLCHAIN_SDK/usr/lib/swift/wasi/wasm32/wasi.modulemap + sed -i.bak -e "s@\".*/include@\"../../../../share/wasi-sysroot/include@g" "$DIST_TOOLCHAIN_SDK/usr/lib/swift/wasi/wasm32/wasi.modulemap" + rm "$DIST_TOOLCHAIN_SDK/usr/lib/swift/wasi/wasm32/wasi.modulemap.bak" + sed -i.bak -e "s@\".*/include@\"../../../../share/wasi-sysroot/include@g" "$DIST_TOOLCHAIN_SDK/usr/lib/swift_static/wasi/wasm32/wasi.modulemap" + rm "$DIST_TOOLCHAIN_SDK/usr/lib/swift_static/wasi/wasm32/wasi.modulemap.bak" } create_darwin_info_plist() { diff --git a/utils/webassembly/build-xctest.sh b/utils/webassembly/build-xctest.sh index 103edd0fcf6df..c2eb7ba1f3955 100755 --- a/utils/webassembly/build-xctest.sh +++ b/utils/webassembly/build-xctest.sh @@ -15,7 +15,7 @@ cmake -G Ninja \ -DWASI_SDK_PATH="$SOURCE_PATH/wasi-sdk" \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_Swift_COMPILER_FORCED=ON \ - -DSWIFT_FOUNDATION_PATH=$DESTINATION_TOOLCHAIN/usr/lib/swift/wasi/wasm32 \ + -DSWIFT_FOUNDATION_PATH=$DESTINATION_TOOLCHAIN/usr/lib/swift_static/wasi/wasm32 \ "${SOURCE_PATH}/swift-corelibs-xctest" ninja -v