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;
38 wxString authorWX = wxGetTextFromUser(_T("Author (One word)"),
41 if (description.IsEmpty()) return false;
47 std::string command("creaNewProject.bat ");
48 std::string command1("creaSed.exe ");
49 std::string command2("del ");
51 command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\"";
52 command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\"";
53 command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\"";
54 if ( ! system ( command.c_str() ) )
56 system ( command1.c_str() );
57 system ( command2.c_str() );
59 // Create a Package at the same time. JPR
60 char *author = (char*) (authorWX.mb_str()) ;
61 std::string nomDirectory = crea::wx2std(dir) + "\\" + crea::wx2std(name);
62 std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + crea::wx2std(name) + "_PKG";
63 std::string bbCreatePackage("bbCreatePackage ");
64 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
65 system (bbCreatePackage.c_str());
67 add = "echo ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
70 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
71 wxOK | wxICON_INFORMATION);
73 wxString err(_T("An error occured while running '"));
74 err += crea::std2wx(command) + _T("'");
75 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
78 // ------ LINUX / MacOS
81 std::string command("creaNewProject.sh ");
82 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
84 if ( ! system ( command.c_str() ) )
86 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
87 wxOK | wxICON_INFORMATION);
89 // Create a Package at the same time. JPR
91 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
92 //system(execGUICreateNewPackage.c_str());
94 // or, better, new trick :
95 // bbCreatePackage nomDirectory nomPackage author Description
97 //EED char *author = getenv("USER");
98 // JPR char *author = (char*) (authorWX.mb_str());
99 std::string author(authorWX.mb_str());
100 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
101 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
103 std::string bbCreatePackage("bbCreatePackage ");
104 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
105 system (bbCreatePackage.c_str());
108 add = "echo 'ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
109 //std::cout << add << std::endl;
115 wxString err(_T("An error occured while running '"));
116 err += crea::std2wx(command) + _T("'");
117 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);