Skip to content

Commit b720165

Browse files
committed
fix: build.sh cross-platform compatibility
- Fix macOS stat command incompatibility in same_dir() function - Use -f flag for macOS, -c flag for Linux - Detects platform and uses appropriate stat syntax - Add automatic uppercase conversion for PC_TARGET - Allows users to run './build.sh -p coco' instead of requiring uppercase - Converts target to uppercase before passing to CMake
1 parent 31f6107 commit b720165

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

build.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,16 @@ normalize_path() {
224224

225225
same_dir() {
226226
[ -d "$1" ] && [ -d "$2" ] || return 1
227-
stat1=$(stat -c "%d:%i" "$1")
228-
stat2=$(stat -c "%d:%i" "$2")
227+
# Use -f for macOS, -c for Linux
228+
if stat -f "%d:%i" "$1" >/dev/null 2>&1; then
229+
# macOS
230+
stat1=$(stat -f "%d:%i" "$1")
231+
stat2=$(stat -f "%d:%i" "$2")
232+
else
233+
# Linux
234+
stat1=$(stat -c "%d:%i" "$1")
235+
stat2=$(stat -c "%d:%i" "$2")
236+
fi
229237
[ "$stat1" = "$stat2" ]
230238
}
231239

@@ -289,6 +297,8 @@ fi
289297
# PC BUILD using cmake
290298
if [ ! -z "$PC_TARGET" ] ; then
291299
echo "PC Build Mode"
300+
# Convert PC_TARGET to uppercase for CMake compatibility
301+
PC_TARGET="${PC_TARGET^^}"
292302
# lets build_webui.py know we are using the generated INI file, this variable name is the one PIO uses when it calls subprocesses, so we use same name.
293303
export PROJECT_CONFIG=$INI_FILE
294304
GEN_CMD=""

0 commit comments

Comments
 (0)