From 65500a66eaaeb95cfda07b398a1a54e35d0b3021 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Sat, 20 Jan 2024 22:16:52 -0500 Subject: [PATCH] Improve jai build function --- .vimrc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.vimrc b/.vimrc index 93288b9..74b0283 100644 --- a/.vimrc +++ b/.vimrc @@ -1170,7 +1170,14 @@ fu! StopRunTask() call HideAsyncResults() endfu -fu! Build(optimized=0, silent=0) +" @incomplete use the same path searching from RunProgram +" @incomplete use the same path searching from RunProgram +" @incomplete use the same path searching from RunProgram +" @incomplete use the same path searching from RunProgram +" @incomplete use the same path searching from RunProgram +" @incomplete use the same path searching from RunProgram +" @incomplete use the same path searching from RunProgram +fu! Build(optimized=0, silent=0) abort let l:async_cmd = "AsyncRun! " if a:silent let l:async_cmd .= "-post=call\\ HideAsyncResults() " @@ -1178,7 +1185,7 @@ fu! Build(optimized=0, silent=0) let l:is_jai = 0 let l:has_jai_build_file = 0 - let l:has_jai_first_file = 1 + let l:has_jai_first_file = 0 let l:ext = tolower(expand('%:e')) let l:current_dir = expand('%:p:h') @@ -1194,16 +1201,16 @@ fu! Build(optimized=0, silent=0) if filereadable(l:current_dir . "/build.jai") || filereadable(l:current_dir . "/first.jai") || ((l:one_dir_back != "/") && (filereadable(l:one_dir_back . "/build.jai") || filereadable(l:one_dir_back . "/first.jai"))) let l:has_jai_build_file = 1 - if filereadable(l:current_dir . "/build.jai") == 1 + if filereadable(l:current_dir . "/build.jai") let l:cmd = "jai ". l:current_dir . "/build.jai" - elseif filereadable(l:current_dir . "/first.jai") == 1 + elseif filereadable(l:current_dir . "/first.jai") let l:cmd = "jai ". l:current_dir . "/first.jai" let l:has_jai_first_file = 1 else " It's one directory back. We don't want to include '../' in " the cmd because then our reported paths in the program get " botched, e.g. path shown in an assert error. - if filereadable(l:one_dir_back . "/build.jai") == 1 + if filereadable(l:one_dir_back . "/build.jai") let l:cmd = "jai " . l:one_dir_back . "/build.jai" else let l:cmd = "jai " . l:one_dir_back . "/first.jai" @@ -1214,7 +1221,16 @@ fu! Build(optimized=0, silent=0) let l:cmd = "jai % " endif else - let l:cmd .= './build* ' + if filereadable("build") && !isdirectory("build") + let l:cmd .= './build ' + elseif filereadable("build.sh") + let l:cmd .= './build.sh ' + elseif filereadable("build.bat") + let l:cmd .= './build.bat ' + else + let l:cmd .= './build* ' + endif + if a:optimized == 1 let l:cmd .= ' -o' endif @@ -1250,11 +1266,6 @@ fu! Build(optimized=0, silent=0) else echo "Compiling debug " . expand('%:t') endif - - " If there's a local modules/ directory then we'll import it. - if isdirectory(l:current_dir . "/modules") - let l:cmd .= " -import_dir modules" - endif endif if g:campo_jai_metaprogram_args != ""