-
Notifications
You must be signed in to change notification settings - Fork 1
/
compilescripts
executable file
·40 lines (34 loc) · 1.05 KB
/
compilescripts
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
#!/usr/bin/env bash
#
# simple script to compile the source text script files
OSACOMPILE=/usr/bin/osacompile
SRC_DIR=src
APPLESCRIPT_EXT=applescript
JAVASCRIPT_EXT=javascript
APPLESCRIPT_LANG=AppleScript
JAVASCRIPT_LANG=JavaScript
SCPT_DIR=script
SCPT_EXT=scpt
# delete the output dir
rm -rf $SCPT_DIR
# and then recreate it
mkdir -p $SCPT_DIR
find src -type d -depth 1 -exec basename {} \; | while read APPNAME
do
mkdir -p "$SCPT_DIR/$APPNAME"
# compile applescripts
find "$SRC_DIR/$APPNAME" -iname "*.$APPLESCRIPT_EXT" | while read SRC
do
SCPT=$(basename "$SRC" .$APPLESCRIPT_EXT).$SCPT_EXT
echo "Compiling $APPLESCRIPT_LANG $SRC...." >&2
$OSACOMPILE -l $APPLESCRIPT_LANG -o "$SCPT_DIR/$APPNAME/$SCPT" "$SRC"
done
# compile javascripts
find "$SRC_DIR/$APPNAME" -iname "*.$JAVASCRIPT_EXT" | while read SRC
do
SCPT=$(basename "$SRC" .$JAVASCRIPT_EXT).$SCPT_EXT
echo "Compiling $JAVASCRIPT_LANG $SRC...." >&2
$OSACOMPILE -l $JAVASCRIPT_LANG -o "$SCPT_DIR/$APPNAME/$SCPT" "$SRC"
done
done
echo "Done." >&2