mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Check exe and lib output so -o works with directories. Removed construct forms from Maybe.
This commit is contained in:
@@ -28,16 +28,6 @@ fn Maybe value(Type val)
|
||||
return { .value = val, .has_value = true };
|
||||
}
|
||||
|
||||
fn Maybe Maybe.with_value(Type val) @operator(construct)
|
||||
{
|
||||
return { .value = val, .has_value = true };
|
||||
}
|
||||
|
||||
fn Maybe Maybe.empty() @operator(construct)
|
||||
{
|
||||
return { };
|
||||
}
|
||||
|
||||
const Maybe EMPTY = { };
|
||||
|
||||
macro Type! Maybe.get(self)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
- Several fixes for .o files and -o output, improving handling and naming.
|
||||
- Fix bug casting bool to int to other int #1995.
|
||||
- `@if` declarations were missing from -P output #1973.
|
||||
- Check exe and lib output so -o works with directories.
|
||||
|
||||
### Stdlib changes
|
||||
|
||||
|
||||
@@ -658,6 +658,12 @@ void compiler_compile(void)
|
||||
create_output_dir(compiler.build.output_dir);
|
||||
output_exe = file_append_path(compiler.build.output_dir, output_exe);
|
||||
}
|
||||
char *dir_path = file_get_dir(output_exe);
|
||||
if (dir_path && strlen(dir_path) && !file_is_dir(dir_path))
|
||||
{
|
||||
error_exit("Can't create '%s', the directory '%s' could not be found.", output_exe, dir_path);
|
||||
}
|
||||
|
||||
if (file_is_dir(output_exe))
|
||||
{
|
||||
error_exit("Cannot create exe with the name '%s' - there is already a directory with that name.", output_exe);
|
||||
@@ -757,6 +763,11 @@ void compiler_compile(void)
|
||||
create_output_dir(compiler.build.output_dir);
|
||||
output_static = file_append_path(compiler.build.output_dir, output_static);
|
||||
}
|
||||
char *dir_path = file_get_dir(output_static);
|
||||
if (dir_path && strlen(dir_path) && !file_is_dir(dir_path))
|
||||
{
|
||||
error_exit("Can't create '%s', the directory '%s' could not be found.", output_static, dir_path);
|
||||
}
|
||||
if (file_is_dir(output_static))
|
||||
{
|
||||
error_exit("Cannot create a static library with the name '%s' - there is already a directory with that name.", output_exe);
|
||||
@@ -777,6 +788,11 @@ void compiler_compile(void)
|
||||
create_output_dir(compiler.build.output_dir);
|
||||
output_dynamic = file_append_path(compiler.build.output_dir, output_dynamic);
|
||||
}
|
||||
char *dir_path = file_get_dir(output_dynamic);
|
||||
if (dir_path && strlen(dir_path) && !file_is_dir(dir_path))
|
||||
{
|
||||
error_exit("Can't create '%s', the directory '%s' could not be found.", output_dynamic, dir_path);
|
||||
}
|
||||
if (file_is_dir(output_dynamic))
|
||||
{
|
||||
error_exit("Cannot create a dynamic library with the name '%s' - there is already a directory with that name.", output_exe);
|
||||
|
||||
@@ -169,7 +169,7 @@ bool file_namesplit(const char *path, char** filename_ptr, char** directory_ptr)
|
||||
if (file_len == 1 && path[0] == '.') return false;
|
||||
if (file_len == 2 && path[0] == '.' && path[1] == '.') return false;
|
||||
if (!file_len) return false;
|
||||
*filename_ptr = str_copy(&path[len - file_len], file_len);
|
||||
if (filename_ptr) *filename_ptr = str_copy(&path[len - file_len], file_len);
|
||||
if (!directory_ptr) return true;
|
||||
if (file_len < len)
|
||||
{
|
||||
@@ -422,6 +422,13 @@ DONE:;
|
||||
return lib_path;
|
||||
}
|
||||
|
||||
char *file_get_dir(const char *full_path)
|
||||
{
|
||||
char *dir = NULL;
|
||||
file_get_dir_and_filename_from_full(full_path, NULL, &dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
void file_get_dir_and_filename_from_full(const char *full_path, char **filename, char **dir_path)
|
||||
{
|
||||
if (!file_namesplit(full_path, filename, dir_path))
|
||||
|
||||
@@ -83,6 +83,7 @@ bool file_touch(const char *path);
|
||||
char *file_read_binary(const char *path, size_t *size);
|
||||
char *file_read_all(const char *path, size_t *return_size);
|
||||
size_t file_clean_buffer(char *buffer, const char *path, size_t file_size);
|
||||
char *file_get_dir(const char *full_path);
|
||||
void file_get_dir_and_filename_from_full(const char *full_path, char **filename, char **dir_path);
|
||||
void file_find_top_dir();
|
||||
bool file_has_suffix_in_list(const char *file_name, int name_len, const char **suffix_list, int suffix_count);
|
||||
|
||||
Reference in New Issue
Block a user