-
Notifications
You must be signed in to change notification settings - Fork 1
/
hpgcc.sh
66 lines (55 loc) · 1.61 KB
/
hpgcc.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
#!/bin/env bash
# grab current user name info
VERSION="0.5b1"
HOSTUID=$(id -u)
HOSTGID=$(id -g)
HOSTUSER=$(id -un)
HOSTGROUP=$(id -gn)
printHelp() {
echo "HPGCC3 cross compiler assitant script version $VERSION"
echo "NOTE: Images are non-persistant and will not keep any data across runs."
echo "USAGE: hpgcc.sh [special options] [command to run in image]"
echo "invoke with a command to run the command in the cross compiler docker image"
echo "all commands are run in current working dir\n"
echo "Common tools:"
echo " * make: GNU make"
echo " * arm-eabi-none-** : arm cross-compile tools\n"
echo "Special options for this script:"
echo " --script -s"
echo " output this scipt to stdout"
echo " --make -m"
echo " automake the current dir with default options"
}
case $1 in
--help|-h)
printHelp
exit 0
;;
--make|-m)
SOPTS="bash -c /hpgcc3/amake.sh"
;;
--script|-s)
SOPTS="cat /hpgcc3/hpgcc.sh"
;;
'')
printHelp
exit 0
;;
*)
;;
esac
CONTAINER_NAME=hpgcc3_$RANDOM
if ! [[ $SOPTS ]]; then
docker run --name $CONTAINER_NAME -it -v $PWD:/work \
-e HOST_UID=$HOSTUID -e HOST_GID=$HOSTGID \
-e HOST_USER=$HOSTUSER -e HOST_GROUP=$HOSTGROUP \
hpgcc "$@"
else
docker run --name $CONTAINER_NAME -it -v $PWD:/work \
-e HOST_UID=$HOSTUID -e HOST_GID=$HOSTGID \
-e HOST_USER=$HOSTUSER -e HOST_GROUP=$HOSTGROUP \
hpgcc $SOPTS
fi
RUN_EXIT_CODE=$?
docker rm $CONTAINER_NAME
exit $RUN_EXIT_CODE