mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Only trim .odin from build filenames
This commit is contained in:
+25
-2
@@ -2209,10 +2209,33 @@ gb_internal bool init_build_paths(String init_filename) {
|
|||||||
while (output_name.len > 0 && (output_name[output_name.len-1] == '/' || output_name[output_name.len-1] == '\\')) {
|
while (output_name.len > 0 && (output_name[output_name.len-1] == '/' || output_name[output_name.len-1] == '\\')) {
|
||||||
output_name.len -= 1;
|
output_name.len -= 1;
|
||||||
}
|
}
|
||||||
|
// Only trim the extension if it's an Odin source file.
|
||||||
|
// This lets people build folders with extensions or files beginning with dots.
|
||||||
|
if (path_extension(output_name) == ".odin" && !path_is_directory(output_name)) {
|
||||||
|
output_name = remove_extension_from_path(output_name);
|
||||||
|
}
|
||||||
output_name = remove_directory_from_path(output_name);
|
output_name = remove_directory_from_path(output_name);
|
||||||
output_name = remove_extension_from_path(output_name);
|
|
||||||
output_name = copy_string(ha, string_trim_whitespace(output_name));
|
output_name = copy_string(ha, string_trim_whitespace(output_name));
|
||||||
output_path = path_from_string(ha, output_name);
|
// This is `path_from_string` without the extension trimming.
|
||||||
|
Path res = {};
|
||||||
|
if (output_name.len > 0) {
|
||||||
|
String fullpath = path_to_full_path(ha, output_name);
|
||||||
|
defer (gb_free(ha, fullpath.text));
|
||||||
|
|
||||||
|
res.basename = directory_from_path(fullpath);
|
||||||
|
res.basename = copy_string(ha, res.basename);
|
||||||
|
|
||||||
|
if (path_is_directory(fullpath)) {
|
||||||
|
if (res.basename.len > 0 && res.basename.text[res.basename.len - 1] == '/') {
|
||||||
|
res.basename.len--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isize name_start = (res.basename.len > 0) ? res.basename.len + 1 : res.basename.len;
|
||||||
|
res.name = substring(fullpath, name_start, fullpath.len);
|
||||||
|
res.name = copy_string(ha, res.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output_path = res;
|
||||||
|
|
||||||
// Note(Dragos): This is a fix for empty filenames
|
// Note(Dragos): This is a fix for empty filenames
|
||||||
// Turn the trailing folder into the file name
|
// Turn the trailing folder into the file name
|
||||||
|
|||||||
Reference in New Issue
Block a user