Skip to content

Commit 20c985e

Browse files
committed
Fix SIGHUP not declared on Windows, add dev symlink setup script for src/java
1 parent 399b5e0 commit 20c985e

10 files changed

Lines changed: 5342 additions & 148 deletions

mode/CppMode.jar

3.76 KB
Binary file not shown.

setup-dev-symlinks.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env bash
2+
# The REAL CppBuild.java (and friends) live in THIS folder's src/java/.
3+
# This script creates symlinks INSIDE your processing4 checkout (at
4+
# java/src/processing/mode/cpp/) pointing back at these real files, so
5+
# that running Gradle from processing4 compiles the same source you're
6+
# editing here -- no need to keep two copies in sync.
7+
#
8+
# Handles:
9+
# - destination directory missing entirely (creates it)
10+
# - individual source files missing (skips just that one, warns)
11+
# - a target that's already a regular file (backs it up, then links)
12+
# - a target that's already a CORRECT symlink (skips, no-op)
13+
# - a target that's a symlink pointing somewhere ELSE / dangling
14+
# (replaces it with the correct link)
15+
# - files in the destination that aren't part of our known set
16+
# (left completely alone)
17+
#
18+
# Usage:
19+
# ./setup-dev-symlinks.sh /path/to/your/processing4
20+
21+
set -e
22+
23+
if [ -z "$1" ]; then
24+
echo "Usage: $0 /path/to/your/processing4"
25+
echo "Example: $0 ~/Projects/processing4"
26+
exit 1
27+
fi
28+
29+
if [ ! -d "$1" ]; then
30+
echo "ERROR: '$1' is not a directory."
31+
exit 1
32+
fi
33+
34+
PROCESSING4_DIR="$(cd "$1" && pwd)"
35+
DEST_DIR="$PROCESSING4_DIR/java/src/processing/mode/cpp"
36+
37+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
38+
SRC_DIR="$SCRIPT_DIR/src/java"
39+
40+
if [ ! -d "$SRC_DIR" ]; then
41+
echo "ERROR: $SRC_DIR does not exist."
42+
echo "Expected the real .java source files to live there."
43+
exit 1
44+
fi
45+
46+
mkdir -p "$DEST_DIR"
47+
48+
echo "real source: $SRC_DIR"
49+
echo "linking into: $DEST_DIR"
50+
echo
51+
52+
shopt -s nullglob
53+
SOURCE_FILES=("$SRC_DIR"/*.java)
54+
shopt -u nullglob
55+
56+
if [ ${#SOURCE_FILES[@]} -eq 0 ]; then
57+
echo "WARNING: no .java files found in $SRC_DIR -- nothing to link."
58+
exit 0
59+
fi
60+
61+
linked=0
62+
skipped=0
63+
warned=0
64+
65+
for f in "${SOURCE_FILES[@]}"; do
66+
name="$(basename "$f")"
67+
target="$DEST_DIR/$name"
68+
69+
if [ ! -e "$f" ]; then
70+
# Shouldn't normally happen (glob already matched it), but guards
71+
# against a file being deleted mid-run.
72+
echo "WARNING: $name disappeared from source -- skipping."
73+
warned=$((warned+1))
74+
continue
75+
fi
76+
77+
if [ -L "$target" ]; then
78+
# Already a symlink -- check if it already points at the right file.
79+
current_link="$(readlink "$target")"
80+
if [ "$current_link" == "$f" ]; then
81+
skipped=$((skipped+1))
82+
continue
83+
fi
84+
echo "Replacing stale/incorrect symlink: $name (was -> $current_link)"
85+
rm "$target"
86+
elif [ -e "$target" ]; then
87+
# A REAL file/directory sits at the target -- back it up rather than
88+
# silently destroying whatever's there (could be a contributor's own
89+
# local edits made before running this script).
90+
backup="$target.bak"
91+
n=1
92+
while [ -e "$backup" ]; do
93+
backup="$target.bak.$n"
94+
n=$((n+1))
95+
done
96+
echo "Backing up existing $name -> $(basename "$backup")"
97+
mv "$target" "$backup"
98+
fi
99+
100+
ln -s "$f" "$target"
101+
echo "linked $name"
102+
linked=$((linked+1))
103+
done
104+
105+
echo
106+
echo "Done: $linked linked, $skipped already correct, $warned warnings."
107+
echo "$DEST_DIR now points at the real source in $SRC_DIR."
108+
echo "Build the jar by running ./gradlew from $PROCESSING4_DIR."

src/Processing.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,11 @@ void PApplet::enableDebugConsole(){_doEnableDebugConsole();}
29022902
void PApplet::run(){
29032903
g_papplet = this;
29042904
signal(SIGTERM, [](int){ if(PApplet::g_papplet && PApplet::g_papplet->gWindow) glfwSetWindowShouldClose(PApplet::g_papplet->gWindow, GLFW_TRUE); });
2905+
#ifndef _WIN32
2906+
// SIGHUP is POSIX-only -- Windows has no controlling-terminal/session
2907+
// concept, so there's no equivalent signal to catch here at all.
29052908
signal(SIGHUP, [](int){ if(PApplet::g_papplet && PApplet::g_papplet->gWindow) glfwSetWindowShouldClose(PApplet::g_papplet->gWindow, GLFW_TRUE); });
2909+
#endif
29062910
// Write directly to a file since -mwindows kills stderr on Windows
29072911
setvbuf(stdout, nullptr, _IONBF, 0);
29082912
std::srand((unsigned)std::time(nullptr));

0 commit comments

Comments
 (0)