launcher.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2012-2025 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: MIT
  4. */
  5. #include "core/memory/allocator.h"
  6. #include "core/memory/globals.h"
  7. #include "core/os.h"
  8. #include "core/process.h"
  9. #define STB_SPRINTF_IMPLEMENTATION
  10. #define STB_SPRINTF_NOUNALIGNED
  11. #define STB_SPRINTF_NOFLOAT
  12. #include <stb_sprintf.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. int main(int argc, char **argv)
  16. {
  17. using namespace crown;
  18. memory_globals::init();
  19. CE_UNUSED(argc);
  20. #if CROWN_PLATFORM_LINUX
  21. os::setcwd("platforms/linux64/bin");
  22. os::setenv("UBUNTU_MENUPROXY", "");
  23. #elif CROWN_PLATFORM_WINDOWS
  24. os::setcwd("platforms/windows64/bin");
  25. #else
  26. #error "Unsupported platform."
  27. #endif
  28. char editor_exe[] = EXE_PATH("crown-editor-release");
  29. Process pr;
  30. argv[0] = editor_exe;
  31. if (pr.spawn(argv, CROWN_PROCESS_STDOUT_PIPE | CROWN_PROCESS_STDERR_MERGE) != 0) {
  32. printf("Cannot spawn %s\n", argv[0]);
  33. memory_globals::shutdown();
  34. return EXIT_FAILURE;
  35. }
  36. int exit_code = pr.wait();
  37. memory_globals::shutdown();
  38. return exit_code;
  39. }