Browse Source

Related to MR 398: finished implementation of default build system setting, but renamed project.default_build_system to project.default_build_management_system, since make and ninja are examples of build systems. Also added --buildtype plain to meson default build.

merge-requests/399/head
eidheim 7 years ago
parent
commit
e0e47a37ed
  1. 2
      CMakeLists.txt
  2. 2
      src/config.cc
  3. 2
      src/config.h
  4. 2
      src/files.h
  5. 2
      src/meson.cc
  6. 56
      src/window.cc

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8) cmake_minimum_required (VERSION 2.8.8)
project(juci) project(juci)
set(JUCI_VERSION "1.4.6.4") set(JUCI_VERSION "1.4.6.5")
set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

2
src/config.cc

@ -190,13 +190,13 @@ void Config::read(const boost::property_tree::ptree &cfg) {
theme.variant = cfg.get<std::string>("gtk_theme.variant"); theme.variant = cfg.get<std::string>("gtk_theme.variant");
theme.font = cfg.get<std::string>("gtk_theme.font"); theme.font = cfg.get<std::string>("gtk_theme.font");
project.default_build_system = cfg.get<std::string>("project.default_build_system");
project.default_build_path = cfg.get<std::string>("project.default_build_path"); project.default_build_path = cfg.get<std::string>("project.default_build_path");
project.debug_build_path = cfg.get<std::string>("project.debug_build_path"); project.debug_build_path = cfg.get<std::string>("project.debug_build_path");
project.cmake.command = cfg.get<std::string>("project.cmake.command"); project.cmake.command = cfg.get<std::string>("project.cmake.command");
project.cmake.compile_command = cfg.get<std::string>("project.cmake.compile_command"); project.cmake.compile_command = cfg.get<std::string>("project.cmake.compile_command");
project.meson.command = cfg.get<std::string>("project.meson.command"); project.meson.command = cfg.get<std::string>("project.meson.command");
project.meson.compile_command = cfg.get<std::string>("project.meson.compile_command"); project.meson.compile_command = cfg.get<std::string>("project.meson.compile_command");
project.default_build_management_system = cfg.get<std::string>("project.default_build_management_system");
project.save_on_compile_or_run = cfg.get<bool>("project.save_on_compile_or_run"); project.save_on_compile_or_run = cfg.get<bool>("project.save_on_compile_or_run");
project.clear_terminal_on_compile = cfg.get<bool>("project.clear_terminal_on_compile"); project.clear_terminal_on_compile = cfg.get<bool>("project.clear_terminal_on_compile");
project.ctags_command = cfg.get<std::string>("project.ctags_command"); project.ctags_command = cfg.get<std::string>("project.ctags_command");

2
src/config.h

@ -40,11 +40,11 @@ public:
std::string compile_command; std::string compile_command;
}; };
std::string default_build_system;
std::string default_build_path; std::string default_build_path;
std::string debug_build_path; std::string debug_build_path;
CMake cmake; CMake cmake;
Meson meson; Meson meson;
std::string default_build_management_system;
bool save_on_compile_or_run; bool save_on_compile_or_run;
bool clear_terminal_on_compile; bool clear_terminal_on_compile;
std::string ctags_command; std::string ctags_command;

2
src/files.h

@ -179,6 +179,8 @@ const std::string default_config_file = R"RAW({
"command": "meson", "command": "meson",
"compile_command": "ninja" "compile_command": "ninja"
}, },
"default_build_management_system_comment": "Select which build management system to use when creating a new C or C++ project, for instance \"cmake\" or \"meson\"",
"default_build_management_system": "cmake",
"save_on_compile_or_run": true, "save_on_compile_or_run": true,
"clear_terminal_on_compile": true, "clear_terminal_on_compile": true,
"ctags_command": "ctags", "ctags_command": "ctags",

2
src/meson.cc

@ -53,7 +53,7 @@ bool Meson::update_default_build(const boost::filesystem::path &default_build_pa
Dialog::Message message("Creating/updating default build"); Dialog::Message message("Creating/updating default build");
auto exit_status = Terminal::get().process(Config::get().project.meson.command + ' ' + auto exit_status = Terminal::get().process(Config::get().project.meson.command + ' ' +
(compile_commands_exists ? "--internal regenerate " : "") + (compile_commands_exists ? "--internal regenerate " : "") +
filesystem::escape_argument(project_path.string()), default_build_path); "--buildtype plain " + filesystem::escape_argument(project_path.string()), default_build_path);
message.hide(); message.hide();
if(exit_status == EXIT_SUCCESS) if(exit_status == EXIT_SUCCESS)
return true; return true;

56
src/window.cc

@ -267,21 +267,25 @@ void Window::set_menu_actions() {
if(chr == ' ') if(chr == ' ')
chr = '_'; chr = '_';
} }
boost::filesystem::path buildsys_path; boost::filesystem::path build_config_path;
std::string buildsys; std::string build_config;
// Depending on default_build_system, generate build configuration // Depending on default_build_management_system, generate build configuration
if(Config::get().project.default_build_system == "cmake") { if(Config::get().project.default_build_management_system == "cmake") {
buildsys_path = project_path / "CMakeLists.txt"; build_config_path = project_path / "CMakeLists.txt";
buildsys = "cmake_minimum_required(VERSION 2.8)\n\nproject(" + project_name + ")\n\nset(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra\")\n\nadd_executable(" + project_name + " main.c)\n"; build_config = "cmake_minimum_required(VERSION 2.8)\n\nproject(" + project_name + ")\n\nset(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra\")\n\nadd_executable(" + project_name + " main.c)\n";
} }
else if(Config::get().project.default_build_system == "meson") { else if(Config::get().project.default_build_management_system == "meson") {
buildsys_path = project_path / "meson.build"; build_config_path = project_path / "meson.build";
buildsys = "project('" + project_name + "', 'c')\nexecutable('" + project_name + "', 'main.c')\n"; build_config = "project('" + project_name + "', 'c')\n\nadd_project_arguments('-std=c11', '-Wall', '-Wextra', language: 'c')\n\nexecutable('" + project_name + "', 'main.c')\n";
}
else {
Terminal::get().print("Error: build management system " + Config::get().project.default_build_management_system + " not supported.\n", true);
return;
} }
auto c_main_path = project_path / "main.c"; auto c_main_path = project_path / "main.c";
auto clang_format_path = project_path / ".clang-format"; auto clang_format_path = project_path / ".clang-format";
if(boost::filesystem::exists(buildsys_path)) { if(boost::filesystem::exists(build_config_path)) {
Terminal::get().print("Error: " + buildsys_path.string() + " already exists.\n", true); Terminal::get().print("Error: " + build_config_path.string() + " already exists.\n", true);
return; return;
} }
if(boost::filesystem::exists(c_main_path)) { if(boost::filesystem::exists(c_main_path)) {
@ -294,7 +298,7 @@ void Window::set_menu_actions() {
} }
std::string c_main = "#include <stdio.h>\n\nint main() {\n printf(\"Hello World!\\n\");\n}\n"; std::string c_main = "#include <stdio.h>\n\nint main() {\n printf(\"Hello World!\\n\");\n}\n";
std::string clang_format = "IndentWidth: 2\nAccessModifierOffset: -2\nUseTab: Never\nColumnLimit: 0\n"; std::string clang_format = "IndentWidth: 2\nAccessModifierOffset: -2\nUseTab: Never\nColumnLimit: 0\n";
if(filesystem::write(buildsys_path, buildsys) && filesystem::write(c_main_path, c_main) && filesystem::write(clang_format_path, clang_format)) { if(filesystem::write(build_config_path, build_config) && filesystem::write(c_main_path, c_main) && filesystem::write(clang_format_path, clang_format)) {
Directories::get().open(project_path); Directories::get().open(project_path);
Notebook::get().open(c_main_path); Notebook::get().open(c_main_path);
Directories::get().update(); Directories::get().update();
@ -312,21 +316,25 @@ void Window::set_menu_actions() {
if(chr == ' ') if(chr == ' ')
chr = '_'; chr = '_';
} }
boost::filesystem::path buildsys_path; boost::filesystem::path build_config_path;
std::string buildsys; std::string build_config;
// Depending on default_build_system, generate build configuration // Depending on default_build_management_system, generate build configuration
if(Config::get().project.default_build_system == "cmake") { if(Config::get().project.default_build_management_system == "cmake") {
buildsys_path = project_path / "CMakeLists.txt"; build_config_path = project_path / "CMakeLists.txt";
buildsys = "cmake_minimum_required(VERSION 2.8)\n\nproject(" + project_name + ")\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra\")\n\nadd_executable(" + project_name + " main.cpp)\n"; build_config = "cmake_minimum_required(VERSION 2.8)\n\nproject(" + project_name + ")\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra\")\n\nadd_executable(" + project_name + " main.cpp)\n";
} }
else if(Config::get().project.default_build_system == "meson") { else if(Config::get().project.default_build_management_system == "meson") {
buildsys_path = project_path / "meson.build"; build_config_path = project_path / "meson.build";
buildsys = "project('" + project_name + "', 'cpp')\nexecutable('" + project_name + "', 'main.cpp')\n"; build_config = "project('" + project_name + "', 'cpp')\n\nadd_project_arguments('-std=c++1y', '-Wall', '-Wextra', language: 'cpp')\n\nexecutable('" + project_name + "', 'main.cpp')\n";
}
else {
Terminal::get().print("Error: build management system " + Config::get().project.default_build_management_system + " not supported.\n", true);
return;
} }
auto cpp_main_path = project_path / "main.cpp"; auto cpp_main_path = project_path / "main.cpp";
auto clang_format_path = project_path / ".clang-format"; auto clang_format_path = project_path / ".clang-format";
if(boost::filesystem::exists(buildsys_path)) { if(boost::filesystem::exists(build_config_path)) {
Terminal::get().print("Error: " + buildsys_path.string() + " already exists.\n", true); Terminal::get().print("Error: " + build_config_path.string() + " already exists.\n", true);
return; return;
} }
if(boost::filesystem::exists(cpp_main_path)) { if(boost::filesystem::exists(cpp_main_path)) {
@ -339,7 +347,7 @@ void Window::set_menu_actions() {
} }
std::string cpp_main = "#include <iostream>\n\nint main() {\n std::cout << \"Hello World!\\n\";\n}\n"; std::string cpp_main = "#include <iostream>\n\nint main() {\n std::cout << \"Hello World!\\n\";\n}\n";
std::string clang_format = "IndentWidth: 2\nAccessModifierOffset: -2\nUseTab: Never\nColumnLimit: 0\nNamespaceIndentation: All\n"; std::string clang_format = "IndentWidth: 2\nAccessModifierOffset: -2\nUseTab: Never\nColumnLimit: 0\nNamespaceIndentation: All\n";
if(filesystem::write(buildsys_path, buildsys) && filesystem::write(cpp_main_path, cpp_main) && filesystem::write(clang_format_path, clang_format)) { if(filesystem::write(build_config_path, build_config) && filesystem::write(cpp_main_path, cpp_main) && filesystem::write(clang_format_path, clang_format)) {
Directories::get().open(project_path); Directories::get().open(project_path);
Notebook::get().open(cpp_main_path); Notebook::get().open(cpp_main_path);
Directories::get().update(); Directories::get().update();

Loading…
Cancel
Save