From c7c678651a30db30e449e965e6c82ad0dcb871e6 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 18 Dec 2023 20:35:37 -0500 Subject: checkpoint - arg-handler --- editor/editor.cpp | 16 ++++++++++++---- editor/main.cpp | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'editor') diff --git a/editor/editor.cpp b/editor/editor.cpp index 53d8883..4170ac9 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -105,16 +105,24 @@ void PkeEditor_Tick(double delta) { PkeThreads_Enqueue(threadPoolHandle, std::packaged_task( [] { auto pid = fork(); if (pid == 0) { + char pluginOpt[128]; + pluginOpt[127] = '\n'; + sprintf(pluginOpt, "--plugin %s", pkeSettings.pluginPath == nullptr ? "example.o" : pkeSettings.pluginPath); + int status = -1; const char *argv[] = { + pluginOpt, NULL, }; - int status = execvp("pke_runtime", const_cast(argv)); - fprintf(stderr, "pke_runtime exited with a status of %i\n", status); + status = execvp("pke_runtime", const_cast(argv)); + fprintf(stderr, "pke_runtime (child) exited with a status of %i\n", status); + subProgramRunning = false; + } else if (pid == -1) { + fprintf(stdout, "pke_runtime failed to fork\n"); subProgramRunning = false; } else { - int status; + int status = 0xCAFEBABE; waitpid(pid, &status, 0); - fprintf(stdout, "pke_runtime exited cleanly with a status of %i\n", status); + fprintf(stdout, "pke_runtime (parent) exited with a status of %i (0x%08X)\n", status, status); subProgramRunning = false; } })); diff --git a/editor/main.cpp b/editor/main.cpp index a431183..af0e66a 100644 --- a/editor/main.cpp +++ b/editor/main.cpp @@ -1,5 +1,6 @@ #include +#include "arg-handler.hpp" #include "plugins.hpp" #include "editor.hpp" #include "event.hpp" @@ -28,6 +29,7 @@ int main(int argc, char *argv[]) { pkePlugin.OnImGuiRender = PkeEditor_RecordImGui; } // run + PkeArgs_Parse(argc, argv); Game_Main({}, argv[0]); fprintf(stdout, "PKE_EDITOR EXITING\n"); return 0; -- cgit v1.2.3