Skip to content

Commit 98522f2

Browse files
MaxDesiatovkateinoigakukun
authored andcommitted
Move packaging scripts from swiftwasm-package-sdk (#18)
Currently our CI scripts rely on validity of scripts in the [`swiftwasm-package-sdk`](https://github.com/swiftwasm/swiftwasm-package-sdk) repository. That can't always be the case, especialy as we don't checkout a specific commit in that repository. And even if we did, managing this isn't convenient. Adding a submodule has its own set of issues and I personally think that a monorepo approach is much simpler for a small set of scripts, at least at an early stage. In fact, it would make sense to have these scripts in the upstream [`swift`](https://github.com/apple/swift) repository at some point, similarly to [what Android people have previously done](https://github.com/apple/swift/tree/master/utils/android). Thus, these scripts and a few small helper files are copied to `utils/webassembly` directory and are executed directly on CI. After this PR is merged, I don't see a particular need for our [`swiftwasm-package-sdk`](https://github.com/swiftwasm/swiftwasm-package-sdk) and [`swiftwasm-sdk`](https://github.com/swiftwasm/swiftwasm-sdk) repos, those probably can be archived. As a small cleanup addition, `.github/workflows/main.yml` file now has consistent indentation. * Move packaging scripts from swiftwasm-package-sdk * Rename `wasm` directory to `webassembly` * Make all .sh scripts executable after download * Make sdkroot/swiftwasm script executable * Add newline to build-mac-package.sh * Add newline to build-packages.sh * Remove swift_start.o and swift_end.o
1 parent 16de707 commit 98522f2

19 files changed

+321
-25
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,50 @@ name: CI
33
on:
44
push:
55
branches:
6-
- swiftwasm
6+
- swiftwasm
77
pull_request:
88
branches:
9-
- swiftwasm
9+
- swiftwasm
1010

1111
jobs:
1212
linux_build:
1313
timeout-minutes: 0
1414
runs-on: ubuntu-18.04
1515

1616
steps:
17-
- uses: actions/checkout@v1
18-
- name: Build Linux installable archive
19-
run: ./ci-linux.sh
20-
- name: Upload Linux installable archive
21-
uses: actions/upload-artifact@v1
22-
with:
23-
name: linux-installable
24-
path: ../swiftwasm-linux.tar.gz
17+
- uses: actions/checkout@v1
18+
- name: Build Linux installable archive
19+
run: ./ci-linux.sh
20+
- name: Upload Linux installable archive
21+
uses: actions/upload-artifact@v1
22+
with:
23+
name: linux-installable
24+
path: ../swiftwasm-linux.tar.gz
2525

2626
macos_build:
2727
timeout-minutes: 0
2828
runs-on: macOS-10.14
2929

3030
steps:
31-
- uses: actions/checkout@v1
32-
- name: Build macOS installable archive
33-
run: ./ci-mac.sh
34-
- name: Upload macOS installable archive
35-
uses: actions/upload-artifact@v1
36-
with:
37-
name: macos-installable
38-
path: ../swiftwasm-macos.tar.gz
31+
- uses: actions/checkout@v1
32+
- name: Build macOS installable archive
33+
run: ./ci-mac.sh
34+
- name: Upload macOS installable archive
35+
uses: actions/upload-artifact@v1
36+
with:
37+
name: macos-installable
38+
path: ../swiftwasm-macos.tar.gz
39+
- name: Upload packaging scripts
40+
uses: actions/upload-artifact@v1
41+
with:
42+
name: packaging-scripts
43+
path: utils/webassembly
3944

4045
package:
4146
name: Build SwiftWasm packages
4247
needs:
43-
- linux_build
44-
- macos_build
48+
- linux_build
49+
- macos_build
4550
runs-on: ubuntu-18.04
4651
steps:
4752
- name: Download installable Linux archive
@@ -52,11 +57,16 @@ jobs:
5257
uses: actions/download-artifact@v1
5358
with:
5459
name: macos-installable
60+
- name: Download packaging scripts
61+
uses: actions/download-artifact@v1
62+
with:
63+
name: packaging-scripts
5564
- name: Build the packages
5665
shell: bash
5766
run: |
58-
git clone https://github.com/swiftwasm/swiftwasm-package-sdk.git
59-
cd swiftwasm-package-sdk
67+
cd packaging-scripts
68+
find . -name '*.sh' -exec chmod +x {} \;
69+
chmod +x sdkroot/swiftwasm
6070
./download-prebuilts.sh
6171
6272
cp ../linux-installable/swiftwasm-linux.tar.gz \
@@ -74,19 +84,19 @@ jobs:
7484
uses: actions/upload-artifact@v1
7585
with:
7686
name: macos-package
77-
path: swiftwasm-package-sdk/output/swiftwasm-sdk-macos.tar.xz
87+
path: packaging-scripts/output/swiftwasm-sdk-macos.tar.xz
7888

7989
- name: Upload Linux package
8090
uses: actions/upload-artifact@v1
8191
with:
8292
name: linux-package
83-
path: swiftwasm-package-sdk/output/swiftwasm-sdk-linux.tar.xz
93+
path: packaging-scripts/output/swiftwasm-sdk-linux.tar.xz
8494

8595
- name: Upload hello.wasm compiled with Linux package
8696
uses: actions/upload-artifact@v1
8797
with:
8898
name: linux-hello.wasm
89-
path: swiftwasm-package-sdk/output/swiftwasm-sdk/hello.wasm
99+
path: packaging-scripts/output/swiftwasm-sdk/hello.wasm
90100

91101
macos_smoke_test:
92102
name: Compile hello.swift on macOS

utils/webassembly/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
compiler
2+
swiftwasm-sdk
3+
prebuilt
4+
output
5+
tmpdir

utils/webassembly/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Creates packages containing everything needed to build WebAssembly programs with Swift.
2+
3+
# Building
4+
5+
```
6+
./download-prebuilts.sh
7+
./download-installable-prebuilts.sh
8+
./build-packages.sh
9+
```
10+
11+
# Contents of package
12+
13+
- Swift toolchain from [swiftwasm-sdk](https://github.com/swiftwasm/swiftwasm-sdk)
14+
- WASI modified sysroot from [wasi-sdk](https://github.com/swiftwasm/wasi-sdk)
15+
- libicu from [icu4c-wasi](https://github.com/swiftwasm/icu4c-wasi)
16+
- linking helpers from [swiftwasm-wasi-stubs](https://github.com/swiftwasm/swiftwasm-wasi-stubs)
17+
- wasi-ld, either from wasi-sdk (on Linux) or upstream LLVM 9.0 (on Mac)
18+
- build script for compiling a Swift file to a .wasm
19+
- a Getting Started guide
20+
21+
# Notes
22+
23+
This shares a lot with the [swiftwasm-compile-service](https://github.com/swiftwasm/swiftwasm-compile-service).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
echo "Unpacking Linux prebuilts"
4+
mkdir -p output
5+
cd linux
6+
./unpack-prebuilts.sh
7+
echo "Compressing"
8+
tar cJf ../output/swiftwasm-sdk-linux.tar.xz swiftwasm-sdk
9+
cd ..
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
echo "Unpacking macOS prebuilts"
4+
mkdir -p output
5+
cd macos
6+
./unpack-prebuilts.sh
7+
echo "Compressing macOS package"
8+
tar cJf ../output/swiftwasm-sdk-macos.tar.xz swiftwasm-sdk
9+
cd ..

utils/webassembly/build-packages.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
rm -rf output || true
4+
./build-linux-package.sh
5+
./build-mac-package.sh
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e
3+
cp -r ../sdkroot/* compiler/
4+
cp ../linux/compiler/opt/swiftwasm-sdk/lib/swift/wasm/wasm32/glibc.modulemap compiler/extra_utils
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
mkdir -p prebuilt
4+
cd prebuilt
5+
wget -O swiftwasm-linux.tar.gz https://github.com/swiftwasm/swiftwasm-sdk/releases/download/20191112.1.linux/swiftwasm.tar.gz
6+
# Mac specific
7+
wget -O swiftwasm-macos.tar.gz https://github.com/swiftwasm/swiftwasm-sdk/releases/download/20191112.1.mac/swiftwasm-mac.tar.gz
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
mkdir -p prebuilt
4+
cd prebuilt
5+
wget https://github.com/swiftwasm/wasi-sdk/releases/download/20191022.1/wasi-sdk-4.39g3025a5f47c04-linux.tar.gz
6+
wget https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz
7+
# Mac specific
8+
wget http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-darwin-apple.tar.xz
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
rm -rf swiftwasm-sdk compiler
4+
mkdir swiftwasm-sdk
5+
ln -s swiftwasm-sdk compiler
6+
cd compiler
7+
untar="../../prebuilt/wasi-sdk-"*"-linux.tar.gz
8+
../../prebuilt/swiftwasm-linux.tar.gz
9+
../../prebuilt/icu4c-wasi.tar.xz"
10+
for i in $untar
11+
do
12+
echo $i
13+
tar xf $i
14+
done
15+
cd ..
16+
mv "compiler/wasi-sdk-"* "compiler/wasi-sdk"
17+
mv compiler/wasi-sdk/share/wasi-sysroot compiler/wasi-sdk/share/sysroot
18+
../remove-swift-extra-files.sh || true
19+
../remove-wasi-extra-files.sh || true
20+
../copy-shared-files.sh || true

0 commit comments

Comments
 (0)