-
Notifications
You must be signed in to change notification settings - Fork 394
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
Add support for emscripten targets #106
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c828b03
Add emscripten targets
malbarbo 2aca86d
Add rust-itertools as build test for emscripten targets
malbarbo 79446d8
Add travis tests for emscripten targets
malbarbo 1a3a59c
Add tests for running examples and tests
malbarbo a016a0b
Explain how node-wasm works
malbarbo d1d7253
Add a note about lib problems on emscripten
malbarbo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM ubuntu:16.04 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
cmake \ | ||
gcc \ | ||
libc6-dev \ | ||
make \ | ||
pkg-config | ||
|
||
RUN apt-get install -y --no-install-recommends python | ||
|
||
COPY emscripten.sh / | ||
RUN bash /emscripten.sh | ||
|
||
COPY emscripten-entry.sh / | ||
ENTRYPOINT ["/emscripten-entry.sh"] | ||
|
||
ENV CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
export HOME=/tmp/ | ||
|
||
cp /emsdk-portable/.emscripten $HOME/ | ||
|
||
source /emsdk-portable/emsdk_env.sh &> /dev/null | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
set -ex | ||
|
||
main() { | ||
local dependencies=( | ||
ca-certificates | ||
cmake | ||
curl | ||
git | ||
python | ||
) | ||
|
||
apt-get update | ||
local purge_list=() | ||
for dep in ${dependencies[@]}; do | ||
if ! dpkg -L $dep; then | ||
apt-get install --no-install-recommends -y $dep | ||
purge_list+=( $dep ) | ||
fi | ||
done | ||
|
||
cd / | ||
curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ | ||
tar -xz | ||
cd /emsdk-portable | ||
|
||
./emsdk update | ||
./emsdk install latest | ||
./emsdk activate latest | ||
|
||
# Make emsdk usable by any user | ||
cp /root/.emscripten /emsdk-portable | ||
chmod a+r -R /emsdk-portable/ | ||
chmod a+x /emsdk-portable/emsdk | ||
chmod a+xw /emsdk-portable/ | ||
|
||
# Compile and cache libc | ||
source ./emsdk_env.sh | ||
echo "main(){}" > a.c | ||
emcc a.c | ||
emcc -s BINARYEN=1 a.c | ||
echo -e "#include <iostream>\n void hello(){ std::cout << std::endl; }" > a.cpp | ||
emcc a.cpp | ||
emcc -s BINARYEN=1 a.cpp | ||
rm -f a.* | ||
chmod a+rw -R /emsdk-portable/.emscripten_cache/ | ||
rm /emsdk-portable/.emscripten_cache.lock | ||
|
||
# Clean up | ||
apt-get purge --auto-remove -y ${purge_list[@]} | ||
|
||
rm $0 | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
path="$(dirname $1)" | ||
file="$(basename $1)" | ||
|
||
# Workaround for | ||
# https://github.com/kripken/emscripten/issues/4542 | ||
|
||
if [ "$(basename $path)" != "deps" ]; then | ||
path="$path/deps" | ||
fi | ||
|
||
cd "$path" | ||
|
||
if [ -f "$file" ]; then | ||
/node-*/bin/node "$file" | ||
else | ||
/node-*/bin/node "../$file" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
set -ex | ||
|
||
main() { | ||
local dependencies=( | ||
ca-certificates | ||
curl | ||
) | ||
|
||
apt-get update | ||
local purge_list=() | ||
for dep in ${dependencies[@]}; do | ||
if ! dpkg -L $dep; then | ||
apt-get install --no-install-recommends -y $dep | ||
purge_list+=( $dep ) | ||
fi | ||
done | ||
|
||
cd / | ||
curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ | ||
tar -xJ | ||
|
||
# Clean up | ||
apt-get purge --auto-remove -y ${purge_list[@]} | ||
|
||
rm $0 | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM ubuntu:16.04 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
cmake \ | ||
gcc \ | ||
libc6-dev \ | ||
make \ | ||
pkg-config | ||
|
||
RUN apt-get install -y --no-install-recommends python | ||
|
||
COPY emscripten.sh / | ||
RUN bash /emscripten.sh | ||
|
||
COPY node.sh / | ||
RUN bash /node.sh | ||
|
||
COPY emscripten-entry.sh / | ||
ENTRYPOINT ["/emscripten-entry.sh"] | ||
|
||
COPY node-wasm /usr/local/bin/ | ||
ENV CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add a comment here indicating what kind of paths we expect to see here and why we have to branch here and in the if below?