-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_enso.sh
executable file
·132 lines (115 loc) · 3.49 KB
/
run_enso.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
pushd $(dirname $0) > /dev/null
source .direnv/python*/bin/activate
export PYTHONPATH=./:$PYTHONPATH
readonly COMPILED_DIR=.
readonly COMPILE_ENSO_COMMANDS=false
print_usage() {
read -r -d '' USAGE<<EOF
Usage: $(basename $0) [options] [enso-options]
Where options can be:
--usage:\t\tSimple usage
--recompile\t\tForce recompilation to binary
--recompile-full\t\tForce full recompilation
--run-compiled\tRun compiled binary (will compile if no binary exists)
Enso-options:
EOF
echo -e "$USAGE"
python2 scripts/run_enso.py -h | sed "0,/^Options:/d"
}
get_enso_commands_dir() {
# Read Enso config and obtain location of Enso commands folder
python2 scripts/run_enso.py --get-config-var SCRIPTS_FOLDER_NAME
}
get_enso_commands() {
# List Enso commands files
find "$(get_enso_commands_dir)" -maxdepth 1 -name "*.py" | grep -v "_windows."
}
# Read commandline args
SKIP_ARGS=0
for arg in $@
do
if [ "$arg" == "--usage" -o "$arg" == "--help" ]; then
SKIP_ARGS=$(( SKIP_ARGS + 1))
print_usage
exit 0
elif [ "$arg" == "--recompile" ]; then
SKIP_ARGS=$(( SKIP_ARGS + 1))
RECOMPILE=true
elif [ "$arg" == "--recompile-full" ]; then
SKIP_ARGS=$(( SKIP_ARGS + 1))
RECOMPILE_FULL=true
elif [ "$arg" == "--run-compiled" ]; then
SKIP_ARGS=$(( SKIP_ARGS + 1))
RUN_COMPILED=true
else
# Any other params will be appended to Enso
break
fi
done
# Rotate away args so that only Enso args remain
if [ $SKIP_ARGS -gt 0 ]; then
shift $SKIP_ARGS
fi
# Is recompilation needed?
if [ "$RECOMPILE" = true -o "$RUN_COMPILED" = true -a ! -x "./enso.bin" ]; then
if [ ! -d "$COMPILED_DIR" ]; then
mkdir -p "$COMPILED_DIR"
fi
PLUGIN_INCLUDES=
if [ "$COMPILE_ENSO_COMMANDS" = true ]; then
for plugin in $(get_enso_commands)
do
PLUGIN_INCLUDES="$PLUGIN_INCLUDES --include-plugin-file=$plugin"
done
fi
export NUITKA_CCACHE_BINARY=$(which ccache)
CLANG_INSTALLED=$(type clang 2>&1 >/dev/null && echo "true")
[ "$CLANG_INSTALLED" = true ] || echo "WARNING: Clang compiler is not installed, falling back to gcc."
# Compile Enso
python2 -m nuitka --show-modules --output-dir="$COMPILED_DIR" -o enso.bin \
$([ "$CLANG_INSTALLED" = true ] && echo "--clang") \
--lto --jobs=8 --plugin-enable=multiprocessing --python-flag="-O" \
$([ "$RECOMPILE_FULL" = true ] && echo "--follow-imports") \
--include-module=enso \
--include-module=enso.contrib \
--include-module=backports \
--include-module=dbus \
--include-module=pyparsing \
--include-module=bs4 \
--include-module=gtk \
--include-module=Xlib \
--include-module=gio \
--include-module=cairo \
--include-module=contextlib2 \
--include-module=psutil \
--include-module=six \
--include-module=watchdog \
--include-module=xdg \
--include-plugin-file=enso/contrib/calc/exchangerates/updater.py \
$PLUGIN_INCLUDES \
--nofollow-import-to=enso.platform.win32 \
--nofollow-import-to=enso.platform.osx \
--nofollow-import-to=enso.contrib.open.platform.win32 \
--nofollow-import-to=feedparser \
./scripts/run_enso.py
if [ $? -ne 0 ]; then
exit
fi
if [ ! -x "./enso.bin" ]; then
echo "Can't find the binary enso.bin, compilation probably failed!"
exit 1
fi
#mv $COMPILED_DIR/enso.bin ./enso.bin
fi
if [ "$RUN_COMPILED" = true ]; then
pkill -f "python2.*enso"
pkill -x "enso.bin"
./enso.bin $@
else
pkill -f "python2.*enso"
pkill -x "enso.bin"
python2 scripts/run_enso.py $@
fi
deactivate
popd