mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
Merge pull request #965 from MihailRis/update-headless-sub-instances
add project arguments table passing in app.start_background_instance
This commit is contained in:
commit
c2a77509f7
3 changed files with 31 additions and 2 deletions
|
|
@ -172,7 +172,9 @@ app.start_background_instance(
|
||||||
-- script file
|
-- script file
|
||||||
app_script: string,
|
app_script: string,
|
||||||
-- log file
|
-- log file
|
||||||
output_file: string | nil
|
output_file: string,
|
||||||
|
-- project parameters (can be read with vc.get_project_arg(name))
|
||||||
|
project_args: table<string, string> | nil
|
||||||
) -> int
|
) -> int
|
||||||
|
|
||||||
-- Checks if the engine sub-instance is alive.
|
-- Checks if the engine sub-instance is alive.
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,9 @@ app.start_background_instance(
|
||||||
-- файл сценария
|
-- файл сценария
|
||||||
app_script: string,
|
app_script: string,
|
||||||
-- файл лога
|
-- файл лога
|
||||||
output_file: string | nil
|
output_file: string,
|
||||||
|
-- параметры проекта, что будут доступны через vc.get_project_arg(name)
|
||||||
|
project_args: table<string, string> | nil,
|
||||||
) -> int
|
) -> int
|
||||||
|
|
||||||
-- Проверяет, жив ли под-экземпляр движка.
|
-- Проверяет, жив ли под-экземпляр движка.
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,20 @@ static int l_start_background_instance(lua::State* L) {
|
||||||
|
|
||||||
auto scriptPath = lua::require_lstring(L, 1);
|
auto scriptPath = lua::require_lstring(L, 1);
|
||||||
io::path outputPath = lua::isstring(L, 2) ? lua::require_lstring(L, 2) : "";
|
io::path outputPath = lua::isstring(L, 2) ? lua::require_lstring(L, 2) : "";
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, std::string>> projectArgs;
|
||||||
|
if (lua::istable(L, 3)) {
|
||||||
|
lua::pushnil(L);
|
||||||
|
while (lua::next(L, 3)) {
|
||||||
|
lua::pushvalue(L, -2);
|
||||||
|
auto key = lua::tolstring(L, -1);
|
||||||
|
auto value = lua::tolstring(L, -2);
|
||||||
|
projectArgs.emplace_back(key, value);
|
||||||
|
lua::pop(L, 2);
|
||||||
|
}
|
||||||
|
lua::pop(L);
|
||||||
|
}
|
||||||
|
|
||||||
const auto& paths = engine->getPaths();
|
const auto& paths = engine->getPaths();
|
||||||
|
|
||||||
std::vector<std::string> args {
|
std::vector<std::string> args {
|
||||||
|
|
@ -419,6 +433,17 @@ static int l_start_background_instance(lua::State* L) {
|
||||||
args.emplace_back("--project");
|
args.emplace_back("--project");
|
||||||
args.emplace_back(io::resolve(engine->getProject().path).u8string());
|
args.emplace_back(io::resolve(engine->getProject().path).u8string());
|
||||||
|
|
||||||
|
if (!projectArgs.empty()) {
|
||||||
|
args.emplace_back("--");
|
||||||
|
for (const auto& [key, value] : projectArgs) {
|
||||||
|
if (key.empty()) {
|
||||||
|
throw std::runtime_error("empty project argument name passed");
|
||||||
|
}
|
||||||
|
args.emplace_back("--" + key);
|
||||||
|
args.emplace_back(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int handle = -1;
|
int handle = -1;
|
||||||
for (int i = 0; i < ::processes.size(); i++) {
|
for (int i = 0; i < ::processes.size(); i++) {
|
||||||
if (!::processes[i] || !::processes[i]->isActive()) {
|
if (!::processes[i] || !::processes[i]->isActive()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue