-
Notifications
You must be signed in to change notification settings - Fork 30
Support building on macOS to develop this project #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7b563cc
544c068
1de0656
3998824
f4c2205
1b3daf9
08549c7
cad6531
19ca6b1
eb76d92
f09c370
258f25e
8d90ac3
8c87d29
72cd605
5e3916e
a089ff2
a19bb18
b320192
6e88e0a
df43f21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- swiftwasm | ||
|
||
jobs: | ||
linux_build: | ||
timeout-minutes: 0 | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Run a multi-line script | ||
run: | | ||
sudo apt update | ||
sudo apt install \ | ||
git ninja-build clang python \ | ||
uuid-dev libicu-dev icu-devtools libbsd-dev \ | ||
libedit-dev libxml2-dev libsqlite3-dev swig \ | ||
libpython-dev libncurses5-dev pkg-config \ | ||
libblocksruntime-dev libcurl4-openssl-dev \ | ||
systemtap-sdt-dev tzdata rsync | ||
./utils/update-checkout --clone --scheme wasm | ||
git checkout $GITHUB_SHA | ||
export sourcedir=$PWD/.. | ||
cd $sourcedir | ||
wget -O install_cmake.sh "https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.sh" | ||
chmod +x install_cmake.sh | ||
sudo mkdir -p /opt/cmake | ||
sudo ./install_cmake.sh --skip-license --prefix=/opt/cmake | ||
sudo ln -sf /opt/cmake/bin/* /usr/local/bin | ||
cmake --version | ||
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz | ||
tar xfz wasi-sdk.tar.gz | ||
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk | ||
wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz" | ||
tar xf icu.tar.xz | ||
cd swift | ||
utils/build-script --release --wasm --verbose \ | ||
--skip-build-benchmarks \ | ||
--extra-cmake-options=" \ | ||
-DSWIFT_SDKS='WASM;LINUX' \ | ||
-DSWIFT_BUILD_SOURCEKIT=FALSE \ | ||
-DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ | ||
" \ | ||
--build-stdlib-deployment-targets "wasm-wasm32" \ | ||
--build-swift-static-stdlib \ | ||
--install-destdir="$sourcedir/install" \ | ||
--install-prefix="/opt/swiftwasm-sdk" \ | ||
--install-swift \ | ||
--installable-package="$sourcedir/swiftwasm.tar.gz" \ | ||
--llvm-targets-to-build "X86;WebAssembly" \ | ||
--stdlib-deployment-targets "wasm-wasm32" \ | ||
--wasm-icu-data "todo-icu-data" \ | ||
--wasm-icu-i18n "$sourcedir/icu_out/lib" \ | ||
--wasm-icu-i18n-include "$sourcedir/icu_out/include" \ | ||
--wasm-icu-uc "$sourcedir/icu_out/lib" \ | ||
--wasm-icu-uc-include "$sourcedir/icu_out/include" \ | ||
--wasm-wasi-sdk "$sourcedir/wasi-sdk" | ||
macos_build: | ||
timeout-minutes: 0 | ||
runs-on: macOS-10.14 | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Run a multi-line script | ||
run: | | ||
brew install cmake ninja | ||
./utils/update-checkout --clone --scheme wasm | ||
git checkout $GITHUB_SHA | ||
export sourcedir=$PWD/.. | ||
cd $sourcedir | ||
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz | ||
tar xfz wasi-sdk.tar.gz | ||
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk | ||
# Link sysroot/usr/include to sysroot/include because Darwin sysroot doesn't | ||
# find header files in sysroot/include but sysroot/usr/include | ||
mkdir wasi-sdk/share/sysroot/usr/ | ||
ln -s ../include wasi-sdk/share/sysroot/usr/include | ||
wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz" | ||
tar xf icu.tar.xz | ||
cd swift | ||
./utils/build-script --release --wasm --verbose \ | ||
--skip-build-benchmarks \ | ||
--extra-cmake-options=" \ | ||
-DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ | ||
-DSWIFT_PRIMARY_VARIANT_ARCH:STRING=wasm32 \ | ||
-DSWIFT_OSX_x86_64_ICU_STATICLIB=TRUE \ | ||
-DSWIFT_BUILD_SOURCEKIT=FALSE \ | ||
-DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ | ||
" \ | ||
--build-stdlib-deployment-targets "wasm-wasm32" \ | ||
--build-swift-dynamic-sdk-overlay false \ | ||
--build-swift-static-sdk-overlay false \ | ||
--build-swift-static-stdlib \ | ||
--llvm-targets-to-build "X86;WebAssembly" \ | ||
--stdlib-deployment-targets "wasm-wasm32" \ | ||
--wasm-icu-data "todo-icu-data" \ | ||
--wasm-icu-i18n "$sourcedir/icu_out/lib" \ | ||
--wasm-icu-i18n-include "$sourcedir/icu_out/include" \ | ||
--wasm-icu-uc "$sourcedir/icu_out/lib" \ | ||
--wasm-icu-uc-include "$sourcedir/icu_out/include" \ | ||
--wasm-wasi-sdk "$sourcedir/wasi-sdk" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,7 +416,7 @@ extension __StringStorage { | |
let count = try initializer(buffer) | ||
|
||
let countAndFlags = CountAndFlags(mortalCount: count, isASCII: false) | ||
#if arch(i386) || arch(arm) | ||
#if arch(i386) || arch(arm) || arch(wasm32) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines are added by upstream Swift |
||
storage._count = countAndFlags.count | ||
storage._flags = countAndFlags.flags | ||
#else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//===--- SwiftRT-WASM.cpp --------------------------------------------------===// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I separated SwiftRT file to distinguish ELF and WASM. |
||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved
set(CMAKE_AR ...)
line to use prebuilt llvm-ar only on Linux.In macOS environment, this hack is unnecessary.