diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53cca32fe..fcc9c3239 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,8 +45,11 @@ jobs: - name: Build testproject run: | cd resources/testproject - ..\..\build\${{ matrix.build_type }}\c3c.exe --debug-log run hello_world_win32 + ..\..\build\${{ matrix.build_type }}\c3c.exe --debug-log --emit-llvm run hello_world_win32 + dir build\llvm_ir ..\..\build\${{ matrix.build_type }}\c3c.exe clean + dir build\llvm_ir + - name: Build testproject lib run: | diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 10bad1d47..e89d86d09 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -854,7 +854,7 @@ static void execute_scripts(void) StringSlice call = slice_next_token(&execs, ' '); if (call.len < 3 || call.ptr[call.len - 3] != '.' || call.ptr[call.len - 2] != 'c' || call.ptr[call.len - 2] != '3') { - (void)execute_cmd(exec); + (void) execute_cmd(exec, false); continue; } scratch_buffer_clear(); diff --git a/src/compiler/libraries.c b/src/compiler/libraries.c index 9fe479501..77fa87c3e 100644 --- a/src/compiler/libraries.c +++ b/src/compiler/libraries.c @@ -257,11 +257,11 @@ void resolve_libraries(void) } FOREACH_BEGIN(const char *exec, library->execs) printf("] Execute '%s' for library '%s':", exec, library->provides); - puts(execute_cmd(exec)); + puts(execute_cmd(exec, false)); FOREACH_END(); FOREACH_BEGIN(const char *exec, target->execs) printf("] Execute '%s' for library '%s':", exec, library->provides); - puts(execute_cmd(exec)); + puts(execute_cmd(exec, false)); FOREACH_END(); } } \ No newline at end of file diff --git a/src/compiler/sema_passes.c b/src/compiler/sema_passes.c index 97a80cdc7..5f3f9cda3 100644 --- a/src/compiler/sema_passes.c +++ b/src/compiler/sema_passes.c @@ -284,7 +284,7 @@ static Decl **sema_run_exec(CompilationUnit *unit, Decl *decl) } else { - const char *output = execute_cmd(scratch_buffer_to_string()); + const char *output = execute_cmd(scratch_buffer_to_string(), false); file = source_file_text_load(scratch_buffer_to_string(), output); } if (old_path) diff --git a/src/utils/file_utils.c b/src/utils/file_utils.c index 7df5a7b7a..e862c0bc2 100644 --- a/src/utils/file_utils.c +++ b/src/utils/file_utils.c @@ -481,15 +481,15 @@ bool file_delete_file(const char *path) #endif } -bool file_delete_all_files_in_dir_with_suffix(const char *path, const char *suffix) +void file_delete_all_files_in_dir_with_suffix(const char *path, const char *suffix) { assert(path); #if (_MSC_VER) - const char *cmd = "del /q \"%s\\*%s\""; + const char *cmd = "del /q \"%s\\*%s\" >nul 2>&1"; #else const char *cmd = "rm -f %s/*%s"; #endif - return execute_cmd(str_printf(cmd, path, suffix)) == 0; + execute_cmd(str_printf(cmd, path, suffix), true); } #if (_MSC_VER) @@ -571,7 +571,7 @@ void file_add_wildcard_files(const char ***files, const char *path, bool recursi #endif #define BUFSIZE 1024 -const char *execute_cmd(const char *cmd) +const char *execute_cmd(const char *cmd, bool ignore_failure) { char buffer[BUFSIZE]; char *output = ""; @@ -579,11 +579,13 @@ const char *execute_cmd(const char *cmd) #if (_MSC_VER) if (!(process = _wpopen(win_utf8to16(cmd), L"r"))) { + if (ignore_failure) return ""; error_exit("Failed to open a pipe for command '%s'.", cmd); } #else if (!(process = popen(cmd, "r"))) { + if (ignore_failure) return ""; error_exit("Failed to open a pipe for command '%s'.", cmd); } #endif @@ -598,6 +600,7 @@ const char *execute_cmd(const char *cmd) #endif if (err) { + if (ignore_failure) return ""; error_exit("Failed to execute '%s'.", cmd); } diff --git a/src/utils/lib.h b/src/utils/lib.h index 9978770ec..9e762777d 100644 --- a/src/utils/lib.h +++ b/src/utils/lib.h @@ -72,7 +72,8 @@ bool file_namesplit(const char *path, char** filename_ptr, char** directory_ptr) const char* file_expand_path(const char* path); const char* find_lib_dir(void); const char *find_rel_exe_dir(const char *dir); -bool file_delete_all_files_in_dir_with_suffix(const char *dir, const char *suffix); + +void file_delete_all_files_in_dir_with_suffix(const char *dir, const char *suffix); bool file_delete_file(const char *path); bool file_is_dir(const char *file); bool file_exists(const char *path); @@ -86,7 +87,7 @@ bool file_has_suffix_in_list(const char *file_name, int name_len, const char **s void file_add_wildcard_files(const char ***files, const char *path, bool recursive, const char **suffix_list, int suffix_count); const char *file_append_path(const char *path, const char *name); -const char *execute_cmd(const char *cmd); +const char *execute_cmd(const char *cmd, bool ignore_failure); bool execute_cmd_failable(const char *cmd, const char **result); void *cmalloc(size_t size); void *ccalloc(size_t size, size_t elements);