Skip to content

Commit

Permalink
Use a submodule to manage brotli dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Mar 10, 2022
1 parent c5f122e commit 6d17fc8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
with:
token: ${{ secrets.PRIVATE_CHECKOUT }}
submodules: recursive

- name: Install Ubuntu dependencies
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "fastcache"]
path = fastcache
url = [email protected]:OffchainLabs/fastcache.git
[submodule "brotli"]
path = brotli
url = https://github.com/google/brotli.git
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,17 @@ solgen/test/prover/proofs/%.json: arbitrator/prover/test-cases/%.wasm $(arbitrat
yarn --cwd solgen install
@touch $@

.make/cbrotli-lib: | .make
@printf "%btesting cbrotli local build exists. If this step fails, see ./build-brotli.sh -l -h%b\n" $(color_pink) $(color_reset)
.make/cbrotli-lib: brotli/c/** | .make
@printf "%btesting cbrotli local build exists. If this step fails, run ./build-brotli.sh -l%b\n" $(color_pink) $(color_reset)
test -f target/include/brotli/encode.h
test -f target/include/brotli/decode.h
test -f target/lib/libbrotlicommon-static.a
test -f target/lib/libbrotlienc-static.a
test -f target/lib/libbrotlidec-static.a
@touch $@

.make/cbrotli-wasm: | .make
@printf "%btesting cbrotli wasm build exists. If this step fails, see ./build-brotli.sh -w -h%b\n" $(color_pink) $(color_reset)
.make/cbrotli-wasm: brotli/c/** | .make
@printf "%btesting cbrotli wasm build exists. If this step fails, run ./build-brotli.sh -w%b\n" $(color_pink) $(color_reset)
test -f target/lib-wasm/libbrotlicommon-static.a
test -f target/lib-wasm/libbrotlienc-static.a
test -f target/lib-wasm/libbrotlidec-static.a
Expand Down
1 change: 1 addition & 0 deletions brotli
Submodule brotli added at f4153a
43 changes: 15 additions & 28 deletions build-brotli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@ BUILD_WASM=false
BUILD_LOCAL=false
USE_DOCKER=false
TARGET_DIR=target/
SOURCE_DIR=target/src/brotli
COMMIT_ID=f4153a09f87cb # v1.0.9 + fixes required for cmake
REPO_URL=https://github.com/google/brotli.git
SOURCE_DIR=brotli

usage(){
echo "brotli builder for arbitrum"
echo
echo "usage: $0 [options]"
echo
echo "use one or more of:"
echo " w build wasm (uses emscripten)"
echo " l build local"
echo " -w build wasm (uses emscripten)"
echo " -l build local"
echo
echo "to avoid dependencies you might want:"
echo " d build inside docker container"
echo " -d build inside docker container"
echo
echo "Other options:"
echo " s source dir (will be created if doesn't exist) default: $SOURCE_DIR"
echo " t target dir default: $TARGET_DIR"
echo " c commit id (pass empty string to disable checkout) default: $COMMIT_ID"
echo " h help"
echo " -s source dir default: $SOURCE_DIR"
echo " -t target dir default: $TARGET_DIR"
echo " -h help"
echo
echo "all relative paths are relative to script location"
}
Expand All @@ -55,9 +52,6 @@ while getopts "s:t:c:wldh" option; do
s)
SOURCE_DIR="$OPTARG"
;;
c)
COMMIT_ID="$OPTARG"
;;
esac
done

Expand All @@ -82,30 +76,23 @@ if $USE_DOCKER; then
exit 0
fi

if [ ! -d "$SOURCE_DIR" ]; then
git clone $REPO_URL "$SOURCE_DIR"
fi
cd "$SOURCE_DIR"
if [ ! -z $COMMIT_ID ]; then
git checkout $COMMIT_ID
fi

if $BUILD_WASM; then
mkdir -p build-wasm
mkdir -p install-wasm
TEMP_INSTALL_DIR_ABS=`cd -P install-wasm; pwd`
cd build-wasm
cmake ../ -DCMAKE_C_COMPILER=emcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fPIC -DCMAKE_INSTALL_PREFIX="$TEMP_INSTALL_DIR_ABS" -DCMAKE_AR=`which emar` -DCMAKE_RANLIB=`which touch`
mkdir -p buildfiles/build-wasm
mkdir -p buildfiles/install-wasm
TEMP_INSTALL_DIR_ABS=`cd -P buildfiles/install-wasm; pwd`
cd buildfiles/build-wasm
cmake ../../ -DCMAKE_C_COMPILER=emcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fPIC -DCMAKE_INSTALL_PREFIX="$TEMP_INSTALL_DIR_ABS" -DCMAKE_AR=`which emar` -DCMAKE_RANLIB=`which touch`
make -j
make install
cp -rv "$TEMP_INSTALL_DIR_ABS/lib" "$TARGET_DIR_ABS/lib-wasm"
cd ..
fi

if $BUILD_LOCAL; then
mkdir -p build-local
cd build-local
cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$TARGET_DIR_ABS"
mkdir -p buildfiles/build-local
cd buildfiles/build-local
cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$TARGET_DIR_ABS"
make -j
make install
cd ..
Expand Down

0 comments on commit 6d17fc8

Please sign in to comment.