Skip to content

Commit 15cd120

Browse files
committed
feat(.solution.toml): Now accept multiple ocurrences of executable.
1 parent fbb83e7 commit 15cd120

File tree

12 files changed

+249
-178
lines changed

12 files changed

+249
-178
lines changed

lua/compiler/languages/asm.lua

+17-16
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,17 @@ function M.action(selected_option)
109109
vim.cmd("OverseerOpen")
110110
elseif selected_option == "option4" then
111111
local entry_points
112+
local task = {}
112113
local tasks = {}
113-
local task
114+
local executables = {}
114115

115116
-- if .solution file exists in working dir
116117
local solution_file = utils.get_solution_file()
117118
if solution_file then
118119
local config = utils.parse_solution_file(solution_file)
119-
local executable
120120

121121
for entry, variables in pairs(config) do
122-
if variables.executable then
123-
executable = utils.os_path(variables.executable)
124-
goto continue
125-
end
122+
if entry == "executables" then goto continue end
126123
entry_point = utils.os_path(variables.entry_point)
127124
entry_point_dir = vim.fn.fnamemodify(entry_point, ":h")
128125
files = utils.find_files(entry_point_dir, "*.asm")
@@ -157,20 +154,24 @@ function M.action(selected_option)
157154
::continue::
158155
end
159156

160-
if executable then
161-
task = { "shell", name = "- Run program → " .. executable,
162-
cmd = executable .. -- run
163-
" && echo && echo " .. executable .. -- echo
164-
" && echo '" .. final_message .. "'"
165-
}
166-
table.insert(tasks, task)
167-
else
168-
task = {}
157+
local solution_executables = config["executables"]
158+
if solution_executables then
159+
for entry, executable in pairs(solution_executables) do
160+
task = { "shell", name = "- Run program → " .. executable,
161+
cmd = executable .. -- run
162+
" && echo " .. executable .. -- echo
163+
" && echo '" .. final_message .. "'"
164+
}
165+
table.insert(executables, task) -- store all the executables we've created
166+
table.insert(tasks, executables)
167+
end
169168
end
170169

171170
task = overseer.new_task({
172171
name = "- Assembly compiler", strategy = { "orchestrator",
173-
tasks = tasks
172+
tasks = tasks -- Build all the programs in the solution in parallel
173+
-- Link all the programs in the solution in parallel
174+
-- -- Then run the solution executable(s)
174175
}})
175176
task:start()
176177
vim.cmd("OverseerOpen")

lua/compiler/languages/c.lua

+17-18
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,25 @@ function M.action(selected_option)
5555
name = "- C compiler",
5656
strategy = { "orchestrator",
5757
tasks = {{ "shell", name = "- Run program → " .. entry_point,
58-
cmd = output .. -- run
59-
" && echo " .. output .. -- echo
58+
cmd = output .. -- run
59+
" && echo " .. output .. -- echo
6060
" && echo '" .. final_message .. "'"
6161
},},},})
6262
task:start()
6363
vim.cmd("OverseerOpen")
6464
elseif selected_option == "option4" then
6565
local entry_points
66+
local task = {}
6667
local tasks = {}
67-
local task
68+
local executables = {}
6869

6970
-- if .solution file exists in working dir
7071
local solution_file = utils.get_solution_file()
7172
if solution_file then
7273
local config = utils.parse_solution_file(solution_file)
73-
local executable
7474

7575
for entry, variables in pairs(config) do
76-
if variables.executable then
77-
executable = utils.os_path(variables.executable)
78-
goto continue
79-
end
76+
if entry == "executables" then goto continue end
8077
entry_point = utils.os_path(variables.entry_point)
8178
files = utils.find_files_to_compile(entry_point, "*.c")
8279
output = utils.os_path(variables.output)
@@ -93,21 +90,23 @@ function M.action(selected_option)
9390
::continue::
9491
end
9592

96-
if executable then
97-
task = { "shell", name = "- Run program → " .. executable,
98-
cmd = executable .. -- run
99-
" && echo " .. executable .. -- echo
100-
" && echo '" .. final_message .. "'"
101-
}
102-
else
103-
task = {}
93+
local solution_executables = config["executables"]
94+
if solution_executables then
95+
for entry, executable in pairs(solution_executables) do
96+
task = { "shell", name = "- Run program → " .. executable,
97+
cmd = executable .. -- run
98+
" && echo " .. executable .. -- echo
99+
" && echo '" .. final_message .. "'"
100+
}
101+
table.insert(executables, task) -- store all the executables we've created
102+
end
104103
end
105104

106105
task = overseer.new_task({
107106
name = "- C compiler", strategy = { "orchestrator",
108107
tasks = {
109-
tasks, -- Build all the programs in the solution in parallel
110-
task -- Then run the solution executable
108+
tasks, -- Build all the programs in the solution in parallel
109+
executables -- Then run the solution executable(s)
111110
}}})
112111
task:start()
113112
vim.cmd("OverseerOpen")

lua/compiler/languages/cpp.lua

+15-16
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,16 @@ function M.action(selected_option)
6363
elseif selected_option == "option4" then
6464
local entry_points
6565
local tasks = {}
66-
local task
66+
local task = {}
67+
local executables = {}
6768

6869
-- if .solution file exists in working dir
6970
local solution_file = utils.get_solution_file()
7071
if solution_file then
7172
local config = utils.parse_solution_file(solution_file)
72-
local executable
7373

7474
for entry, variables in pairs(config) do
75-
if variables.executable then
76-
executable = utils.os_path(variables.executable)
77-
goto continue
78-
end
75+
if entry == "executables" then goto continue end
7976
entry_point = utils.os_path(variables.entry_point)
8077
files = utils.find_files_to_compile(entry_point, "*.cpp")
8178
output = utils.os_path(variables.output)
@@ -92,21 +89,23 @@ function M.action(selected_option)
9289
::continue::
9390
end
9491

95-
if executable then
96-
task = { "shell", name = "- Run program → " .. executable,
97-
cmd = executable .. -- run
98-
" && echo " .. executable .. -- echo
99-
" && echo '" .. final_message .. "'"
100-
}
101-
else
102-
task = {}
92+
local solution_executables = config["executables"]
93+
if solution_executables then
94+
for entry, executable in pairs(solution_executables) do
95+
task = { "shell", name = "- Run program → " .. executable,
96+
cmd = executable .. -- run
97+
" && echo " .. executable .. -- echo
98+
" && echo '" .. final_message .. "'"
99+
}
100+
table.insert(executables, task) -- store all the executables we've created
101+
end
103102
end
104103

105104
task = overseer.new_task({
106105
name = "- C++ compiler", strategy = { "orchestrator",
107106
tasks = {
108-
tasks, -- Build all the programs in the solution in parallel
109-
task -- Then run the solution executable
107+
tasks, -- Build all the programs in the solution in parallel
108+
executables -- Then run the solution executable(s)
110109
}}})
111110
task:start()
112111
vim.cmd("OverseerOpen")

lua/compiler/languages/cs.lua

+15-16
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,17 @@ function M.action(selected_option)
6666
vim.cmd("OverseerOpen")
6767
elseif selected_option == "option4" then
6868
local entry_points
69+
local task = {}
6970
local tasks = {}
70-
local task
71+
local executables = {}
7172

7273
-- if .solution file exists in working dir
7374
local solution_file = utils.get_solution_file()
7475
if solution_file then
7576
local config = utils.parse_solution_file(solution_file)
76-
local executable
7777

7878
for entry, variables in pairs(config) do
79-
if variables.executable then
80-
executable = utils.os_path(variables.executable)
81-
goto continue
82-
end
79+
if entry == "executables" then goto continue end
8380
entry_point = utils.os_path(variables.entry_point)
8481
files = utils.find_files_to_compile(entry_point, "*.cs")
8582
output = utils.os_path(variables.output)
@@ -96,21 +93,23 @@ function M.action(selected_option)
9693
::continue::
9794
end
9895

99-
if executable then
100-
task = { "shell", name = "- Run program → " .. executable,
101-
cmd = "mono " .. executable .. -- run
102-
" && echo " .. executable .. -- echo
103-
" && echo '" .. final_message .. "'"
104-
}
105-
else
106-
task = {}
96+
local solution_executables = config["executables"]
97+
if solution_executables then
98+
for entry, executable in pairs(solution_executables) do
99+
task = { "shell", name = "- Run program → " .. executable,
100+
cmd = "mono " .. executable .. -- run
101+
" && echo " .. executable .. -- echo
102+
" && echo '" .. final_message .. "'"
103+
}
104+
table.insert(executables, task) -- store all the executables we've created
105+
end
107106
end
108107

109108
task = overseer.new_task({
110109
name = "- C# compiler", strategy = { "orchestrator",
111110
tasks = {
112-
tasks, -- Build all the programs in the solution in parallel
113-
task -- Then run the solution executable
111+
tasks, -- Build all the programs in the solution in parallel
112+
executables -- Then run the solution executable(s)
114113
}}})
115114
task:start()
116115
vim.cmd("OverseerOpen")

lua/compiler/languages/go.lua

+15-16
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,17 @@ function M.action(selected_option)
6363
vim.cmd("OverseerOpen")
6464
elseif selected_option == "option4" then
6565
local entry_points
66+
local task = {}
6667
local tasks = {}
67-
local task
68+
local executables = {}
6869

6970
-- if .solution file exists in working dir
7071
local solution_file = utils.get_solution_file()
7172
if solution_file then
7273
local config = utils.parse_solution_file(solution_file)
73-
local executable
7474

7575
for entry, variables in pairs(config) do
76-
if variables.executable then
77-
executable = utils.os_path(variables.executable)
78-
goto continue
79-
end
76+
if entry == "executables" then goto continue end
8077
entry_point = utils.os_path(variables.entry_point)
8178
files = utils.find_files_to_compile(entry_point, "*.go")
8279
output = utils.os_path(variables.output)
@@ -93,21 +90,23 @@ function M.action(selected_option)
9390
::continue::
9491
end
9592

96-
if executable then
97-
task = { "shell", name = "- Run program → " .. executable,
98-
cmd = executable .. -- run
99-
" && echo " .. executable .. -- echo
100-
" && echo '" .. final_message .. "'"
101-
}
102-
else
103-
task = {}
93+
local solution_executables = config["executables"]
94+
if solution_executables then
95+
for entry, executable in pairs(solution_executables) do
96+
task = { "shell", name = "- Run program → " .. executable,
97+
cmd = executable .. -- run
98+
" && echo " .. executable .. -- echo
99+
" && echo '" .. final_message .. "'"
100+
}
101+
table.insert(executables, task) -- store all the executables we've created
102+
end
104103
end
105104

106105
task = overseer.new_task({
107106
name = "- Go compiler", strategy = { "orchestrator",
108107
tasks = {
109-
tasks, -- Build all the programs in the solution in parallel
110-
task -- Then run the solution executable
108+
tasks, -- Build all the programs in the solution in parallel
109+
executables -- Then run the solution executable(s)
111110
}}})
112111
task:start()
113112
vim.cmd("OverseerOpen")

lua/compiler/languages/java.lua

+15-18
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,17 @@ function M.action(selected_option)
6363
vim.cmd("OverseerOpen")
6464
elseif selected_option == "option4" then
6565
local entry_points
66+
local task = {}
6667
local tasks = {}
67-
local task
68+
local executables = {}
6869

6970
-- if .solution file exists in working dir
7071
local solution_file = utils.get_solution_file()
7172
if solution_file then
7273
local config = utils.parse_solution_file(solution_file)
73-
local executable
7474

7575
for entry, variables in pairs(config) do
76-
if variables.executable then
77-
executable = utils.os_path(variables.executable)
78-
goto continue
79-
end
76+
if entry == "executables" then goto continue end
8077
entry_point = utils.os_path(variables.entry_point)
8178
files = utils.find_files_to_compile(entry_point, "*.java")
8279
output = utils.os_path(variables.output)
@@ -93,23 +90,23 @@ function M.action(selected_option)
9390
::continue::
9491
end
9592

96-
if executable then
97-
output_dir = vim.fn.fnamemodify(executable, ":h")
98-
output_filename = vim.fn.fnamemodify(executable, ":t:r")
99-
task = { "shell", name = "- Run program → " .. executable,
100-
cmd = "java -cp " .. output_dir .. " " .. output_filename .. -- run
101-
" && echo " .. executable .. -- echo
102-
" && echo '" .. final_message .. "'"
103-
}
104-
else
105-
task = {}
93+
local solution_executables = config["executables"]
94+
if solution_executables then
95+
for entry, executable in pairs(solution_executables) do
96+
task = { "shell", name = "- Run program → " .. executable,
97+
cmd = "java -cp " .. output_dir .. " " .. output_filename .. -- run
98+
" && echo " .. executable .. -- echo
99+
" && echo '" .. final_message .. "'"
100+
}
101+
table.insert(executables, task) -- store all the executables we've created
102+
end
106103
end
107104

108105
task = overseer.new_task({
109106
name = "- Java compiler", strategy = { "orchestrator",
110107
tasks = {
111-
tasks, -- Build all the programs in the solution in parallel
112-
task -- Then run the solution executable
108+
tasks, -- Build all the programs in the solution in parallel
109+
executables -- Then run the solution executable(s)
113110
}}})
114111
task:start()
115112
vim.cmd("OverseerOpen")

0 commit comments

Comments
 (0)