Skip to content

Commit f362ec8

Browse files
committed
Merge pyodide build scripts
1 parent a16f9d1 commit f362ec8

File tree

5 files changed

+120
-78
lines changed

5 files changed

+120
-78
lines changed

.github/workflows/ci-emscripten.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,11 @@ jobs:
5050
path: ${{ github.workspace }}/wasm-library-dir
5151
key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_libgmp.sh', 'bin/pyodide_build_libmpfr.sh', 'bin/pyodide_build_flint.sh') }}-0
5252

53-
- name: Build libgmp
53+
- name: Build GMP, MPFR and FLINT
5454
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
5555
env:
5656
CFLAGS: "-fPIC"
57-
WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir
58-
run: bin/pyodide_build_libgmp.sh
59-
60-
- name: Build libmpfr
61-
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
62-
env:
63-
CFLAGS: "-fPIC"
64-
WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir
65-
run: bin/pyodide_build_libmpfr.sh
66-
67-
- name: Build flint
68-
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
69-
env:
70-
CFLAGS: "-fPIC"
71-
WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir
72-
run: bin/pyodide_build_flint.sh
57+
run: bin/pyodide_build_dependencies.sh --wasm-library-dir ${{ github.workspace }}/wasm-library-dir
7358

7459
- name: Persist WASM library directory to cache
7560
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2

bin/pyodide_build_dependencies.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
while [[ $# -gt 0 ]]
6+
do
7+
key="$1"
8+
case $key in
9+
-h|--help)
10+
echo "bin/pyodide_build_dependencies.sh [options]"
11+
echo
12+
echo "Build local emscripten installs of python-flint's dependencies."
13+
echo
14+
echo "Supported options:"
15+
echo " --help - show this help message"
16+
echo " --wasm-library-dir <WASM_LIBRARY_DIR> - directory to install libraries"
17+
echo " --flint-commit <FLINT_COMMIT> - flint commit to build"
18+
echo
19+
exit
20+
;;
21+
--wasm-library-dir)
22+
# e.g. --wasm-library-dir /path/to/wasm-library-dir
23+
WASM_LIBRARY_DIR="$2"
24+
shift
25+
shift
26+
;;
27+
--flint-commit)
28+
# e.g. --flint-commit 3.3.1
29+
FLINT_COMMIT="$2"
30+
shift
31+
shift
32+
;;
33+
*)
34+
2>&1 echo "unrecognised argument:" $key
35+
exit 1
36+
;;
37+
esac
38+
done
39+
40+
41+
if [ -z "$WASM_LIBRARY_DIR" ]; then
42+
echo "WASM_LIBRARY_DIR not set"
43+
exit 1
44+
fi
45+
46+
source bin/build_variables.sh
47+
48+
49+
# ---------------------------Build GMP ----------------------------------#
50+
51+
52+
curl -L https://ftp.gnu.org/gnu/gmp/gmp-$GMPVER.tar.xz -o gmp-$GMPVER.tar.xz
53+
tar -xf gmp-$GMPVER.tar.xz
54+
55+
cd gmp-$GMPVER
56+
57+
emconfigure ./configure \
58+
--disable-dependency-tracking \
59+
--host none \
60+
--disable-shared \
61+
--enable-static \
62+
--enable-cxx \
63+
--prefix=$WASM_LIBRARY_DIR
64+
65+
emmake make -j $(nproc)
66+
emmake make install
67+
68+
cd ..
69+
70+
71+
# ---------------------------Build MPFR ----------------------------------#
72+
73+
74+
curl -L https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER.tar.xz -o mpfr-$MPFRVER.tar.xz
75+
tar -xf mpfr-$MPFRVER.tar.xz
76+
77+
cd mpfr-$MPFRVER
78+
79+
emconfigure ./configure \
80+
--disable-dependency-tracking \
81+
--disable-shared \
82+
--with-gmp=$WASM_LIBRARY_DIR \
83+
--prefix=$WASM_LIBRARY_DIR
84+
85+
emmake make -j $(nproc)
86+
emmake make install
87+
88+
cd ..
89+
90+
91+
# ---------------------------Build FLINT----------------------------------#
92+
93+
94+
if [ -z "$FLINT_COMMIT" ]; then
95+
git clone https://github.com/flintlib/flint --branch $FLINT_COMMIT
96+
cd flint
97+
else
98+
curl -O -L https://github.com/flintlib/flint/releases/download/v$FLINTVER/flint-$FLINTVER.tar.gz
99+
tar xf flint-$FLINTVER.tar.gz
100+
cd flint-$FLINTVER
101+
fi
102+
103+
./bootstrap.sh
104+
105+
emconfigure ./configure \
106+
--disable-dependency-tracking \
107+
--disable-shared \
108+
--prefix=$WASM_LIBRARY_DIR \
109+
--with-gmp=$WASM_LIBRARY_DIR \
110+
--with-mpfr=$WASM_LIBRARY_DIR \
111+
--host=wasm32-unknown-emscripten \
112+
--disable-assembly \
113+
--disable-pthread
114+
115+
emmake make -j $(nproc)
116+
emmake make install
117+
118+
cd ..

bin/pyodide_build_flint.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

bin/pyodide_build_libgmp.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

bin/pyodide_build_libmpfr.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)