-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·69 lines (68 loc) · 2.34 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh
#
# ---- Build script for chktex.js. ----
#
# On UNIX boxes with Emscripten installed on them, this should just work.
#
# To create a release build of chktex.js
#
# ./build.sh
#
# If all goes well running
#
# ./chktex.js --version
#
# Should work.
#
# To generate debug builds for development, try:
#
# ./build.sh --dev
#
# This will include source maps that I've found work in VSCode's node debugger
# (see .vscode/launch.json for an example of how to debug). It will also disable
# Emscripten optimisations that will make debugging easier.
#
#
# If you have trouble running this script, you can try explicitly running
#
# ./configure-js.sh
#
# To create a Makefile and then
#
# ./make-js.sh
#
# To have emscripten run it.
#
# The resulting commands the above will generate will very likely be the same
# As what is presented below, and will take a fair while (and scan for perl,
# latex and all sorts of stuff on your system), hence this simple build script.
FLAGS='-DHAVE_CONFIG_H -DSYSCONFDIR="/usr/local/etc" -D__unix__'
CFLAGS='-O3'
if [ "$1" == "--dev" ]; then
echo "---------- BUILDING DEVELOPMENT VERSION OF CHKTEX.JS -----------------"
CFLAGS='-g4'
else
echo "---------- BUILDING RELEASE VERSION OF CHKTEX.JS ---------------------"
fi
CFLAGS="$CFLAGS -Wstrict-prototypes -Wall"
echo "---------- 1/3 Cleaning existing files... ----------------------------"
rm *.bc chktex.js*
echo "---------- 2/3 Building... -------------------------------------------"
trap 'exit' ERR # bail on error
set -x # show the executed command
emcc $FLAGS $CFLAGS -c ChkTeX.c -o ChkTeX.bc
emcc $FLAGS $CFLAGS -c FindErrs.c -o FindErrs.bc
emcc $FLAGS $CFLAGS -c OpSys.c -o OpSys.bc
emcc $FLAGS $CFLAGS -c Resource.c -o Resource.bc
emcc $FLAGS $CFLAGS -c Utility.c -o Utility.bc
emcc $CFLAGS -o chktex.js ChkTeX.bc FindErrs.bc OpSys.bc Resource.bc Utility.bc --pre-js ./pre.js --memory-init-file 0 --embed-file chktexrc@/usr/local/etc/
set +x # show the executed command
echo "---------- 3/3 Converting to executable... ---------------------------"
echo "#!/usr/bin/env node" | cat - chktex.js > /tmp/out && mv /tmp/out chktex.js
chmod u+x chktex.js
echo "---------- Finished. Testing binary... -------------------------------"
./chktex.js --version
if [ "$1" != "--dev" ]; then
echo "---------- Cleaning up (build a --dev build to stop this) ------------"
rm *.bc
fi