From 39657e4d968711c11254fa0ee26d576cfc367071 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 22 Jul 2024 15:15:51 +0200 Subject: Fix #3473 Fix the problem where the initial package's directory name ended in .odin. --- src/parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 5a3fc1634..f2d2a1d15 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -5609,7 +5609,7 @@ gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const pkg->foreign_files.allocator = permanent_allocator(); // NOTE(bill): Single file initial package - if (kind == Package_Init && string_ends_with(path, FILE_EXT)) { + if (kind == Package_Init && !path_is_directory(path) && string_ends_with(path, FILE_EXT)) { FileInfo fi = {}; fi.name = filename_from_path(path); fi.fullpath = path; @@ -6529,6 +6529,7 @@ gb_internal ParseFileError parse_packages(Parser *p, String init_filename) { GB_ASSERT(init_filename.text[init_filename.len] == 0); String init_fullpath = path_to_full_path(permanent_allocator(), init_filename); + if (!path_is_directory(init_fullpath)) { String const ext = str_lit(".odin"); if (!string_ends_with(init_fullpath, ext)) { @@ -6543,6 +6544,7 @@ gb_internal ParseFileError parse_packages(Parser *p, String init_filename) { if ((build_context.command_kind & Command__does_build) && build_context.build_mode == BuildMode_Executable) { String short_path = filename_from_path(path); + char *cpath = alloc_cstring(temporary_allocator(), short_path); if (gb_file_exists(cpath)) { error({}, "Please specify the executable name with -out: as a directory exists with the same name in the current working directory"); -- cgit v1.2.3 From 90a4d12b30f24c4a44a8c8e606ce56efde56cf50 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 22 Jul 2024 16:11:33 +0200 Subject: Fix .exe path is directory check. --- src/parser.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index f2d2a1d15..eaf43b5bc 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6543,10 +6543,9 @@ gb_internal ParseFileError parse_packages(Parser *p, String init_filename) { } if ((build_context.command_kind & Command__does_build) && build_context.build_mode == BuildMode_Executable) { - String short_path = filename_from_path(path); - - char *cpath = alloc_cstring(temporary_allocator(), short_path); - if (gb_file_exists(cpath)) { + String output_path = path_to_string(temporary_allocator(), build_context.build_paths[8]); + char *cpath = alloc_cstring(temporary_allocator(), output_path); + if (path_is_directory(output_path) && gb_file_exists(cpath)) { error({}, "Please specify the executable name with -out: as a directory exists with the same name in the current working directory"); return ParseFile_DirectoryAlreadyExists; } -- cgit v1.2.3 From 07d2aba31037c645327f28eba179d6cdba245cca Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 22 Jul 2024 16:36:21 +0200 Subject: Simplify exe path check. --- src/parser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index eaf43b5bc..aba2b8276 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6544,8 +6544,7 @@ gb_internal ParseFileError parse_packages(Parser *p, String init_filename) { if ((build_context.command_kind & Command__does_build) && build_context.build_mode == BuildMode_Executable) { String output_path = path_to_string(temporary_allocator(), build_context.build_paths[8]); - char *cpath = alloc_cstring(temporary_allocator(), output_path); - if (path_is_directory(output_path) && gb_file_exists(cpath)) { + if (path_is_directory(output_path)) { error({}, "Please specify the executable name with -out: as a directory exists with the same name in the current working directory"); return ParseFile_DirectoryAlreadyExists; } -- cgit v1.2.3