diff options
author | pommicket <pommicket@gmail.com> | 2022-12-24 00:28:50 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-24 00:28:50 -0500 |
commit | 1c346f2aba30fcb581f20f2b67bd5e6adcb4a7e6 (patch) | |
tree | 863b8ebbd37c67cb4dd0015d5c72a436dd89bc7e /build.c | |
parent | 8d96a4b0f0ebb059a63cc4c3193e0169ccf4f5b5 (diff) |
find build directory in a much better way
this will be useful for LSPs
Diffstat (limited to 'build.c')
-rw-r--r-- | build.c | 39 |
1 files changed, 8 insertions, 31 deletions
@@ -78,47 +78,24 @@ static void build_start_with_command(Ted *ted, char const *command) { } static void build_start(Ted *ted) { - bool cargo = false, make = false; - - strbuf_cpy(ted->build_dir, ted->cwd); Settings *settings = ted_active_settings(ted); - char *command = settings->build_default_command; - - change_directory(ted->cwd); + char *root = ted_get_root_dir(ted); + strbuf_cpy(ted->build_dir, root); + change_directory(root); + free(root); + #if _WIN32 if (fs_file_exists("make.bat")) { command = "make.bat"; } else #endif - // check if Cargo.toml exists in this or the parent/parent's parent directory if (fs_file_exists("Cargo.toml")) { - cargo = true; - } else if (fs_file_exists(".." PATH_SEPARATOR_STR "Cargo.toml")) { - ted_path_full(ted, "..", ted->build_dir, sizeof ted->build_dir); - cargo = true; - } else if (fs_file_exists(".." PATH_SEPARATOR_STR ".." PATH_SEPARATOR_STR "Cargo.toml")) { - ted_path_full(ted, "../..", ted->build_dir, sizeof ted->build_dir); - cargo = true; - } else - // Check if Makefile exists in this or the parent/parent's parent directory - if (fs_file_exists("Makefile")) { - make = true; - } else if (fs_file_exists(".." PATH_SEPARATOR_STR "Makefile")) { - ted_path_full(ted, "..", ted->build_dir, sizeof ted->build_dir); - make = true; - } else if (fs_file_exists(".." PATH_SEPARATOR_STR ".." PATH_SEPARATOR_STR "Makefile")) { - ted_path_full(ted, "../..", ted->build_dir, sizeof ted->build_dir); - make = true; - } - - - // @TODO(eventually): `go build` - - if (cargo) { command = "cargo build"; - } else if (make) { + } else if (fs_file_exists("Makefile")) { command = "make -j12"; + } else if (fs_file_exists("go.mod")) { + command = "go build"; } build_start_with_command(ted, command); |