Skip to content

Commit

Permalink
include async build in release
Browse files Browse the repository at this point in the history
separate output files for async build
  • Loading branch information
petersalomonsen committed Dec 23, 2023
1 parent ef94ffd commit b31a29d
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 21 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ jobs:
set -e
npm run test
npm run test-browser
./preparepublishnpm.sh
PACKAGEFILE=`npm pack | tail -n 1`
tar -xvzf $PACKAGEFILE
rm test-browser/lg2.*
echo "run browser tests with npm package"
cp package/lg2.* test-browser/
npm run test-browser
asyncify:
name: Asyncify
runs-on: ubuntu-latest
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ jobs:
source ./emsdk/emsdk_env.sh
cd emscriptenbuild
./build.sh Release
./build.sh Release-async
cd ..
set -e
npm run test
npm run test-browser
export VERSION=`npm view wasm-git dist-tags.latest`
export NEWVERSION=`node -p "require('./package.json').version"`
echo $VERSION $NEWVERSION
./preparepublishnpm.sh
PACKAGEFILE=`npm pack | tail -n 1`
tar -xvzf $PACKAGEFILE
rm test-browser/lg2.*
echo "run browser tests with npm package"
cp package/lg2.* test-browser/
rm test-browser/lg2.*
cp package/lg2.* test-browser/
npm run test-browser
rm test-browser-async/lg2_async.*
cp package/lg2_async.* test-browser-async/
npm run test-browser-async
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$VERSION" = "$NEWVERSION" || "$BRANCH" != "master" ]]; then
echo "version change is $VERSION->$NEWVERSION, branch is $BRANCH, not publishing, only dry-run"
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project(wasm-git)
cmake_minimum_required(VERSION 3.0)
add_subdirectory(libgit2)
set_target_properties(lg2 PROPERTIES OUTPUT_NAME $ENV{LG2_OUTPUT_NAME})
6 changes: 5 additions & 1 deletion emscriptenbuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ POST_JS="--post-js $(pwd)/post.js"
# Reset in case we've done an '-async' build
cp ../libgit2patchedfiles/src/transports/emscriptenhttp.c ../libgit2/src/libgit2/transports/emscriptenhttp.c

export LG2_OUTPUT_NAME=lg2

# Set build type to Release for release
if [ "$1" == "Release" ]; then
BUILD_TYPE=Release
Expand All @@ -20,16 +22,18 @@ if [ "$1" == "Release-async" ]; then

EXTRA_CMAKE_C_FLAGS="-O3 $ASYNCIFY_FLAGS"
POST_JS="--post-js $(pwd)/post-async.js"
export LG2_OUTPUT_NAME=lg2_async
elif [ "$1" == "Debug-async" ]; then
BUILD_TYPE=Debug
cp ../libgit2patchedfiles/src/transports/emscriptenhttp-async.c ../libgit2/src/libgit2/transports/emscriptenhttp.c

EXTRA_CMAKE_C_FLAGS="$ASYNCIFY_FLAGS"
POST_JS="--post-js $(pwd)/post-async.js"
export LG2_OUTPUT_NAME=lg2_async
fi

# Before building, remove any ../libgit2/src/transports/emscriptenhttp.c left from running setup.sh
[ -f "../libgit2/src/libgit2/transports/emscriptenhttp-async.c" ] && rm ../libgit2/src/libgit2/transports/emscriptenhttp-async.c

emcmake cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="$EXTRA_CMAKE_C_FLAGS --pre-js $(pwd)/pre.js $POST_JS -s \"EXTRA_EXPORTED_RUNTIME_METHODS=['FS','callMain']\" -lnodefs.js -lidbfs.js -s INVOKE_RUN=0 -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=131072" -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DTHREADSAFE=OFF -DUSE_SSH=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=ON ../libgit2
emcmake cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="$EXTRA_CMAKE_C_FLAGS --pre-js $(pwd)/pre.js $POST_JS -s \"EXTRA_EXPORTED_RUNTIME_METHODS=['FS','callMain']\" -lnodefs.js -lidbfs.js -s INVOKE_RUN=0 -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=131072" -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DTHREADSAFE=OFF -DUSE_SSH=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=ON ..
emmake make lg2
2 changes: 1 addition & 1 deletion karma.conf-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
{pattern: 'lg2.*', included: false},
{pattern: 'lg2_async.*', included: false},
// {pattern: 'async-test.js', included: false},
{pattern: '**/*.spec.js'}
],
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"files": [
"lg2.js",
"lg2.wasm",
"lg2_async.js",
"lg2_async.wasm",
"README.md"
],
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions preparepublishnpm.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
set -e
echo "copy lg2.wasm and lg2.js from build folder"
cp emscriptenbuild/examples/lg2.wasm .
cp emscriptenbuild/examples/lg2.js .
cp emscriptenbuild/libgit2/examples/lg2.wasm .
cp emscriptenbuild/libgit2/examples/lg2.js .
cp emscriptenbuild/libgit2/examples/lg2_async.wasm .
cp emscriptenbuild/libgit2/examples/lg2_async.js .
echo "publish --dry-run (run npm publish to finalize)"
npm publish --dry-run
1 change: 0 additions & 1 deletion test-browser-async/lg2.js

This file was deleted.

1 change: 0 additions & 1 deletion test-browser-async/lg2.wasm

This file was deleted.

1 change: 1 addition & 0 deletions test-browser-async/lg2_async.js
1 change: 1 addition & 0 deletions test-browser-async/lg2_async.wasm
2 changes: 1 addition & 1 deletion test-browser-async/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('wasm-git', function() {
window.lg2Ready = true;
done();
}
scriptElement.src = 'base/lg2.js';
scriptElement.src = 'base/lg2_async.js';
document.documentElement.appendChild(scriptElement);
});

Expand Down
2 changes: 1 addition & 1 deletion test-browser/lg2.js
2 changes: 1 addition & 1 deletion test-browser/lg2.wasm
2 changes: 1 addition & 1 deletion test/lg2.js
2 changes: 1 addition & 1 deletion test/lg2.wasm

0 comments on commit b31a29d

Please sign in to comment.