Skip to content

Commit

Permalink
Improve error message when creating an exe and the name is already us…
Browse files Browse the repository at this point in the history
…ed by a directory.
  • Loading branch information
lerno committed Nov 2, 2023
1 parent eab0b41 commit 98c0025
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ jobs:
install: git binutils mingw-w64-x86_64-clang mingw-w64-x86_64-ninja mingw-w64-x86_64-cmake mingw-w64-x86_64-toolchain mingw-w64-x86_64-python
- shell: msys2 {0}
run: |
pacman --noconfirm -U https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-llvm-17.0.2-1-any.pkg.tar.zst
pacman --noconfirm -U https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-lld-17.0.2-1-any.pkg.tar.zst
pacman --noconfirm -U https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-llvm-17.0.4-any.pkg.tar.zst
pacman --noconfirm -U https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-lld-17.0.4-any.pkg.tar.zst
- name: CMake
run: |
cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
Expand Down
14 changes: 13 additions & 1 deletion src/compiler/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ void compiler_compile(void)

if (output_exe)
{
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);
}
if (link_libc() && platform_target.os != OS_TYPE_WIN32
&& active_target.arch_os_target == default_target && active_target.system_linker != SYSTEM_LINKER_OFF)
{
Expand Down Expand Up @@ -520,6 +524,10 @@ void compiler_compile(void)
}
else if (output_static)
{
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);
}
if (!static_lib_linker(output_static, obj_files, output_file_count))
{
error_exit("Failed to produce static library '%s'.", output_static);
Expand All @@ -531,9 +539,13 @@ void compiler_compile(void)
}
else if (output_dynamic)
{
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);
}
if (!dynamic_lib_linker(output_dynamic, obj_files, output_file_count))
{
error_exit("Failed to produce static library '%s'.", output_dynamic);
error_exit("Failed to produce dynamic library '%s'.", output_dynamic);
}
delete_object_files(obj_files, output_file_count);
printf("Dynamic library '%s' created.\n", output_dynamic);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMPILER_VERSION "0.4.693"
#define COMPILER_VERSION "0.4.694"

0 comments on commit 98c0025

Please sign in to comment.