diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-18 20:35:37 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-23 11:41:03 -0500 |
| commit | c7c678651a30db30e449e965e6c82ad0dcb871e6 (patch) | |
| tree | 09f012460a7f77bb92d82d642ec0e9d85ef347e2 /editor | |
| parent | 4c4304429a4c06167aa21de246aa21e7b3ceb725 (diff) | |
checkpoint - arg-handler
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 16 | ||||
| -rw-r--r-- | editor/main.cpp | 2 |
2 files changed, 14 insertions, 4 deletions
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<void()>( [] { 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<char **>(argv)); - fprintf(stderr, "pke_runtime exited with a status of %i\n", status); + status = execvp("pke_runtime", const_cast<char **>(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 <csignal> +#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; |
