-
Notifications
You must be signed in to change notification settings - Fork 1
/
start-session
executable file
·51 lines (42 loc) · 1.78 KB
/
start-session
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
#!/bin/sh
### Session workflow
#
# NB: you need to run all the mentioned scripts from the repo root.
#
# * Checkout starting point. For a fresh session the `main` branch is a good choice.
# * Make sure that the git tree is clean, as this script will be committing your
# changes as you make them.
# * Start server with `./start-server`
# * Run this script with a session name as an argument.
# It must be valid as a part of git branch name as the script will prefix it with
# `session/` and checkout this branch.
# * If the session with such name exists it will be resumed.
# * Make changes in `src/session.nim` and save file to compile and send to the server.
# * After every successful compilation there will be a commit.
# * Ctrl-C this script to stop and switch back to the starting point.
# * The system is ready for the next session!
#
###
if [ -z $1 ]; then
echo "Please provide session name."
exit 1
fi
if ! git diff --quiet HEAD; then
echo "Tree must be clean."
exit 1
fi
git checkout "session/$1" || git checkout -b "session/$1" || exit 1
rm target/session.so.*
echo "All set, make sure server is running and edit src/session.nim to make some noises."
# dlopen tries really hard to reuse shared objects. The simplest way I've found
# to workaround it on macOS is to build the library with a different name each
# time. Just "double-buffer" copying as clive does didn't work, I assume because
# not only the filename/inode is checked but LC_ID_DYLIB baked into the file
# too. We also have to randomize the naming and remove unloaded libs to
# make it work.
fswatch --event=Created --event=Updated -e flycheck -o src | while read num; do
rm target/session.so.*
nim c --app:lib -o:target/session.so.$RANDOM src/session.nim && git commit -am "$(date)"
done
git commit -am "$(date)"
git checkout -