Skip to content

Commit

Permalink
feat(.solution.toml): Now accept multiple ocurrences of executable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeioth committed Aug 22, 2023
1 parent fbb83e7 commit 15cd120
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 178 deletions.
33 changes: 17 additions & 16 deletions lua/compiler/languages/asm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,17 @@ function M.action(selected_option)
vim.cmd("OverseerOpen")
elseif selected_option == "option4" then
local entry_points
local task = {}
local tasks = {}
local task
local executables = {}

-- if .solution file exists in working dir
local solution_file = utils.get_solution_file()
if solution_file then
local config = utils.parse_solution_file(solution_file)
local executable

for entry, variables in pairs(config) do
if variables.executable then
executable = utils.os_path(variables.executable)
goto continue
end
if entry == "executables" then goto continue end
entry_point = utils.os_path(variables.entry_point)
entry_point_dir = vim.fn.fnamemodify(entry_point, ":h")
files = utils.find_files(entry_point_dir, "*.asm")
Expand Down Expand Up @@ -157,20 +154,24 @@ function M.action(selected_option)
::continue::
end

if executable then
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(tasks, task)
else
task = {}
local solution_executables = config["executables"]
if solution_executables then
for entry, executable in pairs(solution_executables) do
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(executables, task) -- store all the executables we've created
table.insert(tasks, executables)
end
end

task = overseer.new_task({
name = "- Assembly compiler", strategy = { "orchestrator",
tasks = tasks
tasks = tasks -- Build all the programs in the solution in parallel
-- Link all the programs in the solution in parallel
-- -- Then run the solution executable(s)
}})
task:start()
vim.cmd("OverseerOpen")
Expand Down
35 changes: 17 additions & 18 deletions lua/compiler/languages/c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,25 @@ function M.action(selected_option)
name = "- C compiler",
strategy = { "orchestrator",
tasks = {{ "shell", name = "- Run program → " .. entry_point,
cmd = output .. -- run
" && echo " .. output .. -- echo
cmd = output .. -- run
" && echo " .. output .. -- echo
" && echo '" .. final_message .. "'"
},},},})
task:start()
vim.cmd("OverseerOpen")
elseif selected_option == "option4" then
local entry_points
local task = {}
local tasks = {}
local task
local executables = {}

-- if .solution file exists in working dir
local solution_file = utils.get_solution_file()
if solution_file then
local config = utils.parse_solution_file(solution_file)
local executable

for entry, variables in pairs(config) do
if variables.executable then
executable = utils.os_path(variables.executable)
goto continue
end
if entry == "executables" then goto continue end
entry_point = utils.os_path(variables.entry_point)
files = utils.find_files_to_compile(entry_point, "*.c")
output = utils.os_path(variables.output)
Expand All @@ -93,21 +90,23 @@ function M.action(selected_option)
::continue::
end

if executable then
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
else
task = {}
local solution_executables = config["executables"]
if solution_executables then
for entry, executable in pairs(solution_executables) do
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(executables, task) -- store all the executables we've created
end
end

task = overseer.new_task({
name = "- C compiler", strategy = { "orchestrator",
tasks = {
tasks, -- Build all the programs in the solution in parallel
task -- Then run the solution executable
tasks, -- Build all the programs in the solution in parallel
executables -- Then run the solution executable(s)
}}})
task:start()
vim.cmd("OverseerOpen")
Expand Down
31 changes: 15 additions & 16 deletions lua/compiler/languages/cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,16 @@ function M.action(selected_option)
elseif selected_option == "option4" then
local entry_points
local tasks = {}
local task
local task = {}
local executables = {}

-- if .solution file exists in working dir
local solution_file = utils.get_solution_file()
if solution_file then
local config = utils.parse_solution_file(solution_file)
local executable

for entry, variables in pairs(config) do
if variables.executable then
executable = utils.os_path(variables.executable)
goto continue
end
if entry == "executables" then goto continue end
entry_point = utils.os_path(variables.entry_point)
files = utils.find_files_to_compile(entry_point, "*.cpp")
output = utils.os_path(variables.output)
Expand All @@ -92,21 +89,23 @@ function M.action(selected_option)
::continue::
end

if executable then
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
else
task = {}
local solution_executables = config["executables"]
if solution_executables then
for entry, executable in pairs(solution_executables) do
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(executables, task) -- store all the executables we've created
end
end

task = overseer.new_task({
name = "- C++ compiler", strategy = { "orchestrator",
tasks = {
tasks, -- Build all the programs in the solution in parallel
task -- Then run the solution executable
tasks, -- Build all the programs in the solution in parallel
executables -- Then run the solution executable(s)
}}})
task:start()
vim.cmd("OverseerOpen")
Expand Down
31 changes: 15 additions & 16 deletions lua/compiler/languages/cs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,17 @@ function M.action(selected_option)
vim.cmd("OverseerOpen")
elseif selected_option == "option4" then
local entry_points
local task = {}
local tasks = {}
local task
local executables = {}

-- if .solution file exists in working dir
local solution_file = utils.get_solution_file()
if solution_file then
local config = utils.parse_solution_file(solution_file)
local executable

for entry, variables in pairs(config) do
if variables.executable then
executable = utils.os_path(variables.executable)
goto continue
end
if entry == "executables" then goto continue end
entry_point = utils.os_path(variables.entry_point)
files = utils.find_files_to_compile(entry_point, "*.cs")
output = utils.os_path(variables.output)
Expand All @@ -96,21 +93,23 @@ function M.action(selected_option)
::continue::
end

if executable then
task = { "shell", name = "- Run program → " .. executable,
cmd = "mono " .. executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
else
task = {}
local solution_executables = config["executables"]
if solution_executables then
for entry, executable in pairs(solution_executables) do
task = { "shell", name = "- Run program → " .. executable,
cmd = "mono " .. executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(executables, task) -- store all the executables we've created
end
end

task = overseer.new_task({
name = "- C# compiler", strategy = { "orchestrator",
tasks = {
tasks, -- Build all the programs in the solution in parallel
task -- Then run the solution executable
tasks, -- Build all the programs in the solution in parallel
executables -- Then run the solution executable(s)
}}})
task:start()
vim.cmd("OverseerOpen")
Expand Down
31 changes: 15 additions & 16 deletions lua/compiler/languages/go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,17 @@ function M.action(selected_option)
vim.cmd("OverseerOpen")
elseif selected_option == "option4" then
local entry_points
local task = {}
local tasks = {}
local task
local executables = {}

-- if .solution file exists in working dir
local solution_file = utils.get_solution_file()
if solution_file then
local config = utils.parse_solution_file(solution_file)
local executable

for entry, variables in pairs(config) do
if variables.executable then
executable = utils.os_path(variables.executable)
goto continue
end
if entry == "executables" then goto continue end
entry_point = utils.os_path(variables.entry_point)
files = utils.find_files_to_compile(entry_point, "*.go")
output = utils.os_path(variables.output)
Expand All @@ -93,21 +90,23 @@ function M.action(selected_option)
::continue::
end

if executable then
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
else
task = {}
local solution_executables = config["executables"]
if solution_executables then
for entry, executable in pairs(solution_executables) do
task = { "shell", name = "- Run program → " .. executable,
cmd = executable .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(executables, task) -- store all the executables we've created
end
end

task = overseer.new_task({
name = "- Go compiler", strategy = { "orchestrator",
tasks = {
tasks, -- Build all the programs in the solution in parallel
task -- Then run the solution executable
tasks, -- Build all the programs in the solution in parallel
executables -- Then run the solution executable(s)
}}})
task:start()
vim.cmd("OverseerOpen")
Expand Down
33 changes: 15 additions & 18 deletions lua/compiler/languages/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,17 @@ function M.action(selected_option)
vim.cmd("OverseerOpen")
elseif selected_option == "option4" then
local entry_points
local task = {}
local tasks = {}
local task
local executables = {}

-- if .solution file exists in working dir
local solution_file = utils.get_solution_file()
if solution_file then
local config = utils.parse_solution_file(solution_file)
local executable

for entry, variables in pairs(config) do
if variables.executable then
executable = utils.os_path(variables.executable)
goto continue
end
if entry == "executables" then goto continue end
entry_point = utils.os_path(variables.entry_point)
files = utils.find_files_to_compile(entry_point, "*.java")
output = utils.os_path(variables.output)
Expand All @@ -93,23 +90,23 @@ function M.action(selected_option)
::continue::
end

if executable then
output_dir = vim.fn.fnamemodify(executable, ":h")
output_filename = vim.fn.fnamemodify(executable, ":t:r")
task = { "shell", name = "- Run program → " .. executable,
cmd = "java -cp " .. output_dir .. " " .. output_filename .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
else
task = {}
local solution_executables = config["executables"]
if solution_executables then
for entry, executable in pairs(solution_executables) do
task = { "shell", name = "- Run program → " .. executable,
cmd = "java -cp " .. output_dir .. " " .. output_filename .. -- run
" && echo " .. executable .. -- echo
" && echo '" .. final_message .. "'"
}
table.insert(executables, task) -- store all the executables we've created
end
end

task = overseer.new_task({
name = "- Java compiler", strategy = { "orchestrator",
tasks = {
tasks, -- Build all the programs in the solution in parallel
task -- Then run the solution executable
tasks, -- Build all the programs in the solution in parallel
executables -- Then run the solution executable(s)
}}})
task:start()
vim.cmd("OverseerOpen")
Expand Down
Loading

0 comments on commit 15cd120

Please sign in to comment.