mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Add delete testing for windows and update "clean"
This commit is contained in:
committed by
Christoffer Lerno
parent
b657724d9b
commit
db3e9c7ec7
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@@ -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: |
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user