build: Get basic linux build working

This commit is contained in:
doyle 2023-11-26 00:52:50 +11:00
parent 88d996af87
commit 05788cc726
4 changed files with 84 additions and 74 deletions

2
External/tely vendored

@ -1 +1 @@
Subproject commit d13c0f1f1efc426bc2d4be79f46784be5952c426
Subproject commit f6b969cf9205d939f8b5d4d05d41026be98e82ac

View File

@ -18,4 +18,4 @@ cp --force feely_pona_build ${code_dir}
popd
# Run the build program
# ${code_dir}\feely_pona_build.exe $@ || exit /B 1
${code_dir}/feely_pona_build $@

View File

@ -155,7 +155,7 @@ int main(int argc, char const **argv)
Dqn_FArray_AddAssert(&common_link_flags, DQN_STR8("/link"));
Dqn_FArray_AddAssert(&common_link_flags, DQN_STR8("/incremental:no"));
} else {
Dqn_FArray_AddAssert(&common_compile_flags, DQN_STR8("gcc"));
Dqn_FArray_AddAssert(&common_compile_flags, DQN_STR8("g++"));
Dqn_FArray_AddAssert(&common_compile_flags, DQN_STR8("-Wall"));
Dqn_FArray_AddAssert(&common_compile_flags, DQN_STR8("-g"));
@ -168,7 +168,7 @@ int main(int argc, char const **argv)
robocopy_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { robocopy_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_FArray32<Dqn_Str8> common_copy_cmd_args = {};
Dqn_FArray8<Dqn_Str8> common_copy_cmd_args = {};
if (windows_build) {
Dqn_FArray_AddAssert(&common_copy_cmd_args, DQN_STR8("robocopy"));
Dqn_FArray_AddAssert(&common_copy_cmd_args, DQN_STR8("/NJH"));
@ -179,41 +179,60 @@ int main(int argc, char const **argv)
Dqn_FArray_AddAssert(&common_copy_cmd_args, DQN_STR8("--recursive"));
}
Dqn_FArray32<Dqn_Str8> copy_textures_cmd = common_copy_cmd_args;
Dqn_FArray_AddAssert(&copy_textures_cmd, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures", DQN_STR_FMT(exe_dir)));
Dqn_Str8 textures_dest = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures", DQN_STR_FMT(build_dir));
DQN_HARD_ASSERT(Dqn_Fs_MakeDir(textures_dest));
Dqn_FArray8<Dqn_FArray8<Dqn_Str8>> copy_cmd_list = {};
if (windows_build) {
Dqn_FArray_AddAssert(&copy_textures_cmd, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures atlas.*", DQN_STR_FMT(build_dir)));
Dqn_FArray8<Dqn_Str8> copy_atlas = common_copy_cmd_args;
Dqn_FArray_AddCArrayAssert(&copy_atlas, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures", DQN_STR_FMT(exe_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures atlas.*", DQN_STR_FMT(build_dir)),
});
Dqn_FArray_Add(&copy_cmd_list, copy_atlas);
} else {
Dqn_FArray_AddAssert(&copy_textures_cmd, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures/atlas.*", DQN_STR_FMT(build_dir)));
Dqn_FArray8<Dqn_Str8> copy_atlas_txt = common_copy_cmd_args;
Dqn_FArray_AddCArrayAssert(&copy_atlas_txt, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures/atlas.txt", DQN_STR_FMT(exe_dir)),
textures_dest,
});
Dqn_FArray_Add(&copy_cmd_list, copy_atlas_txt);
Dqn_FArray8<Dqn_Str8> copy_atlas_png = common_copy_cmd_args;
Dqn_FArray_AddCArrayAssert(&copy_atlas_png, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Textures/atlas.png", DQN_STR_FMT(exe_dir)),
textures_dest,
});
Dqn_FArray_Add(&copy_cmd_list, copy_atlas_png);
}
Dqn_FArray32<Dqn_Str8> copy_fonts_cmd = common_copy_cmd_args;
Dqn_FArray_AddAssert(&copy_fonts_cmd, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Fonts", DQN_STR_FMT(exe_dir)));
Dqn_FArray_AddAssert(&copy_fonts_cmd, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Fonts", DQN_STR_FMT(build_dir)));
Dqn_FArray8<Dqn_Str8> copy_fonts_cmd = common_copy_cmd_args;
Dqn_FArray_AddCArrayAssert(&copy_fonts_cmd, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Fonts", DQN_STR_FMT(exe_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Fonts", DQN_STR_FMT(build_dir)),
});
Dqn_FArray_Add(&copy_cmd_list, copy_fonts_cmd);
Dqn_FArray32<Dqn_Str8> copy_audio_cmd = common_copy_cmd_args;
Dqn_FArray_AddAssert(&common_copy_cmd_args, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Audio", DQN_STR_FMT(exe_dir)));
Dqn_FArray_AddAssert(&common_copy_cmd_args, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Audio", DQN_STR_FMT(build_dir)));
Dqn_FArray8<Dqn_Str8> copy_audio_cmd = common_copy_cmd_args;
Dqn_FArray_AddCArrayAssert(&copy_audio_cmd, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Audio", DQN_STR_FMT(exe_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Data/Audio", DQN_STR_FMT(build_dir)),
});
Dqn_FArray_Add(&copy_cmd_list, copy_audio_cmd);
Dqn_FArray32<Dqn_Str8> *copy_cmd_list[] = {
&copy_textures_cmd,
&copy_fonts_cmd,
&copy_audio_cmd,
};
for (Dqn_FArray32<Dqn_Str8> *copy_cmd : copy_cmd_list) {
Dqn_Slice<Dqn_Str8> copy_cmd_slice = Dqn_FArray_Slice(copy_cmd);
for (Dqn_FArray8<Dqn_Str8> const &copy_cmd : copy_cmd_list) {
Dqn_Slice<Dqn_Str8> copy_cmd_slice = Dqn_FArray_Slice(&copy_cmd);
if (dry_run) {
Dqn_Str8 rendered_line = Dqn_Slice_Str8Render(scratch.arena, copy_cmd_slice, DQN_STR8(" "));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(rendered_line));
} else {
Dqn_OS_Exec(copy_cmd_slice, /*working_dir*/ {});
Dqn_OS_ExecOrAbort(copy_cmd_slice, /*working_dir*/ {});
}
}
}
// NOTE: Raylib ================================================================================
Dqn_Str8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/external/raylib", DQN_STR_FMT(exe_dir));
Dqn_Str8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/External/raylib", DQN_STR_FMT(exe_dir));
Dqn_Slice<Dqn_Str8> const raylib_base_files = Dqn_Slice_InitCArray(scratch.arena, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rcore.c", DQN_STR_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/utils.c", DQN_STR_FMT(raylib_dir)),
@ -269,8 +288,8 @@ int main(int argc, char const **argv)
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = base_file;
build_file.output_file_path = Dqn_Str8_InitF(scratch.allocator, "raylib_%.*s.obj", DQN_STR_FMT(file_stem));
build_context.compile_files = Dqn_Slice_InitCArray(scratch.arena, {build_file});
build_file.output_file_path = Dqn_Str8_InitF(scratch.allocator, "raylib_%.*s.%s", DQN_STR_FMT(file_stem), windows_build ? "obj" : "o");
build_context.compile_files = Dqn_Slice_Init(&build_file, 1);
Dqn_FArray_AddAssert(&raylib_pc_output_files, build_file.output_file_path);
if (dry_run) {
@ -285,7 +304,7 @@ int main(int argc, char const **argv)
{
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rglfw.c", DQN_STR_FMT(raylib_dir));
build_file.output_file_path = Dqn_Str8_InitF(scratch.allocator, "raylib_rglfw.obj");
build_file.output_file_path = Dqn_Str8_InitF(scratch.allocator, "raylib_rglfw.%s", windows_build ? "obj" : "o");
build_context.compile_files = Dqn_Slice_InitCArray(scratch.arena, {build_file});
Dqn_FArray_AddAssert(&raylib_pc_output_files, build_file.output_file_path);
@ -311,15 +330,20 @@ int main(int argc, char const **argv)
build_context.flags_style = flags_style;
build_context.compile_files = Dqn_Slice_InitCArray(scratch.arena, {
Dqn_CPPBuildCompileFile{
{}, // Args
{}, // Prefix flags
{}, // Suffix flags
sokol_audio_source_code_file,
},
});
Dqn_FArray_AddAssert(&sokol_audio_pc_output_files, DQN_STR8("sokol_audio.obj"));
Dqn_FArray_AddAssert(&sokol_audio_pc_output_files, Dqn_Str8_InitF(scratch.allocator, "sokol_audio.%s", windows_build ? "obj" : "o"));
Dqn_FArray32<Dqn_Str8> compile_flags = common_compile_flags;
if (windows_build) {
Dqn_FArray_AddAssert(&compile_flags, DQN_STR8("/c"));
} else {
Dqn_FArray_AddAssert(&compile_flags, DQN_STR8("-c"));
}
build_context.compile_flags = Dqn_FArray_Slice(&compile_flags);
build_context.build_dir = build_dir;
@ -332,41 +356,16 @@ int main(int argc, char const **argv)
}
}
// NOTE: QOI Converter =========================================================================
uint64_t qoi_converter_timings[2] = {};
{
qoi_converter_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { qoi_converter_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildContext build_context = {};
build_context.flags_style = flags_style;
build_context.compile_files = Dqn_Slice_InitCArray(scratch.arena, {
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/qoiconv.c", DQN_STR_FMT(code_dir)) },
});
build_context.compile_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("cl"), DQN_STR8("-O2"), DQN_STR8("-MT"), DQN_STR8("/nologo")});
build_context.link_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/link"), DQN_STR8("/incremental:no")});
build_context.include_dirs = Dqn_Slice_InitCArray(scratch.arena, {Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/stb", DQN_STR_FMT(tely_dir))});
build_context.build_dir = build_dir;
if (dry_run) {
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLineStr8(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.arena);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
}
}
// NOTE: Feely Pona Sprite Packer ==============================================================
uint64_t feely_pona_sprite_packer_timings[2] = {};
{
if (windows_build) {
feely_pona_sprite_packer_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_sprite_packer_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildContext build_context = {};
build_context.flags_style = flags_style;
build_context.compile_files = Dqn_Slice_InitCArray(scratch.arena, {
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.cpp", DQN_STR_FMT(code_dir)) },
Dqn_CPPBuildCompileFile{{} /*Prefix flags*/, {} /*Suffix flags*/, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.cpp", DQN_STR_FMT(code_dir)) },
});
build_context.compile_flags = Dqn_FArray_Slice(&common_compile_flags);
@ -382,17 +381,25 @@ int main(int argc, char const **argv)
}
// NOTE: Feely Pona Link Flags =================================================================
Dqn_FArray32<Dqn_Str8> feely_pona_platform_link_flags = {};
Dqn_FArray32<Dqn_Str8> feely_pona_platform_link_flags = common_link_flags;
{
// NOTE: Link to raylib object files and windows libs ======================================
Dqn_FArray_AddArrayAssert(&feely_pona_platform_link_flags, raylib_pc_output_files.data, raylib_pc_output_files.size);
Dqn_FArray_AddArrayAssert(&feely_pona_platform_link_flags, sokol_audio_pc_output_files.data, sokol_audio_pc_output_files.size);
if (windows_build) {
Dqn_FArray_AddAssert(&feely_pona_platform_link_flags, DQN_STR8("gdi32.lib"));
Dqn_FArray_AddAssert(&feely_pona_platform_link_flags, DQN_STR8("opengl32.lib"));
Dqn_FArray_AddAssert(&feely_pona_platform_link_flags, DQN_STR8("winmm.lib"));
Dqn_FArray_AddAssert(&feely_pona_platform_link_flags, DQN_STR8("user32.lib"));
Dqn_FArray_AddAssert(&feely_pona_platform_link_flags, DQN_STR8("shell32.lib"));
Dqn_FArray_AddCArrayAssert(&feely_pona_platform_link_flags, {
DQN_STR8("gdi32.lib"),
DQN_STR8("opengl32.lib"),
DQN_STR8("winmm.lib"),
DQN_STR8("user32.lib"),
DQN_STR8("shell32.lib"),
});
} else {
Dqn_FArray_AddCArrayAssert(&feely_pona_platform_link_flags, {
DQN_STR8("-lpthread"),
DQN_STR8("-ldl"),
DQN_STR8("-lasound"),
});
}
}
@ -405,8 +412,12 @@ int main(int argc, char const **argv)
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STR_FMT(code_dir));
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "terry_cherry");
if (windows_build)
build_file.flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/Tp")});
if (windows_build) {
build_file.prefix_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/Tp")});
} else {
build_file.prefix_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("-xc++")});
build_file.suffix_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("-xnone")});
}
Dqn_FArray32<Dqn_Str8> compile_flags = common_compile_flags;
if (windows_build) {
@ -442,7 +453,7 @@ int main(int argc, char const **argv)
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STR_FMT(code_dir));
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "terry_cherry_dev_dll");
build_file.flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/Tp")});
build_file.prefix_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/Tp")});
Dqn_FArray32<Dqn_Str8> compile_flags = common_compile_flags;
Dqn_FArray_AddAssert(&compile_flags, DQN_STR8("/LD"));
@ -474,7 +485,7 @@ int main(int argc, char const **argv)
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STR_FMT(code_dir));
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "terry_cherry_dev", DQN_STR_FMT(code_dir));
build_file.flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/Tp")});
build_file.prefix_flags = Dqn_Slice_InitCArray(scratch.arena, {DQN_STR8("/Tp")});
Dqn_FArray32<Dqn_Str8> compile_flags = common_compile_flags;
Dqn_FArray_AddAssert(&compile_flags, DQN_STR8("/D TELY_WITH_PLATFORM"));
@ -509,7 +520,7 @@ int main(int argc, char const **argv)
// NOTE: raylib emscripten =====================================================================
uint64_t raylib_emscripten_timings[2] = {};
uint64_t feely_pona_emscripten_timings[2] = {};
if (target_web) {
if (windows_build && target_web) {
Dqn_Str8 const raylib_emscripten_lib_name = DQN_STR8("raylib_emscripten.a");
bool debug_build = false;
@ -671,7 +682,7 @@ int main(int argc, char const **argv)
Dqn_CPPBuildContext build_context = {};
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
build_context.compile_files = Dqn_Slice_InitCArray(scratch.arena, {
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.cpp", DQN_STR_FMT(code_dir)) },
Dqn_CPPBuildCompileFile{{}, {}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.cpp", DQN_STR_FMT(code_dir)) },
});
Dqn_Str8 output_name = DQN_STR8("Terry_Cherry");
@ -747,7 +758,6 @@ int main(int argc, char const **argv)
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_pc_timings[0], raylib_pc_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " sokol_audio: %.2fms", Dqn_OS_PerfCounterMs(sokol_audio_pc_timings[0], sokol_audio_pc_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " qoi_converter: %.2fms", Dqn_OS_PerfCounterMs(qoi_converter_timings[0], qoi_converter_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 (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));

View File

@ -15,13 +15,13 @@
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4244) // warning C4244: 'argument': conversion from 'int' to 'short', possible loss of data
#define STB_RECT_PACK_IMPLEMENTATION
#include "External/tely/external/stb/stb_rect_pack.h"
#include "External/tely/External/stb/stb_rect_pack.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "External/tely/external/stb/stb_image_write.h"
#include "External/tely/External/stb/stb_image_write.h"
#define STB_IMAGE_IMPLEMENTATION
#include "External/tely/external/stb/stb_image.h"
#include "External/tely/External/stb/stb_image.h"
DQN_MSVC_WARNING_POP
DQN_MSVC_WARNING_PUSH