fp: Various tweaks to get web target working
This commit is contained in:
parent
ac898aec6a
commit
53500ed4e2
2
External/tely
vendored
2
External/tely
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 7e37d8655eb5e8c4a61501f054e87ef4b405306c
|
Subproject commit 60aec2dd926ff7cde98408c25ecbc40eb33fddd7
|
@ -3353,9 +3353,6 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
|
|
||||||
TELY_Render_PushFont(renderer, game->inter_regular_font);
|
TELY_Render_PushFont(renderer, game->inter_regular_font);
|
||||||
Dqn_f32 t = (DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f) + 1.f) / 2.f;
|
Dqn_f32 t = (DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f) + 1.f) / 2.f;
|
||||||
#if defined(DQN_PLATFORM_EMSCRIPTEN)
|
|
||||||
TraceLog(LOG_ERROR, "update_counter: %llu, sin_f: %.1f, timer_s: %.1f, t: %.1f", game->play.update_counter, DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f), input->timer_s, t);
|
|
||||||
#endif
|
|
||||||
TELY_Render_PushColourV4(renderer, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, t));
|
TELY_Render_PushColourV4(renderer, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, t));
|
||||||
TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.925f)), Dqn_V2_InitNx1(0.5f), "Press enter to %s", game->play.state == FP_GameState_Play ? "start" : "restart");
|
TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.925f)), Dqn_V2_InitNx1(0.5f), "Press enter to %s", game->play.state == FP_GameState_Play ? "start" : "restart");
|
||||||
TELY_Render_PopColourV4(renderer);
|
TELY_Render_PopColourV4(renderer);
|
||||||
@ -3498,6 +3495,10 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
|
|
||||||
TELY_RFui_TextF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y);
|
TELY_RFui_TextF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y);
|
||||||
|
|
||||||
|
// TODO(doyle): On emscripten we need to use Dqn_OS_PerfCounterNow() however those
|
||||||
|
// require OS functions which need to be exposed into the platform layer.
|
||||||
|
#if 0
|
||||||
|
Dqn_f64 const tsc_frequency = DQN_CAST(Dqn_f64)TELY_Platform_PerfCounterFrequency(&platform->core);
|
||||||
Dqn_ProfilerAnchor *anchors = Dqn_Profiler_AnchorBuffer(Dqn_ProfilerAnchorBuffer_Back);
|
Dqn_ProfilerAnchor *anchors = Dqn_Profiler_AnchorBuffer(Dqn_ProfilerAnchorBuffer_Back);
|
||||||
for (size_t anchor_index = 1; anchor_index < DQN_PROFILER_ANCHOR_BUFFER_SIZE; anchor_index++) {
|
for (size_t anchor_index = 1; anchor_index < DQN_PROFILER_ANCHOR_BUFFER_SIZE; anchor_index++) {
|
||||||
Dqn_ProfilerAnchor const *anchor = anchors + anchor_index;
|
Dqn_ProfilerAnchor const *anchor = anchors + anchor_index;
|
||||||
@ -3506,7 +3507,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
|
|
||||||
uint64_t tsc_exclusive = anchor->tsc_exclusive;
|
uint64_t tsc_exclusive = anchor->tsc_exclusive;
|
||||||
uint64_t tsc_inclusive = anchor->tsc_inclusive;
|
uint64_t tsc_inclusive = anchor->tsc_inclusive;
|
||||||
Dqn_f64 tsc_exclusive_milliseconds = tsc_exclusive * 1000 / DQN_CAST(Dqn_f64)platform->core.tsc_per_second;
|
Dqn_f64 tsc_exclusive_milliseconds = tsc_exclusive * 1000 / tsc_frequency;
|
||||||
if (tsc_exclusive == tsc_inclusive) {
|
if (tsc_exclusive == tsc_inclusive) {
|
||||||
TELY_RFui_TextF(rfui,
|
TELY_RFui_TextF(rfui,
|
||||||
"%.*s[%u]: %.1fms",
|
"%.*s[%u]: %.1fms",
|
||||||
@ -3514,7 +3515,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
anchor->hit_count,
|
anchor->hit_count,
|
||||||
tsc_exclusive_milliseconds);
|
tsc_exclusive_milliseconds);
|
||||||
} else {
|
} else {
|
||||||
Dqn_f64 tsc_inclusive_milliseconds = tsc_inclusive * 1000 / DQN_CAST(Dqn_f64)platform->core.tsc_per_second;
|
Dqn_f64 tsc_inclusive_milliseconds = tsc_inclusive * 1000 / tsc_frequency;
|
||||||
TELY_RFui_TextF(rfui,
|
TELY_RFui_TextF(rfui,
|
||||||
"%.*s[%u]: %.1f/%.1fms",
|
"%.*s[%u]: %.1f/%.1fms",
|
||||||
DQN_STRING_FMT(anchor->name),
|
DQN_STRING_FMT(anchor->name),
|
||||||
@ -3523,6 +3524,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
tsc_inclusive_milliseconds);
|
tsc_inclusive_milliseconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TELY_RFui_Flush(rfui, renderer, input, assets);
|
TELY_RFui_Flush(rfui, renderer, input, assets);
|
||||||
|
@ -80,25 +80,22 @@ void RebuildProgramIfRequired(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PRINT_HELP Dqn_Print_StdLnF(Dqn_PrintStd_Out, "USAGE: feely_pona_build [--help|--dry-run]")
|
#define PRINT_HELP Dqn_Print_StdLnF(Dqn_PrintStd_Out, "USAGE: feely_pona_build [--help|--dry-run|--web]")
|
||||||
int main(int argc, char const **argv)
|
int main(int argc, char const **argv)
|
||||||
{
|
{
|
||||||
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
|
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
|
||||||
if (argc > 2) {
|
|
||||||
PRINT_HELP;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dry_run = false;
|
bool dry_run = false;
|
||||||
if (argc == 2) {
|
bool target_web = false;
|
||||||
|
for (Dqn_usize arg_index = 1; arg_index < argc; arg_index++) {
|
||||||
Dqn_String8 arg = Dqn_String8_InitCString8(argv[1]);
|
Dqn_String8 arg = Dqn_String8_InitCString8(argv[1]);
|
||||||
if (arg == DQN_STRING8("--help")) {
|
if (arg == DQN_STRING8("--help")) {
|
||||||
PRINT_HELP;
|
PRINT_HELP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (arg == DQN_STRING8("--dry-run")) {
|
||||||
|
|
||||||
if (arg == DQN_STRING8("--dry-run")) {
|
|
||||||
dry_run = true;
|
dry_run = true;
|
||||||
|
} else if (arg == DQN_STRING8("--web")) {
|
||||||
|
target_web = true;
|
||||||
} else {
|
} else {
|
||||||
PRINT_HELP;
|
PRINT_HELP;
|
||||||
return 0;
|
return 0;
|
||||||
@ -148,7 +145,7 @@ int main(int argc, char const **argv)
|
|||||||
|
|
||||||
// NOTE: Raylib ================================================================================
|
// NOTE: Raylib ================================================================================
|
||||||
Dqn_String8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/external/raylib", DQN_STRING_FMT(exe_dir));
|
Dqn_String8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/external/raylib", DQN_STRING_FMT(exe_dir));
|
||||||
Dqn_Slice<Dqn_String8> base_raylib_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
Dqn_Slice<Dqn_String8> const raylib_base_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rcore.c", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rcore.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/utils.c", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/utils.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/raudio.c", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/raudio.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
@ -158,47 +155,68 @@ int main(int argc, char const **argv)
|
|||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rshapes.c", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rshapes.c", DQN_STRING_FMT(raylib_dir)),
|
||||||
});
|
});
|
||||||
|
|
||||||
Dqn_CPPBuildContext raylib_build_context = {};
|
Dqn_List<Dqn_String8> raylib_pc_output_files = Dqn_List_Init<Dqn_String8>(scratch.arena, 16);
|
||||||
|
uint64_t raylib_pc_timings[2] = {};
|
||||||
uint64_t raylib_timings[2] = {};
|
|
||||||
{
|
{
|
||||||
raylib_timings[0] = Dqn_OS_PerfCounterNow();
|
raylib_pc_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { raylib_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { raylib_pc_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
// NOTE: Create the list of compile files
|
// NOTE: Setup raylib build context ========================================================
|
||||||
Dqn_List<Dqn_CPPBuildCompileFile> compile_files = Dqn_List_Init<Dqn_CPPBuildCompileFile>(scratch.arena, 32);
|
Dqn_CPPBuildContext build_context = {};
|
||||||
for (Dqn_String8 base_file : base_raylib_files)
|
{
|
||||||
Dqn_List_Add(&compile_files, Dqn_CPPBuildCompileFile{{}, base_file});
|
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_List_Add(&compile_files, Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rglfw.c", DQN_STRING_FMT(raylib_dir))});
|
|
||||||
|
|
||||||
raylib_build_context.compile_files = Dqn_List_ToSliceCopy(&compile_files, scratch.arena);
|
|
||||||
raylib_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/external/glfw/include", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/external/glfw/include", DQN_STRING_FMT(raylib_dir)),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/glfw/deps/mingw", DQN_STRING_FMT(raylib_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/glfw/deps/mingw", DQN_STRING_FMT(raylib_dir)),
|
||||||
});
|
});
|
||||||
|
|
||||||
raylib_build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
DQN_STRING8("cl"),
|
DQN_STRING8("cl"),
|
||||||
DQN_STRING8("/w"),
|
DQN_STRING8("/w"),
|
||||||
DQN_STRING8("/c"),
|
DQN_STRING8("/c"),
|
||||||
DQN_STRING8("/D _DEFAULT_SOURCE"),
|
DQN_STRING8("/D _DEFAULT_SOURCE"),
|
||||||
DQN_STRING8("/D PLATFORM_DESKTOP"),
|
DQN_STRING8("/D PLATFORM_DESKTOP"),
|
||||||
DQN_STRING8("/W4"),
|
|
||||||
DQN_STRING8("/Z7"),
|
DQN_STRING8("/Z7"),
|
||||||
DQN_STRING8("/MT"),
|
DQN_STRING8("/MT"),
|
||||||
DQN_STRING8("/EHsc"),
|
DQN_STRING8("/EHsc"),
|
||||||
DQN_STRING8("/nologo"),
|
DQN_STRING8("/nologo"),
|
||||||
});
|
});
|
||||||
|
build_context.build_dir = build_dir;
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
}
|
||||||
|
|
||||||
raylib_build_context.link_flags = common_link_flags;
|
// NOTE: Compile each file separately with a custom output name ============================
|
||||||
raylib_build_context.build_dir = build_dir;
|
for (Dqn_String8 base_file : raylib_base_files) {
|
||||||
|
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(base_file);
|
||||||
|
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = base_file;
|
||||||
|
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_%.*s.obj", DQN_STRING_FMT(file_stem));
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
|
Dqn_List_Add(&raylib_pc_output_files, build_file.output_file_path);
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
} else {
|
} else {
|
||||||
Dqn_CPPBuild_ExecOrAbort(raylib_build_context, Dqn_CPPBuildMode_CacheBuild);
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Build rlgfw =======================================================================
|
||||||
|
{
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rglfw.c", DQN_STRING_FMT(raylib_dir));
|
||||||
|
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_rglfw.obj");
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
|
Dqn_List_Add(&raylib_pc_output_files, build_file.output_file_path);
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +227,7 @@ int main(int argc, char const **argv)
|
|||||||
DQN_DEFER { feely_pona_sprite_packer_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_sprite_packer_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.h", DQN_STRING_FMT(code_dir)) },
|
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.h", DQN_STRING_FMT(code_dir)) },
|
||||||
});
|
});
|
||||||
@ -227,36 +246,27 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_no_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_no_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_no_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_no_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
Dqn_CPPBuildCompileFile{
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.h", DQN_STRING_FMT(code_dir));
|
||||||
{Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")})},
|
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.h", DQN_STRING_FMT(code_dir))
|
feely_pona_no_dll_build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
},
|
feely_pona_no_dll_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
});
|
feely_pona_no_dll_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
|
|
||||||
});
|
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.compile_flags = common_compile_flags;
|
feely_pona_no_dll_build_context.compile_flags = common_compile_flags;
|
||||||
|
feely_pona_no_dll_build_context.build_dir = build_dir;
|
||||||
|
|
||||||
// NOTE: Link to raylib object files and windows libs ======================================
|
// NOTE: Link to raylib object files and windows libs ======================================
|
||||||
Dqn_List<Dqn_String8> link_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_link_flags);
|
Dqn_List<Dqn_String8> link_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_link_flags);
|
||||||
{
|
{
|
||||||
for (Dqn_CPPBuildCompileFile file : raylib_build_context.compile_files) {
|
for (Dqn_ListIterator<Dqn_String8> it = {}; Dqn_List_Iterate(&raylib_pc_output_files, &it, 0); )
|
||||||
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(file.path);
|
Dqn_List_Add(&link_flags, *it.data);
|
||||||
Dqn_String8 obj_file = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.obj", DQN_STRING_FMT(raylib_build_context.build_dir), DQN_STRING_FMT(file_stem));
|
|
||||||
Dqn_List_Add(&link_flags, obj_file);
|
|
||||||
}
|
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("gdi32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("gdi32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("opengl32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("opengl32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("winmm.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("winmm.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("user32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("user32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STRING8("shell32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STRING8("shell32.lib"));
|
||||||
}
|
}
|
||||||
|
|
||||||
feely_pona_no_dll_build_context.link_flags = Dqn_List_ToSliceCopy(&link_flags, scratch.arena);
|
feely_pona_no_dll_build_context.link_flags = Dqn_List_ToSliceCopy(&link_flags, scratch.arena);
|
||||||
feely_pona_no_dll_build_context.build_dir = build_dir;
|
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(feely_pona_no_dll_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(feely_pona_no_dll_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
@ -272,19 +282,18 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_dll_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STRING_FMT(code_dir));
|
||||||
Dqn_CPPBuildCompileFile{
|
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "tely_dll_msvc", DQN_STRING_FMT(code_dir));
|
||||||
{Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")})},
|
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STRING_FMT(code_dir))
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/LD"));
|
Dqn_List_Add(&compile_flags, DQN_STRING8("/LD"));
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fotely_dll_msvc"));
|
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fetely_dll_msvc"));
|
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fetely_dll_msvc"));
|
||||||
|
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
||||||
build_context.build_dir = build_dir;
|
build_context.build_dir = build_dir;
|
||||||
@ -303,24 +312,21 @@ int main(int argc, char const **argv)
|
|||||||
feely_pona_platform_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_platform_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_platform_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_platform_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/tely_platform_raylib_unity.h", DQN_STRING_FMT(tely_dir));
|
||||||
Dqn_CPPBuildCompileFile{
|
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "feely_pona_msvc", DQN_STRING_FMT(code_dir));
|
||||||
{Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")})},
|
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/tely_platform_raylib_unity.h", DQN_STRING_FMT(tely_dir))
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
|
||||||
raylib_dir,
|
|
||||||
});
|
|
||||||
|
|
||||||
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fofeely_pona_msvc"));
|
|
||||||
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fefeely_pona_msvc"));
|
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fefeely_pona_msvc"));
|
||||||
|
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
|
||||||
build_context.build_dir = build_dir;
|
build_context.build_dir = build_dir;
|
||||||
|
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
@ -341,22 +347,30 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: raylib emscripten =====================================================================
|
// NOTE: raylib emscripten =====================================================================
|
||||||
bool target_web = false;
|
|
||||||
uint64_t raylib_emscripten_timings[2] = {};
|
uint64_t raylib_emscripten_timings[2] = {};
|
||||||
|
uint64_t feely_pona_emscripten_timings[2] = {};
|
||||||
if (target_web) {
|
if (target_web) {
|
||||||
|
Dqn_String8 const raylib_emscripten_lib_name = DQN_STRING8("raylib_emscripten.a");
|
||||||
|
|
||||||
|
// NOTE: Compile each raylib file separately with emcc =====================================
|
||||||
|
{
|
||||||
raylib_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
raylib_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
// NOTE: Compile with emcc
|
// NOTE: Setup build context ===========================================================
|
||||||
|
Dqn_List<Dqn_String8> raylib_emscripten_output_files = Dqn_List_Init<Dqn_String8>(scratch.arena, 16);
|
||||||
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
||||||
{
|
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
|
||||||
|
|
||||||
// NOTE: Create the list of compile files
|
for (Dqn_String8 base_file : raylib_base_files) {
|
||||||
Dqn_List<Dqn_CPPBuildCompileFile> compile_files = Dqn_List_Init<Dqn_CPPBuildCompileFile>(scratch.arena, 32);
|
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(base_file);
|
||||||
for (Dqn_String8 base_file : base_raylib_files)
|
|
||||||
Dqn_List_Add(&compile_files, Dqn_CPPBuildCompileFile{{}, base_file});
|
|
||||||
|
|
||||||
raylib_emscripten_build_context.compile_files = Dqn_List_ToSliceCopy(&compile_files, scratch.arena);
|
// NOTE: Append "emscripten" suffix to the object files
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = base_file;
|
||||||
|
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_%.*s_emscripten.o", DQN_STRING_FMT(file_stem));
|
||||||
|
|
||||||
|
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
raylib_emscripten_build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
raylib_emscripten_build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
DQN_STRING8("cmd"),
|
DQN_STRING8("cmd"),
|
||||||
DQN_STRING8("/C"),
|
DQN_STRING8("/C"),
|
||||||
@ -368,6 +382,7 @@ int main(int argc, char const **argv)
|
|||||||
DQN_STRING8("-D GRAPHICS_API_OPENGL_ES2"),
|
DQN_STRING8("-D GRAPHICS_API_OPENGL_ES2"),
|
||||||
});
|
});
|
||||||
raylib_emscripten_build_context.build_dir = build_dir;
|
raylib_emscripten_build_context.build_dir = build_dir;
|
||||||
|
Dqn_List_Add(&raylib_emscripten_output_files, build_file.output_file_path);
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
@ -377,16 +392,14 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Build the wasm raylib library =================================================
|
||||||
{
|
{
|
||||||
Dqn_String8Builder builder = {};
|
Dqn_String8Builder builder = {};
|
||||||
builder.allocator = scratch.allocator;
|
builder.allocator = scratch.allocator;
|
||||||
Dqn_String8Builder_AppendF(&builder, "cmd /C emar.bat rcs libraylib.a");
|
Dqn_String8Builder_AppendF(&builder, "cmd /C emar.bat rcs %.*s", DQN_STRING_FMT(raylib_emscripten_lib_name));
|
||||||
|
|
||||||
for (Dqn_CPPBuildCompileFile file : raylib_emscripten_build_context.compile_files) {
|
for (Dqn_ListIterator<Dqn_String8> it = {}; Dqn_List_Iterate(&raylib_emscripten_output_files, &it, 0); )
|
||||||
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(file.path);
|
Dqn_String8Builder_AppendF(&builder, " %.*s", DQN_STRING_FMT(*it.data));
|
||||||
Dqn_String8 obj_file = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.o", DQN_STRING_FMT(raylib_emscripten_build_context.build_dir), DQN_STRING_FMT(file_stem));
|
|
||||||
Dqn_String8Builder_AppendF(&builder, " %.*s", DQN_STRING_FMT(obj_file));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dqn_String8 cmd = Dqn_String8Builder_Build(&builder, scratch.allocator);
|
Dqn_String8 cmd = Dqn_String8Builder_Build(&builder, scratch.allocator);
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
@ -398,13 +411,13 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: feely pona emscripten =================================================================
|
// NOTE: feely pona emscripten =================================================================
|
||||||
uint64_t feely_pona_emscripten_timings[2] = {};
|
{
|
||||||
if (target_web) {
|
|
||||||
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
// NOTE: Compile with emcc
|
// NOTE: Compile with emcc =============================================================
|
||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.cpp", DQN_STRING_FMT(code_dir)) },
|
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.cpp", DQN_STRING_FMT(code_dir)) },
|
||||||
});
|
});
|
||||||
@ -414,10 +427,19 @@ int main(int argc, char const **argv)
|
|||||||
DQN_STRING8("-o"), DQN_STRING8("feely_pona.html"),
|
DQN_STRING8("-o"), DQN_STRING8("feely_pona.html"),
|
||||||
DQN_STRING8("-Os"), // Optimize for size
|
DQN_STRING8("-Os"), // Optimize for size
|
||||||
DQN_STRING8("-Wall"),
|
DQN_STRING8("-Wall"),
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/libraylib.a", DQN_STRING_FMT(build_dir)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(raylib_emscripten_lib_name)),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
|
DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=1"),
|
DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=2"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=67108864"),
|
DQN_STRING8("-s"), DQN_STRING8("SAFE_HEAP=0"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_STACK=32MB"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("ALLOW_MEMORY_GROWTH"),
|
||||||
|
DQN_STRING8("-s"), DQN_STRING8("STACK_OVERFLOW_CHECK=2"),
|
||||||
|
DQN_STRING8("--profiling-funcs"), // Expose function names in stack trace
|
||||||
|
DQN_STRING8("-g"), // Debug symbols
|
||||||
|
// NOTE: Must be relative path such that fopen("Data/...") works
|
||||||
|
// otherwise the VFS will encode the full absolute path to the
|
||||||
|
// assets
|
||||||
DQN_STRING8("--preload-file"), DQN_STRING8("Data"),
|
DQN_STRING8("--preload-file"), DQN_STRING8("Data"),
|
||||||
DQN_STRING8("-msimd128"),
|
DQN_STRING8("-msimd128"),
|
||||||
DQN_STRING8("-msse2"),
|
DQN_STRING8("-msse2"),
|
||||||
@ -431,16 +453,20 @@ int main(int argc, char const **argv)
|
|||||||
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
build_timings[1] = Dqn_OS_PerfCounterNow();
|
build_timings[1] = Dqn_OS_PerfCounterNow();
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_timings[0], raylib_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (platform-raylib): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_platform_timings[0], feely_pona_platform_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (platform-raylib): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_platform_timings[0], feely_pona_platform_timings[1]));
|
||||||
|
if (target_web) {
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib (emscripten): %.2fms", Dqn_OS_PerfCounterMs(raylib_emscripten_timings[0], raylib_emscripten_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib (emscripten): %.2fms", Dqn_OS_PerfCounterMs(raylib_emscripten_timings[0], raylib_emscripten_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (emscripten): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_emscripten_timings[0], feely_pona_emscripten_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (emscripten): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_emscripten_timings[0], feely_pona_emscripten_timings[1]));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
BIN
project.rdbg
BIN
project.rdbg
Binary file not shown.
Loading…
Reference in New Issue
Block a user