@@ -10,37 +10,42 @@ String dockerfile = r"""
1010FROM debian:bookworm
1111
1212# Install dependenices
13- RUN apt-get update -y \
14- && apt-get install -y autoconf libtool build-essential git wget
13+ RUN apt-get update -y && apt-get install -y cmake git wget
1514
1615# Download and install wasi-sdk
1716
18- ENV WASI_VERSION=19
17+ ENV WASI_VERSION=27
1918ENV WASI_VERSION_FULL=${WASI_VERSION}.0
20- ENV WASI_SDK_PATH=/wasi-sdk-${WASI_VERSION_FULL}
21- ENV WASI_ARCHIVE=wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
19+ ENV WASI_SDK_PATH=/wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux
20+ ENV WASI_ARCHIVE=wasi-sdk-${WASI_VERSION_FULL}-x86_64- linux.tar.gz
2221
2322RUN wget -nv https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/$WASI_ARCHIVE
2423RUN tar xvf $WASI_ARCHIVE
2524RUN rm $WASI_ARCHIVE
2625
27- # Clone libsecp256k1 and use v0.5 .0
28- RUN git clone https://github.com/bitcoin-core /secp256k1 \
29- && cd secp256k1 \
30- && git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65
31- WORKDIR /secp256k1
26+ # Clone secp256k1-coinlib and use v0.7 .0
27+ RUN git clone https://github.com/peercoin /secp256k1-coinlib \
28+ && cd secp256k1-coinlib \
29+ && git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e
30+ WORKDIR /secp256k1-coinlib
3231
3332# Build using wasi-sdk
34- RUN ./autogen.sh
35- RUN ./configure \
36- --enable-module-recovery --disable-tests --disable-shared \
37- --disable-exhaustive-tests --disable-benchmark \
38- --with-sysroot=${WASI_SDK_PATH}/share/wasi-sysroot \
39- --host=wasm32 --target=wasm32-unknown-wasi \
40- CFLAGS="-O2 -fPIC" CC=${WASI_SDK_PATH}/bin/clang
41- RUN make
33+ RUN cmake -B build \
34+ -DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
35+ -DSECP256K1_BUILD_TESTS=OFF \
36+ -DSECP256K1_DISABLE_SHARED=ON \
37+ -DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
38+ -DSECP256K1_BUILD_BENCHMARK=OFF \
39+ -DSECP256K1_BUILD_EXAMPLES=OFF \
40+ -DSECP256K1_BUILD_CTIME_TESTS=OFF \
41+ -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk.cmake \
42+ -DCMAKE_C_FLAGS="-O2 -fPIC" \
43+ -DCMAKE_BUILD_TYPE=Release
44+ RUN cmake --build build
4245
4346# Link output with wasi standard library and export required functions
47+ # wasm-ld is a bit broken as it requires manual inclusion of necessary symbols
48+ # but it works. Using clang to link would probably be better.
4449RUN mkdir output
4550RUN ${WASI_SDK_PATH}/bin/wasm-ld \
4651 -o output/secp256k1.wasm \
@@ -72,15 +77,13 @@ RUN ${WASI_SDK_PATH}/bin/wasm-ld \
7277 --export secp256k1_schnorrsig_sign32 \
7378 --export secp256k1_schnorrsig_verify \
7479 --export secp256k1_ecdh \
75- # The secp256k1 library object files
76- src/libsecp256k1_la-secp256k1.o \
77- src/libsecp256k1_precomputed_la-precomputed_ecmult.o \
78- src/libsecp256k1_precomputed_la-precomputed_ecmult_gen.o \
80+ # The secp256k1 library file
81+ build/lib/libsecp256k1.a \
7982 # Need to include libc for wasi here as it isn't done for us
8083 ${WASI_SDK_PATH}/share/wasi-sysroot/lib/wasm32-wasi/libc.a \
8184 # Need to include another library from clang that isn't included either
8285 # See https://github.com/WebAssembly/wasi-libc/issues/98
83- ${WASI_SDK_PATH}/lib/clang/15.0.7 /lib/wasi/libclang_rt.builtins-wasm32 .a
86+ ${WASI_SDK_PATH}/lib/clang/20 /lib/wasm32-unknown- wasi/libclang_rt.builtins.a
8487""" ;
8588
8689void binaryFileToDart (String inPath, String outPath, String name) {
0 commit comments