From: Daniel Gonzalez Date: Wed, 19 Jun 2013 09:45:48 +0000 (+0200) Subject: Feature #2042 bbpConfigurator X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;ds=inline;h=cd39bfaca5c64598de7046df6989f244fc6e32cd;p=bbtk.git Feature #2042 bbpConfigurator This application should replace the macro BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT in order to organize the includes so the dependecies are taken into account. It takes the path of the bbs's, the package name, and the output bbp path. For now, it just organizes the files in the bbs's folder in alphabetical order and creates the bbp in that order. --- diff --git a/kernel/appli/CMakeLists.txt b/kernel/appli/CMakeLists.txt index b8718fe..009a011 100644 --- a/kernel/appli/CMakeLists.txt +++ b/kernel/appli/CMakeLists.txt @@ -68,4 +68,7 @@ ADD_SUBDIRECTORY(bbPostInstallPackage) ADD_SUBDIRECTORY(bbPlugPackage) +#Automatic bbp generator +ADD_SUBDIRECTORY(bbpConfigurator) + diff --git a/kernel/appli/bbpConfigurator/CMakeLists.txt b/kernel/appli/bbpConfigurator/CMakeLists.txt new file mode 100644 index 0000000..0cb04b6 --- /dev/null +++ b/kernel/appli/bbpConfigurator/CMakeLists.txt @@ -0,0 +1,42 @@ + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + + + +SET( + SOURCES + bbpConfigurator +) + +ADD_EXECUTABLE( + bbpConfigurator + ${SOURCES} +) + +TARGET_LINK_LIBRARIES( + bbpConfigurator bbtk +) +INSTALL_TARGETS(/bin/ bbpConfigurator) diff --git a/kernel/appli/bbpConfigurator/bbpConfigurator.cpp b/kernel/appli/bbpConfigurator/bbpConfigurator.cpp new file mode 100644 index 0000000..7a1df79 --- /dev/null +++ b/kernel/appli/bbpConfigurator/bbpConfigurator.cpp @@ -0,0 +1,120 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + +#include +#include +#include +#include +#include "boost/filesystem.hpp" +//#include "boost/filesystem/operations.hpp" +//#include "boost/filesystem/path.hpp" + +namespace bf = boost::filesystem; + +//using namespace bbtk; + +int main(int argc, char **argv) +{ + if (argc != 4) + { + std::cout << "usage : bbConfigurator " << std::endl; + return 1; + } + + std::string path_bbs(argv[1]); + std::string package_name(argv[2]); + std::string path_out(argv[3]); + + std::vector files; + + bf::path pth(path_bbs.c_str()); + if(bf::exists(pth) && bf::is_directory(pth)) + { + bf::directory_iterator end_itr; + for(bf::directory_iterator itr(pth); itr != end_itr; ++itr) + { + if(!is_directory(itr->status())) + { + std::string nm(itr->path().filename().string()); + if(nm.substr(nm.size()-4) == ".bbs") + { + std::cout << itr->path().filename().string() << std::endl; + files.push_back(itr->path()); + } + } + } + } + else + { + std::cout<< "the path to the bbs's should be a folder and not a file."; + return 1; + } + + for (int i = 0; i < (int)files.size()-1; ++i) { + for (int j = i+1; j < (int)files.size(); ++j) { + if(files[j].filename().string() < files[i].filename().string()) + { + bf::path tmp = files[i]; + files[i] = files[j]; + files[j] = tmp; + } + } + } + +#ifdef WIN32 + std::string fname = path_out + "\\" + package_name + ".bbp"; +#else + std::string fname = path_out + "/" + package_name + ".bbp"; +#endif + + std::ofstream out(fname.c_str()); + out << "#-----------------------------------------" << std::endl; + out << "# Include script for bbtk package '" << package_name << "'" << std::endl; + out << "# Automatically generated by bbpConfigurator" << std::endl; + out << "#-----------------------------------------" << std::endl; + out << "load "<< package_name << std::endl; + out << "#-----------------------------------------" << std::endl; + out << "package "<< package_name << std::endl; + out << "#-----------------------------------------" << std::endl; + + //each bbs file ordered. + //include [package_name]/boxes/[file_bbs] + //#----------------------------------------- + for (int i = 0; i < (int)files.size(); ++i) { + out << "include " << package_name << "/boxes/" << files[i].filename().string() << std::endl; + out << "#-----------------------------------------" << std::endl; + } + + out << "endpackage" << std::endl; + out << "#-- EOF ----------------------------------" << std::endl; + + out.close(); + + return 0; +} +//========================================================================== + +