Skip to content

Commit 7f812b8

Browse files
committed
build: Write all generated files to build/
1 parent 1353721 commit 7f812b8

File tree

6 files changed

+39
-39
lines changed

6 files changed

+39
-39
lines changed

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/z3-wasm/
21
/.vagrant/
3-
/provision.log
4-
/html/z3w.wasm
5-
/html/z3w.js
2+
/build/
63
/dist/
4+
/html/z3w.js
5+
/html/z3w.wasm
6+
/provision.log
7+
/upload.sh
78
/z3.wasm.tar.gz

README.rst

+10-6
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@ Pre-build archives are available at https://github.com/cpitclaudel/z3.wasm/relea
1111
Building
1212
========
1313

14+
In a VM
15+
-------
16+
1417
Install `Vagrant <https://www.vagrantup.com/>`_, then run this::
1518

1619
vagrant up
1720
vagrant ssh
1821
VAGRANT=true /vagrant/z3.sh
1922

20-
The first build can take up to two hours (emscripten may require a custom build of LLVM, Z3 is large, and all of this is running in a VM).
21-
The output is written to ``z3w.js``, ``z3w.wasm``, ``z3smt2w.js``, and ``z3smt2w.wasm``.
23+
The first build can take up to two hours (emscripten may require a custom build of LLVM, Z3 is large, and all of this is running in a VM). The output (``z3w.js``, ``z3w.wasm``, ``z3smt2w.js``, and ``z3smt2w.wasm``) is written to ``build/z3/``.
2224

23-
On Debian/Ubuntu systems, you may prefer to run natively (the build will be much faster)::
25+
Some Vagrant configurations can cause clang to crash or Vagrant to hang.
26+
Building on a physical machine is the most reliable workaround.
2427

25-
BASEDIR="$(pwd)/build/" ./z3.sh
28+
Natively
29+
--------
2630

27-
Some Vagrant configurations can cause clang to crash; in that case, building on a physical machine is the best workaround.
31+
On Debian/Ubuntu systems, you may prefer to build natively, which will be much faster. In that case, just run ``./z3.sh``, which will place all outputs in ``build/``.
2832

2933
Using the generated code
3034
========================
@@ -61,7 +65,7 @@ From a webpage the process is roughly the same: write Z3's input to a file using
6165

6266
This is all demoed in ``html/z3.html`` (that example also uses a WebWorker to run Z3, keeping the page responsive while it runs). Try it like this::
6367

64-
cp z3-wasm/z3/z3w.js z3-wasm/z3/z3w.wasm ./html
68+
cp build/z3/z3w.js build/z3/z3w.wasm ./html
6569
python3 -m http.server
6670
# Open your browser to http://localhost:8000/html/z3.html
6771

dist.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ rm -rf dist/ html/z3*w.*
33
mkdir dist
44
cp html/* dist/
55
cp README.dist.rst dist/README.rst
6-
cp z3-wasm/z3/z3smt2w.js z3-wasm/z3/z3smt2w.wasm z3-wasm/z3/z3w.js z3-wasm/z3/z3w.wasm dist/
6+
cp build/z3/z3smt2w.js build/z3/z3smt2w.wasm build/z3/z3w.js build/z3/z3w.wasm dist/
77
tar --create --gzip --file z3.wasm.tar.gz --transform 's|^dist|z3.wasm|' dist

z3.sh

+19-24
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,28 @@
2222

2323
# Notes:
2424
#
25-
# * If you see an error like this:
25+
# * If you see an error like this, upgrade to a more recent Ubuntu box:
2626
#
27-
# /vagrant/z3-wasm/emsdk-portable/clang/e1.37.36_64bit/llc:
27+
# /vagrant/build/emsdk-portable/clang/e1.37.36_64bit/llc:
2828
# /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not
29-
# found (required by /vagrant/z3-wasm/emsdk-portable/clang/e1.37.36_64bit/llc)
30-
#
31-
# Then upgrade to a more recent Ubuntu box
29+
# found (required by /vagrant/build/emsdk-portable/clang/e1.37.36_64bit/llc)
3230
#
3331
# * This script is only know to work on Ubuntu. You can run it locally, but in
3432
# that case DO NOT set VAGRANT=true.
3533

3634
: "${VAGRANT:=false}"
3735

3836
if [ "$VAGRANT" = true ]; then
39-
: "${BASEDIR:=/vagrant}"
37+
: "${BASEDIR:=/vagrant/}"
4038
else
41-
: "${BASEDIR:=$(pwd)/build}"
39+
: "${BASEDIR:=$(pwd)/}"
4240
fi
43-
mkdir -p "$BASEDIR"
44-
45-
export DEBIAN_FRONTEND=noninteractive
46-
47-
export JS_ROOT="$BASEDIR/z3-wasm/"
48-
export Z3_ROOT="${JS_ROOT}z3/"
49-
export EMSDK_ROOT="${JS_ROOT}emsdk-portable/"
50-
export EMSCRIPTEN_TEMPDIR="/tmp/emscripten"
5141

5242
export OPTLEVEL=3
43+
export BUILDDIR="${BASEDIR}build/"
44+
export Z3_ROOT="${BUILDDIR}z3/"
45+
export EMSDK_ROOT="${BUILDDIR}emsdk-portable/"
46+
export EMSCRIPTEN_TEMPDIR="/tmp/emscripten/"
5347

5448
function say() {
5549
printf "\033[1;32m%s\033[0m\n" "$1"
@@ -60,6 +54,8 @@ say '*********************************'
6054
say '*** Installing dependencies ***'
6155
say '*********************************'
6256

57+
export DEBIAN_FRONTEND=noninteractive
58+
6359
say '* apt-get update'; {
6460
sudo apt-get -y -q update
6561
}
@@ -86,12 +82,12 @@ say '*******************'
8682
say '*** Downloading ***'
8783
say '*******************'
8884

89-
rm -rf "$JS_ROOT"
90-
mkdir "$JS_ROOT"
85+
rm -rf "$BUILDDIR"
86+
mkdir "$BUILDDIR"
9187

9288
say '* wget emscripten'; {
9389
wget --quiet -O /tmp/emsdk-portable.tar.gz https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
94-
tar -xf /tmp/emsdk-portable.tar.gz -C "$JS_ROOT"
90+
tar -xf /tmp/emsdk-portable.tar.gz -C "$BUILDDIR"
9591
}
9692

9793
say '* git clone z3'; {
@@ -129,7 +125,7 @@ say '* Emscripten: setup'; {
129125

130126
# Don't source emsdk_env directly, as it produces output that can't be logged
131127
# without creating a subshell (which would break `source`)
132-
source "${EMSDK_ROOT}/emsdk_set_env.sh"
128+
source "${EMSDK_ROOT}emsdk_set_env.sh"
133129

134130
# emcc fails in all sorts of weird ways without this
135131
ulimit -s unlimited
@@ -138,8 +134,7 @@ say '* Emscripten: stdlib (very slow!)'; {
138134
mkdir -p "$EMSCRIPTEN_TEMPDIR"
139135
cd "$EMSCRIPTEN_TEMPDIR"
140136
printf '#include<stdio.h>\nint main() { return 0; }\n' > minimal.c
141-
# Adding to emcc here causes it to crash
142-
emcc -v minimal.c
137+
emcc minimal.c
143138
}
144139

145140
cd "$Z3_ROOT"
@@ -204,13 +199,13 @@ EMCC_WASM_OPTIONS=(
204199
# in a WebWorker anyway, so it wouldn't buy us much.
205200
-s BINARYEN_ASYNC_COMPILATION=0)
206201

207-
EMCC_Z3_JS_INPUTS=("${Z3_ROOT}/build/z3.bc")
208-
EMCC_Z3_SMT2_JS_INPUTS=("${BASEDIR}/z3smt2.c" "${Z3_ROOT}/build/libz3.a")
202+
EMCC_Z3_JS_INPUTS=("${Z3_ROOT}build/z3.bc")
203+
EMCC_Z3_SMT2_JS_INPUTS=("${BASEDIR}z3smt2.c" "${Z3_ROOT}build/libz3.a")
209204

210205
cd "$Z3_ROOT"
211206

212207
say '* Z3: Linking (slow!)'; {
213-
cp "${Z3_ROOT}/build/z3" "${Z3_ROOT}/build/z3.bc"
208+
cp "${Z3_ROOT}build/z3" "${Z3_ROOT}build/z3.bc"
214209
# emcc "${EMCC_Z3_OPTIONS[@]}" "${EMCC_Z3_JS_INPUTS[@]}" -o z3.js
215210
emcc "${EMCC_Z3_OPTIONS[@]}" "${EMCC_WASM_OPTIONS[@]}" "${EMCC_Z3_JS_INPUTS[@]}" -o z3w.js
216211
}

z3smt2test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
// SOFTWARE
2020

21-
process.chdir("./z3-wasm/z3/"); // To find the WASM file
22-
var Z3Factory = require('./z3-wasm/z3/z3smt2w.js');
21+
process.chdir("./build/z3/"); // To find the WASM file
22+
var Z3Factory = require('./build/z3/z3smt2w.js');
2323
var z3smt2 = Z3Factory();
2424

2525
var smt2API = {

z3test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
// SOFTWARE
2020

21-
process.chdir("./z3-wasm/z3/"); // To find the WASM file
22-
var Z3Factory = require("./z3-wasm/z3/z3w.js");
21+
process.chdir("./build/z3/"); // To find the WASM file
22+
var Z3Factory = require("./build/z3/z3w.js");
2323
var z3 = Z3Factory();
2424

2525
var FS = z3["FS"];

0 commit comments

Comments
 (0)