-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdjamcompile
executable file
·70 lines (52 loc) · 1.77 KB
/
djamcompile
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
#!/bin/bash
IDIR="${BASH_SOURCE%/*}"
if [[ ! -d "$IDIR" ]]; then IDIR="$PWD"; fi
source "$IDIR/inc/misc_tools.sh"
# Spin up the build container if it is not there.
# No need to spin up if the container is already there
# Copy the files into the container
# Run the jamc compiler in the container using 'docker exec..'
# Get the results back - copy the .jxe file back to the original folder
#
show_usage() {
cat << EOF
djamcompile or djamcompile -h or djamcompile --help prints this help
information.
djamcompile f1.jxe f2.c
compiles f1.js and f2.c to obtain f1.jxe. Here, the source files are
copied into the docker container and the compiler is run in the container.
The resulting file f1.jxe is copied back to the host.
EOF
}
make_container() {
local type=$1
local contname=$2
local dockerImage=`cat $jamfolder/dockerImage`
create_missingdir $jamfolder/type
create_missingdir $jamfolder/type/contname
# Just kill the older container and recreate a new one.
docker kill $contname
docker rm $contname
local dockerSer=`docker run -it -d --privileged --name $contname $dockerImage`
local dockerSer=${dockerSer:0:12}
echo $dockerSer > $jamfolder/type/contname/dockerId
echo "1" > $jamfolder/type/contname/refCount
}
jamfolder=$HOME"/__jamruns"
exit_missingdir $jamfolder "JAMScript not setup in the system."
exit_missingfile $jamfolder/dockerImage "Run djam pull repository"
dbuildc="dbuildctnr-"$UID
make_container test $dbuildc
efile=
for f in $@; do
if [ $f != "-d" ]; then
docker cp $f $dbuildc:/home/admin/temp/$f
efile+=" /home/admin/temp/$f"
else
efile+=" -d"
fi
done
docker exec -it $dbuildc jamc $efile
filename=$1
jxefile="${filename%.*}.jxe"
docker cp $dbuildc:/home/admin/temp/$jxefile $jxefile