Refactor: extract platform abstraction for subprocess spawning
Move all Unix-specific syscalls (fork, execvp, waitpid, strerror, /tmp) into a platform layer so the same spectrogram.c can target Windows (CreateProcess) and WebAssembly (stubs). Key changes: - src/platform.h: public API with spawn handle, error codes, path helpers - src/platform_linux.c: fork/execvp implementation, /tmp, strerror - src/platform_win32.c: CreateProcess implementation, temp dir lookup - src/platform_web.c: stub implementations (no subprocess support on web) - src/spectrogram.c: consume only platform.h; replace pid_t/fork/execvp with Platform_SpawnChild/WaitForChild; use Platform_GetTempDir() for /tmp path; replace strdup with malloc/memcpy for portability - Build: add platform_*.c to gmake, Premake, and build_web.sh
This commit is contained in:
@@ -119,7 +119,9 @@ GENERATED :=
|
||||
OBJECTS :=
|
||||
|
||||
GENERATED += $(OBJDIR)/spectrogram.o
|
||||
GENERATED += $(OBJDIR)/platform_linux.o
|
||||
OBJECTS += $(OBJDIR)/spectrogram.o
|
||||
OBJECTS += $(OBJDIR)/platform_linux.o
|
||||
|
||||
# Rules
|
||||
# #############################################
|
||||
@@ -187,6 +189,10 @@ $(OBJDIR)/spectrogram.o: src/spectrogram.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
|
||||
$(OBJDIR)/platform_linux.o: src/platform_linux.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
|
||||
-include $(OBJECTS:%.o=%.d)
|
||||
ifneq (,$(PCH))
|
||||
-include $(PCH_PLACEHOLDER).d
|
||||
|
||||
Reference in New Issue
Block a user