Skip to content

Commit

Permalink
replace scripts with a more powerful combined script
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgrayio committed Apr 30, 2018
1 parent 2e24a73 commit 6bbb9a6
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 20 deletions.
2 changes: 0 additions & 2 deletions run_app.sh

This file was deleted.

10 changes: 0 additions & 10 deletions run_repl.sh

This file was deleted.

2 changes: 0 additions & 2 deletions run_tests.sh

This file was deleted.

6 changes: 0 additions & 6 deletions run_xcode.sh

This file was deleted.

85 changes: 85 additions & 0 deletions sts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash

POSITIONAL=()
STS_NAME=sts-application
STS_BUILD=false

while [[ $# -gt 0 ]]
do
key="$1"

case ${key} in
-n|--name)
STS_NAME="$2"
shift
shift
;;
-v|--volume)
STS_VOLUME=true
shift
;;
-b|--build)
STS_BUILD=true
shift
;;
*) # unknown option
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"

STS_COMMAND=${POSITIONAL[0]}
STS_COMMAND_ARG=${POSITIONAL[1]}

[[ "$STS_VOLUME" = true ]] && STS_VOL_COMMAND="-v $PWD:/usr/src" || STS_VOL_COMMAND=""

case ${STS_COMMAND} in
build)
BUILD_COMMAND="docker build -t ${STS_NAME} ${STS_VOL_COMMAND} ."
echo "[STS][build] Building with: $BUILD_COMMAND"
eval ${BUILD_COMMAND}
;;
run)
if [ "$STS_BUILD" = true ] ; then
RUN_BUILD_COMMAND="docker build -t ${STS_NAME} ${STS_VOL_COMMAND} ."
echo "[STS][run] -b|--build was passed; building with: $RUN_BUILD_COMMAND"
eval ${RUN_BUILD_COMMAND}
fi
case ${STS_COMMAND_ARG} in
app)
RUN_COMMAND="docker run --rm ${STS_VOL_COMMAND} ${STS_NAME}"
echo "[STS][run][app] running with: $RUN_COMMAND"
eval ${RUN_COMMAND}
;;
repl)
RUN_COMMAND="docker run --rm ${STS_VOL_COMMAND} --security-opt seccomp:unconfined -it \
--entrypoint /usr/bin/swift \
${STS_NAME} \
-I/usr/lib/swift/clang/include \
-I/usr/src/STSLibrary \
-L/usr/src/STSLibrary \
-lSTSLibrary \
-lswiftPython \
-lswiftTensorFlow"
echo "[STS][run][repl] running with: $RUN_COMMAND"
eval ${RUN_COMMAND}
;;
test)
RUN_COMMAND="docker run --rm ${STS_VOL_COMMAND} --entrypoint "/usr/bin/swift" ${STS_NAME} test"
echo "[STS][run][test] running with: $RUN_COMMAND"
eval ${RUN_COMMAND}
;;
xcode)
RUN_COMMAND="docker run --rm -v ${PWD}:/usr/src \
--entrypoint /usr/bin/swift \
${STS_NAME} \
package generate-xcodeproj \
&& open STSProject.xcodeproj"
echo "[STS][run][xcode] running with: $RUN_COMMAND"
eval ${RUN_COMMAND}
;;
esac
;;
esac

0 comments on commit 6bbb9a6

Please sign in to comment.