Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dbartolini committed Nov 22, 2024
1 parent 06831f7 commit fb4e634
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 6 deletions.
14 changes: 14 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ crown-editor-mingw-release64: \
build/projects/mingw
"$(MAKE)" -j$(MAKE_JOBS) -R -C build/projects/mingw crown-editor config=release64

crown-launcher-linux-debug64: \
build/projects/linux
"$(MAKE)" -j$(MAKE_JOBS) -R -C build/projects/linux crown-launcher config=debug64
crown-launcher-linux-release64: \
build/projects/linux
"$(MAKE)" -j$(MAKE_JOBS) -R -C build/projects/linux crown-launcher config=release64

crown-launcher-mingw-debug64: \
build/projects/mingw
"$(MAKE)" -j$(MAKE_JOBS) -R -C build/projects/mingw crown-launcher config=debug64
crown-launcher-mingw-release64: \
build/projects/mingw
"$(MAKE)" -j$(MAKE_JOBS) -R -C build/projects/mingw crown-launcher config=release64

tools-linux-release32: \
build/linux32/bin/luajit \
build/linux32/bin/luac
Expand Down
52 changes: 52 additions & 0 deletions scripts/crown-launcher.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--
-- Copyright (c) 2012-2024 Daniele Bartolini et al.
-- SPDX-License-Identifier: MIT
--

project ("crown-launcher")
kind "WindowedApp"

includedirs {
CROWN_DIR .. "src",
CROWN_DIR .. "3rdparty/stb",
}

configuration { "debug" }
defines {
"CROWN_DEBUG=1"
}

configuration { "release" }
defines {
"CROWN_DEBUG=0"
}

configuration { "linux-*" }
links {
"pthread",
}

configuration { "vs* or mingw*" }
links {
"dbghelp",
"psapi",
"ole32",
"gdi32",
}

configuration {}

files {
CROWN_DIR .. "src/core/os.cpp",
CROWN_DIR .. "src/device/log.cpp",
CROWN_DIR .. "src/core/thread/mutex.cpp",
CROWN_DIR .. "src/core/memory/globals.cpp",
CROWN_DIR .. "src/core/error/**.cpp",
CROWN_DIR .. "src/core/process.cpp",
CROWN_DIR .. "tools/launcher/launcher.cpp",
}

strip()

configuration {} -- reset configuration

1 change: 1 addition & 0 deletions scripts/genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ if _OPTIONS["with-tools"] then

if not _OPTIONS["no-editor"] then
dofile ("crown-editor.lua")
dofile ("crown-launcher.lua")
end
end
6 changes: 0 additions & 6 deletions src/device/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "core/strings/string.inl"
#include "core/strings/string_stream.inl"
#include "core/thread/scoped_mutex.inl"
#include "device/console_server.h"
#include "device/log.h"
#include <stb_sprintf.h>

Expand Down Expand Up @@ -40,9 +39,6 @@ namespace log_internal
/// Sends a log message to all clients.
static void console_log(LogSeverity::Enum sev, System system, const char *msg)
{
if (!console_server())
return;

const char *severity_map[] = { "info", "warning", "error" };
CE_STATIC_ASSERT(countof(severity_map) == LogSeverity::COUNT);

Expand All @@ -63,8 +59,6 @@ namespace log_internal
ss << *ch;
}
ss << "\"}";

console_server()->broadcast(string_stream::c_str(ss));
}

void vlogx(LogSeverity::Enum sev, System system, const char *msg, va_list args)
Expand Down
39 changes: 39 additions & 0 deletions tools/launcher/launcher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "core/memory/allocator.h"
#include "core/memory/globals.h"
#include "core/os.h"
#include "core/process.h"
#define STB_SPRINTF_IMPLEMENTATION
#define STB_SPRINTF_NOUNALIGNED
#define STB_SPRINTF_NOFLOAT
#include <stb_sprintf.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
using namespace crown;
memory_globals::init();
CE_UNUSED(argc);

#if CROWN_PLATFORM_LINUX
os::setcwd("platforms/linux64/bin");
#elif CROWN_PLATFORM_WINDOWS
os::setcwd("platforms/windows64/bin");
#else
#error "Unsupported platform."
#endif

char editor_exe[] = EXE_PATH("level-editor-release");

Process pr;
argv[0] = editor_exe;

if (pr.spawn(argv, CROWN_PROCESS_STDOUT_PIPE | CROWN_PROCESS_STDERR_MERGE) != 0) {
printf("Cannot spawn %s\n", argv[0]);
return EXIT_FAILURE;
}

int exit_code = pr.wait();
memory_globals::shutdown();
return exit_code;
}

0 comments on commit fb4e634

Please sign in to comment.