2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------ */
26 #include <wx/dirdlg.h>
27 #include <stdlib.h> // for getenv
29 class myApp : public wxApp
33 int OnExit() { return true; }
37 CREA_WXMAIN_WITH_CONSOLE
43 //See http://www.wxwindows.org/faqgtk.htm#locale
44 setlocale(LC_NUMERIC, "C");
46 wxInitAllImageHandlers();
48 wxString dir = wxDirSelector(_T("Select directory in which to create the project"), _T(""), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
50 if (dir.IsEmpty()) return false;
52 wxString name = wxGetTextFromUser(_T("Enter project name"),
55 if (name.IsEmpty()) return false;
57 wxString description = wxGetTextFromUser(_T("Enter Package Description (html format)"),
58 _T("create New Package"),
59 _T("NO_DESCRIPTION"));
60 if (description.IsEmpty()) return false;
62 wxString authorWX = wxGetTextFromUser(_T("Author (One word)"),
65 if (description.IsEmpty()) return false;
71 std::string command("creaNewProject.bat ");
72 std::string command1("creaSed.exe ");
73 std::string command2("del ");
75 command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\"";
76 command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\"";
77 command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\"";
78 if ( ! system ( command.c_str() ) )
80 system ( command1.c_str() );
81 system ( command2.c_str() );
83 // Create a Package at the same time. JPR
84 char *author = (char*) (authorWX.mb_str()) ;
85 std::string nomDirectory = crea::wx2std(dir) + "\\" + crea::wx2std(name);
86 std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + crea::wx2std(name) + "_PKG";
87 std::string bbCreatePackage("bbCreatePackage ");
88 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
89 system (bbCreatePackage.c_str());
91 add = "echo ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
94 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
95 wxOK | wxICON_INFORMATION);
97 wxString err(_T("An error occured while running '"));
98 err += crea::std2wx(command) + _T("'");
99 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
102 // ------ LINUX / MacOS
105 std::string command("creaNewProject.sh ");
106 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
108 if ( ! system ( command.c_str() ) )
110 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
111 wxOK | wxICON_INFORMATION);
113 // Create a Package at the same time. JPR
115 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
116 //system(execGUICreateNewPackage.c_str());
118 // or, better, new trick :
119 // bbCreatePackage nomDirectory nomPackage author Description
121 //EED char *author = getenv("USER");
122 // JPR char *author = (char*) (authorWX.mb_str());
123 std::string author(authorWX.mb_str());
124 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
125 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
127 std::string bbCreatePackage("bbCreatePackage ");
128 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
129 system (bbCreatePackage.c_str());
132 add = "echo 'ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
133 //std::cout << add << std::endl;
139 wxString err(_T("An error occured while running '"));
140 err += crea::std2wx(command) + _T("'");
141 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);