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
88 //EED 2018/01/22 char *author = (char*) (authorWX.mb_str()) ;
89 std::string author(authorWX.mb_str());
91 std::string nomDirectory = crea::wx2std(dir) + "\\" + crea::wx2std(name);
92 std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + crea::wx2std(name) + "_PKG";
93 std::string bbCreatePackage("bbCreatePackage ");
94 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
95 system (bbCreatePackage.c_str());
97 add = "echo ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
100 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
101 wxOK | wxICON_INFORMATION);
103 wxString err(_T("An error occured while running '"));
104 err += crea::std2wx(command) + _T("'");
105 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
108 // ------ LINUX / MacOS
111 std::string command("creaNewProject.sh ");
112 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
114 if ( ! system ( command.c_str() ) )
116 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
117 wxOK | wxICON_INFORMATION);
119 // Create a Package at the same time. JPR
121 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
122 //system(execGUICreateNewPackage.c_str());
124 // or, better, new trick :
125 // bbCreatePackage nomDirectory nomPackage author Description
127 //EED char *author = getenv("USER");
128 // JPR char *author = (char*) (authorWX.mb_str());
129 std::string author(authorWX.mb_str());
130 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
131 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
133 std::string bbCreatePackage("bbCreatePackage ");
134 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
135 system (bbCreatePackage.c_str());
138 add = "echo 'ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
139 //std::cout << add << std::endl;
145 wxString err(_T("An error occured while running '"));
146 err += crea::std2wx(command) + _T("'");
147 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);