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 char * install_Dir = getenv("bbtk_DIR");
39 std::string execGUICreateNewPackage(install_Dir);
40 execGUICreateNewPackage = "bbi " + execGUICreateNewPackage;
43 std::string command("creaNewProject.bat ");
44 std::string command1("creaSed.exe ");
45 std::string command2("del ");
47 command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\"";
48 command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\"";
49 command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\"";
50 if ( ! system ( command.c_str() ) )
52 system ( command1.c_str() );
53 system ( command2.c_str() );
54 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
55 wxOK | wxICON_INFORMATION);
56 // Create a Package at the same time. JPR
58 /// \TODO rewrite, according to new trick
59 execGUICreateNewPackage += "\..\..\..\share\bbtk\bbs\toolsbbtk\appli\GUICreatePackage.bbs";
60 system(execGUICreateNewPackage.c_str());
64 wxString err(_T("An error occured while running '"));
65 err += crea::std2wx(command) + _T("'");
66 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
69 // ------ LINUX / MacOS
72 std::string command("creaNewProject.sh ");
73 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
75 if ( ! system ( command.c_str() ) )
77 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
78 wxOK | wxICON_INFORMATION);
80 // Create a Package at the same time. JPR
82 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
83 //system(execGUICreateNewPackage.c_str());
85 // or, better, new trick :
86 // bbCreatePackage nomDirectory nomPackage author Description
88 char *author = getenv("USER");
89 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
90 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
92 std::string bbCreatePackage("bbCreatePackage ");
93 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
94 system (bbCreatePackage.c_str());
98 wxString err(_T("An error occured while running '"));
99 err += crea::std2wx(command) + _T("'");
100 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);