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
89 // char *author = (char*) (authorWX.mb_str()) ;
90 char *author = authorWX.mb_str() ;
92 std::string nomDirectory = crea::wx2std(dir) + "\\" + crea::wx2std(name);
93 std::string nomPackageDirectory = nomDirectory + "\\" + "bbtk_" + crea::wx2std(name) + "_PKG";
94 std::string bbCreatePackage("bbCreatePackage ");
95 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
96 system (bbCreatePackage.c_str());
98 add = "echo ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG) >> " + nomDirectory + "/CMakeLists.txt";
101 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
102 wxOK | wxICON_INFORMATION);
104 wxString err(_T("An error occured while running '"));
105 err += crea::std2wx(command) + _T("'");
106 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);
109 // ------ LINUX / MacOS
112 std::string command("creaNewProject.sh ");
113 command += "\"" + crea::wx2std(dir) + "\"" +" " + crea::wx2std(name);
115 if ( ! system ( command.c_str() ) )
117 wxMessageBox(_T("New Project created !"),_T("creaNewProject"),
118 wxOK | wxICON_INFORMATION);
120 // Create a Package at the same time. JPR
122 //execGUICreateNewPackage += "/../../../share/bbtk/bbs/toolsbbtk/appli/GUICreatePackage.bbs";
123 //system(execGUICreateNewPackage.c_str());
125 // or, better, new trick :
126 // bbCreatePackage nomDirectory nomPackage author Description
128 //EED char *author = getenv("USER");
129 // JPR char *author = (char*) (authorWX.mb_str());
130 std::string author(authorWX.mb_str());
131 std::string nomDirectory = crea::wx2std(dir) + "/" + crea::wx2std(name);
132 std::string nomPackageDirectory = nomDirectory + "/" + "bbtk_" + crea::wx2std(name) + "_PKG";
134 std::string bbCreatePackage("bbCreatePackage ");
135 bbCreatePackage += nomDirectory + " " + crea::wx2std(name) + " " + author + " " + crea::wx2std(description);
136 system (bbCreatePackage.c_str());
139 add = "echo 'ADD_SUBDIRECTORY(bbtk_" + crea::wx2std(name) + "_PKG)' >> " + nomDirectory + "/CMakeLists.txt";
140 //std::cout << add << std::endl;
146 wxString err(_T("An error occured while running '"));
147 err += crea::std2wx(command) + _T("'");
148 wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);