diff --git a/.gitignore b/.gitignore index 5e9c1021..f45ff3ff 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,10 @@ *.tracy *.pdb .vs/* + +CppProperties.json +cpp.hint +.natvis + unused/ +build/ diff --git a/build.c b/build.c index 44a343e3..0a7a9a7c 100644 --- a/build.c +++ b/build.c @@ -142,10 +142,19 @@ void OnBuild(StringList cli_args) } SH_Print(Lit("------------------------------\n")); - if (arg_msvc) { - SH_Print(Lit("* Compiler: Msvc *\n")); - } else { - SH_Print(Lit("* Compiler: Clang *\n")); + { + String compiler = { 0 }; + String compiler_loc = { 0 }; + SH_CommandResult where_res = { 0 }; + if (arg_msvc) { + compiler = Lit("Msvc"); + where_res = SH_RunCommandCaptureOutput(&arena, Lit("where cl.exe"), true); + } else { + compiler = Lit("Clang"); + where_res = SH_RunCommandCaptureOutput(&arena, Lit("where clang.exe"), true); + } + compiler_loc = where_res.error ? Lit("Not found") : StringReplace(&arena, where_res.output, Lit("\n"), Lit("")); + SH_PrintF(Lit("Compiler: %F (%F)\n"), FmtStr(compiler), FmtStr(compiler_loc)); } if (arg_asan) SH_Print(Lit("Asan Enabled\n")); if (arg_profiling) SH_Print(Lit("Profiling\n")); @@ -219,9 +228,10 @@ void OnBuild(StringList cli_args) StringListAppend(&arena, &pch_cpp_compile_args, StringF(&arena, Lit("/FI\"%F\" /Fp\"%F\" /Fo\"%F\""), FmtStr(pch_header.full_path), FmtStr(pch_cpp_output.full_path), FmtStr(pch_cpp_obj_output.full_path))); StringListAppend(&arena, &link_args, Lit("link.exe /nologo %F")); - StringListAppend(&arena, &link_args, StringF(&arena, Lit("/OUT:\"%F\" /PDB:\"%F\" /DEBUG:FULL /OPT:REF /OPT:ICF /NODEFAULTLIB:LIBCMT"), FmtStr(executable.full_path), FmtStr(pdb.full_path))); + StringListAppend(&arena, &link_args, StringF(&arena, Lit("/OUT:\"%F\" /PDB:\"%F\" /DEBUG:FULL /OPT:REF /OPT:ICF"), FmtStr(executable.full_path), FmtStr(pdb.full_path))); String warnings = Lit("/WX /Wall " + "/options:strict " "/wd4820 /wd4201 /wd5220 /wd4514 /wd4244 /wd5045 /wd4242 /wd4061 /wd4189 /wd4723 /wd5246"); StringListAppend(&arena, &compile_warnings, warnings); StringListAppend(&arena, &link_warnings, Lit("/WX")); @@ -243,7 +253,6 @@ void OnBuild(StringList cli_args) StringListAppend(&arena, &compile_and_link_args, Lit("-fuse-ld=lld-link " - "-nostdlib " "-fno-strict-aliasing " "-fno-finite-loops " "-fwrapv " @@ -295,24 +304,13 @@ void OnBuild(StringList cli_args) /* CRTLIB */ if (arg_crtlib) { StringListAppend(&arena, &compile_args, Lit("-DCRTLIB=1")); - String crt_libs = { 0 }; - if (arg_msvc) { - crt_libs = arg_rtc ? - Lit("msvcrtd.lib ucrtd.lib msvcprtd.lib vcruntimed.lib") : - Lit("msvcrt.lib ucrt.lib msvcprt.lib vcruntime.lib"); - } else { - crt_libs = arg_rtc ? - Lit("-lmsvcrtd -lucrtd -lmsvcprtd -lvcruntimed") : - Lit("-lmsvcrt -lucrt -lmsvcprt -lvcruntime"); - } - StringListAppend(&arena, &link_args, crt_libs); } else { if (arg_msvc) { /* TODO */ Error(Lit("TODO\n")); OS_Exit(1); } else { - StringListAppend(&arena, &compile_and_link_args, Lit("-mno-stack-arg-probe -fno-builtin")); + StringListAppend(&arena, &compile_and_link_args, Lit("-mno-stack-arg-probe -fno-builtin -nostdlib")); } } @@ -337,7 +335,7 @@ void OnBuild(StringList cli_args) if (arg_debinfo) { StringListAppend(&arena, &compile_args, Lit("-DDEBINFO=1")); if (arg_msvc) { - StringListAppend(&arena, &compile_args, Lit("/Zi")); + StringListAppend(&arena, &compile_args, Lit("/JMC /Zi")); } else { StringListAppend(&arena, &compile_and_link_args, Lit("-g")); } @@ -416,7 +414,7 @@ void OnBuild(StringList cli_args) } if (D_IsDirty(shaders_tar)) { String tar_cmd = StringF(&arena, Lit("cd %F && tar cvf %F ."), FmtStr(shaders_dir.full_path), FmtStr(shaders_tar.full_path)); - String step_name = StringF(&arena, Lit("Generating archive: %F"), FmtStr(D_GetName(shaders_tar))); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(shaders_dir)), FmtStr(D_GetName(shaders_tar))); StepListAppend(&arena, &compile_command_list, step_name, tar_cmd, (String) { 0 }, true); } @@ -431,7 +429,7 @@ void OnBuild(StringList cli_args) } if (D_IsDirty(res_tar)) { String tar_cmd = StringF(&arena, Lit("cd %F && tar cvf %F ."), FmtStr(res_dir.full_path), FmtStr(res_tar.full_path)); - String step_name = StringF(&arena, Lit("Archiving %F"), FmtStr(D_GetName(res_tar))); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(res_dir)), FmtStr(D_GetName(res_tar))); StepListAppend(&arena, &compile_command_list, step_name, tar_cmd, (String) { 0 }, true); } } @@ -471,7 +469,8 @@ void OnBuild(StringList cli_args) } else { rc_compile_cmd = StringF(&arena, Lit("llvm-rc /fo\"%F\" \"%F\""), FmtStr(rc_res_file.full_path), FmtStr(rc_file.full_path)); } - StepListAppend(&arena, &compile_command_list, D_GetName(rc_file), rc_compile_cmd, rc_res_file.full_path, true); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(rc_file)), FmtStr(D_GetName(rc_res_file))); + StepListAppend(&arena, &compile_command_list, step_name, rc_compile_cmd, rc_res_file.full_path, true); } } @@ -487,7 +486,7 @@ void OnBuild(StringList cli_args) D_ClearWrite(c_src, Lit("")); String comp_cmd = StringF(&arena, final_pch_c_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(c_src.full_path)); String link_file = pch_c_obj_output.full_path; - String step_name = StringF(&arena, Lit("%F (c pch)"), FmtStr(D_GetName(pch_header))); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_c_output))); StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, link_file, true); } /* Cpp */ @@ -496,20 +495,20 @@ void OnBuild(StringList cli_args) D_ClearWrite(cpp_src, Lit("")); String comp_cmd = StringF(&arena, final_pch_cpp_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(cpp_src.full_path)); String link_file = pch_cpp_obj_output.full_path; - String step_name = StringF(&arena, Lit("%F (cpp pch)"), FmtStr(D_GetName(pch_header))); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_cpp_output))); StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, link_file, true); } } else { /* C */ { String comp_cmd = StringF(&arena, final_pch_c_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(pch_c_output.full_path)); - String step_name = StringF(&arena, Lit("%F (c pch)"), FmtStr(D_GetName(pch_header))); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_c_output))); StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, (String) { 0 }, true); } /* Cpp */ { String comp_cmd = StringF(&arena, final_pch_cpp_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(pch_cpp_output.full_path)); - String step_name = StringF(&arena, Lit("%F (cpp pch)"), FmtStr(D_GetName(pch_header))); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_cpp_output))); StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, (String) { 0 }, true); } } @@ -555,17 +554,19 @@ void OnBuild(StringList cli_args) } if (!include) continue; - String obj_file_path = { 0 }; + D_Tag obj_file; { + String obj_file_path = { 0 }; String name_no_extension = StringPathNoExtension(name); obj_file_path = StringF(&arena, Lit("%F/%F.%F"), FmtStr(out_obj_dir_path), FmtStr(name_no_extension), FmtStr(obj_file_extension)); - obj_file_path = OS_GetAbsPath(&arena, obj_file_path); + obj_file = D_FileTagFromPath(&arena, obj_file_path); } String comp_cmd_fmt = is_c ? final_c_compile_args_fmt : final_cpp_compile_args_fmt; - String comp_cmd = StringF(&arena, comp_cmd_fmt, FmtStr(file.full_path), FmtStr(obj_file_path)); + String comp_cmd = StringF(&arena, comp_cmd_fmt, FmtStr(file.full_path), FmtStr(obj_file.full_path)); - StepListAppend(&arena, &compile_command_list, name, comp_cmd, obj_file_path, true); + String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(name), FmtStr(D_GetName(obj_file))); + StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, obj_file.full_path, true); } /* ========================== * diff --git a/src/app.c b/src/app.c index d98e4df9..a47565fd 100644 --- a/src/app.c +++ b/src/app.c @@ -200,8 +200,6 @@ void app_entry_point(void) sys_window_update_settings(&window, &window_settings); scratch_end(scratch); - - settings_path.text[0] = 'a'; } /* Startup systems */ diff --git a/src/memory.c b/src/memory.c index d23cc8e0..cd171c4e 100644 --- a/src/memory.c +++ b/src/memory.c @@ -3,7 +3,7 @@ #if !CRTLIB __attribute((section(".text.memcpy"))) -void *memcpy(void *restrict dest, const void *restrict src, u64 n) +void *memcpy(void *__restrict dest, const void *__restrict src, u64 n) { /* TODO: Faster memcpy */ for (u64 i = 0; i < n; ++i) { diff --git a/src/memory.h b/src/memory.h index f39bc031..b7a05a3b 100644 --- a/src/memory.h +++ b/src/memory.h @@ -16,7 +16,6 @@ #if CRTLIB # include #else -/* TODO: restrict args? */ void *memcpy(void *__restrict dest, const void *__restrict src, u64 n); void *memset(void *dest, i32 c, u64 n); i32 memcmp(const void *p1, const void *p2, u64 n);