Compiling with MSVC, Using raylib! Cleanup

This commit is contained in:
Krzosa Karol
2023-04-05 21:49:05 +02:00
parent d7c96b0ebc
commit fb9c8728ea
14 changed files with 8864 additions and 143 deletions

View File

@@ -96,6 +96,7 @@ const U32 COMPILE_PRINT_STATS = 0x1;
const U32 COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY = 0x2;
const U32 COMPILE_AND_RUN = 0x4;
const U32 COMPILE_TESTING = 0x8;
const U32 DONT_USE_C_COMPILER = 0x10;
static void compile_file(Allocator *allocator, String filename, U32 compile_flags = COMPILE_NULL) {
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {
@@ -103,7 +104,7 @@ static void compile_file(Allocator *allocator, String filename, U32 compile_flag
}
String result = compile_file_to_string(allocator, filename);
B32 r = os_write_file("program.c"_s, result);
B32 r = os_write_file("generated_main.c"_s, result);
assert(r);
F64 total_compiler_time = os_time() - pctx->time.start;
printf("%f - ", total_compiler_time);
@@ -112,20 +113,22 @@ static void compile_file(Allocator *allocator, String filename, U32 compile_flag
Scoped_Arena _scope(scratch);
F64 begin = os_time();
String_Builder builder = {scratch};
builder.addf("clang program.c -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a" OS_EXE " ");
For(pctx->files_to_link) {
builder.addf("-l%Q ", it->intern_val);
if (!is_flag_set(compile_flags, DONT_USE_C_COMPILER)) {
String_Builder builder = {scratch};
builder.addf("clang generated_main.c vendor\\raylib\\windows\\raylibdll.lib -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a" OS_EXE " ");
For(pctx->files_to_link) {
builder.addf("-l%Q ", it->intern_val);
}
String compiler_call = string_flatten(scratch, &builder);
system((const char *)compiler_call.str);
printf("%s\n", compiler_call.str);
}
String compiler_call = string_flatten(scratch, &builder);
system((const char *)compiler_call.str);
F64 end = os_time();
if (is_flag_set(compile_flags, COMPILE_PRINT_STATS)) {
printf("total = %f\n", os_time() - pctx->time.start);
printf("core_total = %f\n", pctx->time.total);
printf("clang = %f\n", end - begin);
if (!is_flag_set(compile_flags, DONT_USE_C_COMPILER)) printf("clang = %f\n", end - begin);
printf("parsing = %f\n", pctx->time.parsing);
printf("typecheck = %f\n", pctx->time.typechecking);
printf("generatin = %f\n", pctx->time.code_generation);
@@ -192,11 +195,11 @@ int main(int argument_count, char **arguments) {
else {
String program_name = string_from_cstring(arguments[1]);
compile_file(&arena, program_name, COMPILE_PRINT_STATS | COMPILE_AND_RUN);
compile_file(&arena, program_name, COMPILE_PRINT_STATS | DONT_USE_C_COMPILER);
}
}
printf("End of program\n");
#if OS_WINDOWS
#if 0 // OS_WINDOWS
if (IsDebuggerPresent()) {
Breakpoint;
}