2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 #include <wx/dirdlg.h>
30 #include <stdlib.h> // for getenv
32 class myApp : public wxApp
36 int OnExit() { return true; }
40 CREA_WXMAIN_WITH_CONSOLE
46 //See http://www.wxwindows.org/faqgtk.htm#locale
47 setlocale(LC_NUMERIC, "C");
49 wxInitAllImageHandlers();
51 wxString dir = wxDirSelector(_T("Select directory in which to create the project"), _T(""), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
53 if (dir.IsEmpty()) return false;
55 wxString name = wxGetTextFromUser(_T("Enter project name"),
58 if (name.IsEmpty()) return false;
60 wxString description = wxGetTextFromUser(_T("Enter Package Description (html format)"),
61 _T("create New Package"),
62 _T("NO_DESCRIPTION"));
63 if (description.IsEmpty()) return false;
65 wxString authorWX = wxGetTextFromUser(_T("Author (One word)"),
68 if (description.IsEmpty()) return false;
74 std::string command("creaNewProject.bat ");
75 std::string command1("creaSed.exe ");
76 std::string command2("del ");
78 command += "\"" + crea::wx2std(dir) + "\" \"" + crea::wx2std(name) + "\"";
79 command1 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\" " + "NameOfTheProject " + crea::wx2std(name) + "> \"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt\"";
80 command2 += "\"" + crea::wx2std(dir)+"\\"+crea::wx2std(name)+"\\CMakeLists.txt.in\"";
81 if ( ! system ( command.c_str() ) )
83 system ( command1.c_str() );
84 system ( command2.c_str() );
86 // Create a Package at the same time. JPR
87 char *author = (char*) (authorWX.mb_str()) ;
88 std::string nomDirectory = crea::wx2std(dir) + "\\" + crea::wx2std(name);
89 std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + crea::wx2std(name) + "_PKG";
90 std::string bbCreatePackage("bbCreatePackage ");
91 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
92 system (bbCreatePackage.c_str());
94 add = "echo ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
97 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
98 wxOK | wxICON_INFORMATION);
100 wxString err(_T("An error occured while running '"));
101 err += crea::std2wx(command) + _T("'");
102 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
105 // ------ LINUX / MacOS
108 std::string command("creaNewProject.sh ");
109 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
111 if ( ! system ( command.c_str() ) )
113 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
114 wxOK | wxICON_INFORMATION);
116 // Create a Package at the same time. JPR
118 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
119 //system(execGUICreateNewPackage.c_str());
121 // or, better, new trick :
122 // bbCreatePackage nomDirectory nomPackage author Description
124 //EED char *author = getenv("USER");
125 // JPR char *author = (char*) (authorWX.mb_str());
126 std::string author(authorWX.mb_str());
127 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
128 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
130 std::string bbCreatePackage("bbCreatePackage ");
131 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
132 system (bbCreatePackage.c_str());
135 add = "echo 'ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
136 //std::cout << add << std::endl;
142 wxString err(_T("An error occured while running '"));
143 err += crea::std2wx(command) + _T("'");
144 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);