@ -267,21 +267,25 @@ void Window::set_menu_actions() {
if ( chr = = ' ' )
chr = ' _ ' ;
}
boost : : filesystem : : path buildsys _path ;
std : : string buildsys ;
// Depending on default_build_system, generate build configuration
if ( Config : : get ( ) . project . default_build_system = = " cmake " ) {
buildsys _path = project_path / " CMakeLists.txt " ;
buildsys = " cmake_minimum_required(VERSION 2.8) \n \n project( " + project_name + " ) \n \n set(CMAKE_C_FLAGS \" ${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra \" ) \n \n add_executable( " + project_name + " main.c) \n " ;
boost : : filesystem : : path build_config _path ;
std : : string build_config ;
// Depending on default_build_management_ system, generate build configuration
if ( Config : : get ( ) . project . default_build_management_ system = = " cmake " ) {
build_config _path = project_path / " CMakeLists.txt " ;
build_config = " cmake_minimum_required(VERSION 2.8) \n \n project( " + project_name + " ) \n \n set(CMAKE_C_FLAGS \" ${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra \" ) \n \n add_executable( " + project_name + " main.c) \n " ;
}
else if ( Config : : get ( ) . project . default_build_system = = " meson " ) {
buildsys_path = project_path / " meson.build " ;
buildsys = " project(' " + project_name + " ', 'c') \n executable(' " + project_name + " ', 'main.c') \n " ;
else if ( Config : : get ( ) . project . default_build_management_system = = " meson " ) {
build_config_path = project_path / " meson.build " ;
build_config = " project(' " + project_name + " ', 'c') \n \n add_project_arguments('-std=c11', '-Wall', '-Wextra', language: 'c') \n \n executable(' " + 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 clang_format_path = project_path / " .clang-format " ;
if ( boost : : filesystem : : exists ( buildsys_path ) ) {
Terminal : : get ( ) . print ( " Error: " + buildsys _path . string ( ) + " already exists. \n " , true ) ;
if ( boost : : filesystem : : exists ( build_config _path ) ) {
Terminal : : get ( ) . print ( " Error: " + build_config _path . string ( ) + " already exists. \n " , true ) ;
return ;
}
if ( boost : : filesystem : : exists ( c_main_path ) ) {
@ -294,7 +298,7 @@ void Window::set_menu_actions() {
}
std : : string c_main = " #include <stdio.h> \n \n int main() { \n printf( \" Hello World! \\ n \" ); \n } \n " ;
std : : string clang_format = " IndentWidth: 2 \n AccessModifierOffset: -2 \n UseTab: Never \n ColumnLimit: 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 ) ;
Notebook : : get ( ) . open ( c_main_path ) ;
Directories : : get ( ) . update ( ) ;
@ -312,21 +316,25 @@ void Window::set_menu_actions() {
if ( chr = = ' ' )
chr = ' _ ' ;
}
boost : : filesystem : : path buildsys _path ;
std : : string buildsys ;
// Depending on default_build_system, generate build configuration
if ( Config : : get ( ) . project . default_build_system = = " cmake " ) {
buildsys _path = project_path / " CMakeLists.txt " ;
buildsys = " cmake_minimum_required(VERSION 2.8) \n \n project( " + project_name + " ) \n \n set(CMAKE_CXX_FLAGS \" ${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra \" ) \n \n add_executable( " + project_name + " main.cpp) \n " ;
boost : : filesystem : : path build_config _path ;
std : : string build_config ;
// Depending on default_build_management_ system, generate build configuration
if ( Config : : get ( ) . project . default_build_management_ system = = " cmake " ) {
build_config _path = project_path / " CMakeLists.txt " ;
build_config = " cmake_minimum_required(VERSION 2.8) \n \n project( " + project_name + " ) \n \n set(CMAKE_CXX_FLAGS \" ${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra \" ) \n \n add_executable( " + project_name + " main.cpp) \n " ;
}
else if ( Config : : get ( ) . project . default_build_system = = " meson " ) {
buildsys_path = project_path / " meson.build " ;
buildsys = " project(' " + project_name + " ', 'cpp') \n executable(' " + project_name + " ', 'main.cpp') \n " ;
else if ( Config : : get ( ) . project . default_build_management_system = = " meson " ) {
build_config_path = project_path / " meson.build " ;
build_config = " project(' " + project_name + " ', 'cpp') \n \n add_project_arguments('-std=c++1y', '-Wall', '-Wextra', language: 'cpp') \n \n executable(' " + 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 clang_format_path = project_path / " .clang-format " ;
if ( boost : : filesystem : : exists ( buildsys_path ) ) {
Terminal : : get ( ) . print ( " Error: " + buildsys _path . string ( ) + " already exists. \n " , true ) ;
if ( boost : : filesystem : : exists ( build_config _path ) ) {
Terminal : : get ( ) . print ( " Error: " + build_config _path . string ( ) + " already exists. \n " , true ) ;
return ;
}
if ( boost : : filesystem : : exists ( cpp_main_path ) ) {
@ -339,7 +347,7 @@ void Window::set_menu_actions() {
}
std : : string cpp_main = " #include <iostream> \n \n int main() { \n std::cout << \" Hello World! \\ n \" ; \n } \n " ;
std : : string clang_format = " IndentWidth: 2 \n AccessModifierOffset: -2 \n UseTab: Never \n ColumnLimit: 0 \n NamespaceIndentation: 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 ) ;
Notebook : : get ( ) . open ( cpp_main_path ) ;
Directories : : get ( ) . update ( ) ;