8
8
9
9
# Restore un-reloaded files on exit (for local testing).
10
10
cleanedUp=0 # avoid recursion if cleanup fails
11
+ godotPid=0 # kill previous instance if necessary
12
+
11
13
cleanup () {
12
14
if [[ $cleanedUp -eq 0 ]]; then
13
15
cleanedUp=1
16
+ if [[ $godotPid -ne 0 ]]; then
17
+ echo " [Bash] Kill Godot (PID $godotPid )..."
18
+ kill $godotPid || true # ignore errors here
19
+ fi
14
20
echo " [Bash] Cleanup..."
15
21
git checkout --quiet $rel /../rust/src/lib.rs $rel /rust.gdextension $rel /MainScene.tscn || true # ignore errors here
16
22
fi
@@ -27,7 +33,7 @@ git checkout --quiet $rel/../rust/src/lib.rs $rel/rust.gdextension
27
33
# Set up editor file which has scene open, so @tool script loads at startup. Also copy scene file that holds a script.
28
34
mkdir -p $rel /.godot/editor
29
35
cp editor_layout.cfg $rel /.godot/editor/editor_layout.cfg
30
- cp MainScene.tscn $rel /MainScene.tscn
36
+ # cp MainScene.tscn $rel/MainScene.tscn
31
37
32
38
# Compile original Rust source.
33
39
cargoArgs=" "
@@ -38,8 +44,8 @@ cargo build -p hot-reload $cargoArgs
38
44
sleep 0.5
39
45
40
46
$GODOT4_BIN -e --headless --path $rel &
41
- pid =$!
42
- echo " [Bash] Wait for Godot ready (PID $pid )..."
47
+ godotPid =$!
48
+ echo " [Bash] Wait for Godot ready (PID $godotPid )..."
43
49
44
50
$GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- await
45
51
$GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- replace
@@ -50,9 +56,9 @@ cargo build -p hot-reload $cargoArgs
50
56
$GODOT4_BIN --headless --no-header --script ReloadOrchestrator.gd -- notify
51
57
52
58
echo " [Bash] Wait for Godot exit..."
53
- wait $pid
59
+ wait $godotPid
54
60
status=$?
55
- echo " [Bash] Godot (PID $pid ) has completed with status $status ."
61
+ echo " [Bash] Godot (PID $godotPid ) has completed with status $status ."
56
62
57
63
58
64
0 commit comments