Update c.lua
This commit is contained in:
+17
-8
@@ -4,6 +4,7 @@ M.c_build = nil
|
||||
M.c_run = nil
|
||||
M.new_c_file = nil
|
||||
M.new_c_project = nil
|
||||
M.project_name = nil
|
||||
|
||||
-- Default config
|
||||
M.config = {
|
||||
@@ -132,6 +133,7 @@ function M.create_project()
|
||||
end
|
||||
|
||||
-- Paths for the project
|
||||
M.project_name = project_name
|
||||
local project_root = vim.fn.expand(M.config.project_root) .. "/" .. project_name
|
||||
local src_dir = project_root .. "/src"
|
||||
local build_dir = project_root .. "/build"
|
||||
@@ -226,17 +228,24 @@ end
|
||||
-- Compile Java files
|
||||
function M.build()
|
||||
local current_dir = vim.fn.expand("%:p:h")
|
||||
local project_root = current_dir:match("(.*)/src")
|
||||
if not project_root then
|
||||
print("Error: Must be inside the 'src' directory.")
|
||||
|
||||
-- local compile_command = "mv " .. legacy_src_dir .. "/* " .. src_dir ..
|
||||
-- " && mv " .. legacy_out_dir .. "/* " .. build_dir ..
|
||||
-- " && rm -rd " .. project_root .. "/" .. "root/"
|
||||
local project_root = vim.fn.expand(M.config.project_root) .. "/" .. M.project_name
|
||||
local into_build = "cd " .. project_root .. "/build"
|
||||
local into_build_status = vim.fn.system(into_build)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
print("Could not go into build dir:\n" .. into_build_status)
|
||||
end
|
||||
|
||||
local project_root_build = current_dir:match("(.*)/build")
|
||||
if not project_root_build then
|
||||
print("Error: Must be inside the 'build' directory.")
|
||||
return
|
||||
end
|
||||
|
||||
local src_dir = project_root .. "/src"
|
||||
local out_dir = project_root .. "/build"
|
||||
|
||||
vim.fn.mkdir(out_dir, "p")
|
||||
local compile_command = string.format("javac -d %s %s/*.java", out_dir, src_dir)
|
||||
local compile_command = "cmake .. && make"
|
||||
local compile_status = vim.fn.system(compile_command)
|
||||
|
||||
if vim.v.shell_error ~= 0 then
|
||||
|
||||
Reference in New Issue
Block a user