|
|
|
@ -167,22 +167,31 @@ void Project::debug_update_stop() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Project::Base> Project::create() { |
|
|
|
std::shared_ptr<Project::Base> Project::create(const boost::filesystem::path &file_path) { |
|
|
|
std::unique_ptr<Project::Build> build; |
|
|
|
std::unique_ptr<Project::Build> build; |
|
|
|
|
|
|
|
std::string language_id; |
|
|
|
if(auto view = Notebook::get().get_current_view()) { |
|
|
|
if(!file_path.empty()) { |
|
|
|
|
|
|
|
build = Build::create(file_path); |
|
|
|
|
|
|
|
if(auto language = Source::guess_language(file_path)) |
|
|
|
|
|
|
|
language_id = language->get_id(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
build = Build::create(view->file_path); |
|
|
|
build = Build::create(view->file_path); |
|
|
|
if(view->language_id == "markdown") |
|
|
|
language_id = view->language_id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(build) { |
|
|
|
|
|
|
|
if(language_id == "markdown") |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Markdown(std::move(build))); |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Markdown(std::move(build))); |
|
|
|
if(view->language_id == "js") |
|
|
|
if(language_id == "js") |
|
|
|
return std::shared_ptr<Project::Base>(new Project::JavaScript(std::move(build))); |
|
|
|
return std::shared_ptr<Project::Base>(new Project::JavaScript(std::move(build))); |
|
|
|
if(view->language_id == "python") |
|
|
|
if(language_id == "python") |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Python(std::move(build))); |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Python(std::move(build))); |
|
|
|
if(view->language_id == "html") |
|
|
|
if(language_id == "html") |
|
|
|
return std::shared_ptr<Project::Base>(new Project::HTML(std::move(build))); |
|
|
|
return std::shared_ptr<Project::Base>(new Project::HTML(std::move(build))); |
|
|
|
if(view->language_id == "go") |
|
|
|
if(language_id == "go") |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Go(std::move(build))); |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Go(std::move(build))); |
|
|
|
if(view->language_id == "julia") |
|
|
|
if(language_id == "julia") |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Julia(std::move(build))); |
|
|
|
return std::shared_ptr<Project::Base>(new Project::Julia(std::move(build))); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
@ -210,7 +219,7 @@ void Project::Base::compile() { |
|
|
|
Info::get().print("Could not find a supported project"); |
|
|
|
Info::get().print("Could not find a supported project"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::Base::compile_and_run() { |
|
|
|
void Project::Base::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
Info::get().print("Could not find a supported project"); |
|
|
|
Info::get().print("Could not find a supported project"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -727,7 +736,7 @@ void Project::Clang::compile() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::Clang::compile_and_run() { |
|
|
|
void Project::Clang::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
auto default_build_path = build->get_default_path(); |
|
|
|
auto default_build_path = build->get_default_path(); |
|
|
|
if(default_build_path.empty() || !build->update_default()) |
|
|
|
if(default_build_path.empty() || !build->update_default()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
@ -740,8 +749,13 @@ void Project::Clang::compile_and_run() { |
|
|
|
arguments = run_arguments_it->second; |
|
|
|
arguments = run_arguments_it->second; |
|
|
|
|
|
|
|
|
|
|
|
if(arguments.empty()) { |
|
|
|
if(arguments.empty()) { |
|
|
|
|
|
|
|
boost::filesystem::path executable; |
|
|
|
|
|
|
|
if(!file_path.empty()) |
|
|
|
|
|
|
|
executable = build->get_executable(file_path); |
|
|
|
|
|
|
|
else { |
|
|
|
auto view = Notebook::get().get_current_view(); |
|
|
|
auto view = Notebook::get().get_current_view(); |
|
|
|
auto executable = build->get_executable(view ? view->file_path : Directories::get().path); |
|
|
|
executable = build->get_executable(view ? view->file_path : Directories::get().path); |
|
|
|
|
|
|
|
} |
|
|
|
if(executable.empty()) { |
|
|
|
if(executable.empty()) { |
|
|
|
if(!build->is_valid(default_build_path)) |
|
|
|
if(!build->is_valid(default_build_path)) |
|
|
|
Terminal::get().print("\e[31mError\e[m: build folder no longer valid, please use Recreate Build in the Project menu.\n", true); |
|
|
|
Terminal::get().print("\e[31mError\e[m: build folder no longer valid, please use Recreate Build in the Project menu.\n", true); |
|
|
|
@ -844,9 +858,15 @@ void Project::Clang::recreate_build() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Project::Markdown::compile_and_run() { |
|
|
|
void Project::Markdown::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
if(auto view = Notebook::get().get_current_view()) { |
|
|
|
std::string command; |
|
|
|
auto command = Config::get().project.markdown_command + ' ' + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
if(!file_path.empty()) |
|
|
|
|
|
|
|
command = Config::get().project.markdown_command + ' ' + filesystem::escape_argument(filesystem::get_short_path(file_path).string()); |
|
|
|
|
|
|
|
else if(auto view = Notebook::get().get_current_view()) |
|
|
|
|
|
|
|
command = Config::get().project.markdown_command + ' ' + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Terminal::get().async_process( |
|
|
|
Terminal::get().async_process( |
|
|
|
command, "", [command](int exit_status) { |
|
|
|
command, "", [command](int exit_status) { |
|
|
|
if(exit_status == 127) |
|
|
|
if(exit_status == 127) |
|
|
|
@ -854,15 +874,18 @@ void Project::Markdown::compile_and_run() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
true); |
|
|
|
true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Project::Python::compile_and_run() { |
|
|
|
void Project::Python::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
std::string command = Config::get().project.python_command + ' '; |
|
|
|
std::string command = Config::get().project.python_command + ' '; |
|
|
|
boost::filesystem::path path; |
|
|
|
boost::filesystem::path path; |
|
|
|
if(dynamic_cast<PythonMain *>(build.get())) { |
|
|
|
if(dynamic_cast<PythonMain *>(build.get())) { |
|
|
|
command += filesystem::get_short_path(build->project_path).string(); |
|
|
|
command += filesystem::get_short_path(build->project_path).string(); |
|
|
|
path = build->project_path; |
|
|
|
path = build->project_path; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if(!file_path.empty()) { |
|
|
|
|
|
|
|
command += filesystem::escape_argument(filesystem::get_short_path(file_path).string()); |
|
|
|
|
|
|
|
path = file_path.parent_path(); |
|
|
|
|
|
|
|
} |
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
command += filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
command += filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
@ -879,13 +902,17 @@ void Project::Python::compile_and_run() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::JavaScript::compile_and_run() { |
|
|
|
void Project::JavaScript::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
std::string command; |
|
|
|
std::string command; |
|
|
|
boost::filesystem::path path; |
|
|
|
boost::filesystem::path path; |
|
|
|
if(dynamic_cast<NpmBuild *>(build.get())) { |
|
|
|
if(dynamic_cast<NpmBuild *>(build.get())) { |
|
|
|
command = "npm start"; |
|
|
|
command = "npm start"; |
|
|
|
path = build->project_path; |
|
|
|
path = build->project_path; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if(!file_path.empty()) { |
|
|
|
|
|
|
|
command = "node " + filesystem::escape_argument(filesystem::get_short_path(file_path).string()); |
|
|
|
|
|
|
|
path = file_path.parent_path(); |
|
|
|
|
|
|
|
} |
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
command = "node " + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
command = "node " + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
@ -902,7 +929,7 @@ void Project::JavaScript::compile_and_run() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::HTML::compile_and_run() { |
|
|
|
void Project::HTML::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
if(dynamic_cast<NpmBuild *>(build.get())) { |
|
|
|
if(dynamic_cast<NpmBuild *>(build.get())) { |
|
|
|
std::string command = "npm start"; |
|
|
|
std::string command = "npm start"; |
|
|
|
|
|
|
|
|
|
|
|
@ -914,6 +941,8 @@ void Project::HTML::compile_and_run() { |
|
|
|
Terminal::get().print("\e[2m" + command + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); |
|
|
|
Terminal::get().print("\e[2m" + command + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if(!file_path.empty()) |
|
|
|
|
|
|
|
Notebook::get().open_uri(std::string("file://") + file_path.string()); |
|
|
|
else if(auto view = Notebook::get().get_current_view()) |
|
|
|
else if(auto view = Notebook::get().get_current_view()) |
|
|
|
Notebook::get().open_uri(std::string("file://") + view->file_path.string()); |
|
|
|
Notebook::get().open_uri(std::string("file://") + view->file_path.string()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -944,7 +973,7 @@ void Project::Rust::compile() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::Rust::compile_and_run() { |
|
|
|
void Project::Rust::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
compiling = true; |
|
|
|
compiling = true; |
|
|
|
|
|
|
|
|
|
|
|
if(Config::get().terminal.clear_on_compile) |
|
|
|
if(Config::get().terminal.clear_on_compile) |
|
|
|
@ -964,13 +993,17 @@ void Project::Rust::compile_and_run() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::Go::compile_and_run() { |
|
|
|
void Project::Go::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
std::string command; |
|
|
|
std::string command; |
|
|
|
boost::filesystem::path path; |
|
|
|
boost::filesystem::path path; |
|
|
|
if(dynamic_cast<GoBuild *>(build.get())) { |
|
|
|
if(dynamic_cast<GoBuild *>(build.get())) { |
|
|
|
command = "go run ."; |
|
|
|
command = "go run ."; |
|
|
|
path = build->project_path; |
|
|
|
path = build->project_path; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if(!file_path.empty()) { |
|
|
|
|
|
|
|
command = "go run " + filesystem::escape_argument(filesystem::get_short_path(file_path).string()); |
|
|
|
|
|
|
|
path = file_path.parent_path(); |
|
|
|
|
|
|
|
} |
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
else if(auto view = Notebook::get().get_current_view()) { |
|
|
|
command = "go run " + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
command = "go run " + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
@ -987,10 +1020,19 @@ void Project::Go::compile_and_run() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Project::Julia::compile_and_run() { |
|
|
|
void Project::Julia::compile_and_run(const boost::filesystem::path &file_path) { |
|
|
|
|
|
|
|
std::string command; |
|
|
|
|
|
|
|
boost::filesystem::path path; |
|
|
|
|
|
|
|
if(!file_path.empty()) { |
|
|
|
|
|
|
|
command = "julia " + filesystem::escape_argument(filesystem::get_short_path(file_path).string()); |
|
|
|
|
|
|
|
path = file_path.parent_path(); |
|
|
|
|
|
|
|
} |
|
|
|
if(auto view = Notebook::get().get_current_view()) { |
|
|
|
if(auto view = Notebook::get().get_current_view()) { |
|
|
|
auto command = "julia " + filesystem::escape_argument(filesystem::get_short_path(Notebook::get().get_current_view()->file_path).string()); |
|
|
|
command = "julia " + filesystem::escape_argument(filesystem::get_short_path(view->file_path).string()); |
|
|
|
auto path = view->file_path.parent_path(); |
|
|
|
path = view->file_path.parent_path(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if(Config::get().terminal.clear_on_compile) |
|
|
|
if(Config::get().terminal.clear_on_compile) |
|
|
|
Terminal::get().clear(); |
|
|
|
Terminal::get().clear(); |
|
|
|
@ -1000,4 +1042,3 @@ void Project::Julia::compile_and_run() { |
|
|
|
Terminal::get().print("\e[2m" + command + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); |
|
|
|
Terminal::get().print("\e[2m" + command + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|