3 #include <stdlib.h> // for getenv
5 class myApp : public wxApp
9 int OnExit() { return true; }
13 CREA_WXMAIN_WITH_CONSOLE
19 //See http://www.wxwindows.org/faqgtk.htm#locale
20 setlocale(LC_NUMERIC, "C");
22 wxInitAllImageHandlers();
24 wxString dir = wxDirSelector(_T("Select directory in which to create the project"), _T(""), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
26 if (dir.IsEmpty()) return false;
28 wxString name = wxGetTextFromUser(_T("Enter project name"),
31 if (name.IsEmpty()) return false;
33 wxString description = wxGetTextFromUser(_T("Enter Package Description (html format)"),
34 _T("create New Package"),
35 _T("NO_DESCRIPTION"));
36 if (description.IsEmpty()) return false;
40 std::string command("creaNewProject.bat ");
41 std::string command1("creaSed.exe ");
42 std::string command2("del ");
44 command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\"";
45 command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\"";
46 command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\"";
47 if ( ! system ( command.c_str() ) )
49 system ( command1.c_str() );
50 system ( command2.c_str() );
51 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
52 wxOK | wxICON_INFORMATION);
54 // Create a Package at the same time. JPR
56 /// \TODO rewrite, according to new trick // JPR
57 // \TODO rewrite, according to new trick // JPR
58 char * install_Dir = getenv("bbtk_DIR");
59 if(install_Dir != NULL) // variable not always defined
61 std::string execGUICreateNewPackage(install_Dir);
62 execGUICreateNewPackage = "bbi " + execGUICreateNewPackage;
63 execGUICreateNewPackage += "\..\..\..\share\bbtk\bbs\toolsbbtk\appli\GUICreatePackage.bbs";
64 system(execGUICreateNewPackage.c_str());
69 wxString err(_T("An error occured while running '"));
70 err += crea::std2wx(command) + _T("'");
71 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
74 // ------ LINUX / MacOS
77 std::string command("creaNewProject.sh ");
78 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
80 if ( ! system ( command.c_str() ) )
82 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
83 wxOK | wxICON_INFORMATION);
85 // Create a Package at the same time. JPR
87 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
88 //system(execGUICreateNewPackage.c_str());
90 // or, better, new trick :
91 // bbCreatePackage nomDirectory nomPackage author Description
93 char *author = getenv("USER");
94 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
95 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
97 std::string bbCreatePackage("bbCreatePackage ");
98 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
99 system (bbCreatePackage.c_str());
102 add = "echo 'ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
103 //std::cout << add << std::endl;
109 wxString err(_T("An error occured while running '"));
110 err += crea::std2wx(command) + _T("'");
111 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);