From 2af948693e29ac664ffc3328620061fbc52693f7 Mon Sep 17 00:00:00 2001 From: Camille GOUTTEBROZE Date: Fri, 26 Sep 2014 14:17:04 +0200 Subject: [PATCH] New file bin/app-template/resources/SalomeApp.xml.in --- bin/app-quickstart.py | 23 +++++++++++++++++---- bin/app-template/CMakeLists.txt | 7 ++++++- bin/app-template/resources/CMakeLists.txt | 21 +++++++++++++++++++ bin/app-template/resources/SalomeApp.xml.in | 22 ++++++++++++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 bin/app-template/resources/CMakeLists.txt create mode 100644 bin/app-template/resources/SalomeApp.xml.in diff --git a/bin/app-quickstart.py b/bin/app-quickstart.py index 582005be1..ab61a3097 100755 --- a/bin/app-quickstart.py +++ b/bin/app-quickstart.py @@ -24,7 +24,7 @@ import shutil import optparse # Options of this script -def ProfileQuickStartParser() : +def profileQuickStartParser() : parser = optparse.OptionParser( usage = "usage: python app-quickstart.py [options]" ) @@ -62,13 +62,23 @@ def ProfileQuickStartParser() : return parser +# +def profileReplaceStrings( src, dst, options ) : + with open( dst, "wt" ) as fout: + with open( src, "rt" ) as fin: + for line in fin: + fout.write( line.replace( '[LIST_OF_MODULES]', options.modules )/ + .replace( '[NAME_OF_APPLICATION]', options.name.upper() )/ + .replace( '', options.name )/ + .replace( '(name_of_application)', options.name.lower() ) ) #Generation of a template profile sources -def generate_sources( options, args ) : +def profileGenerateSources( options, args ) : #Set name of several directories app_dir = os.path.join( options.prefix, options.name ) src_dir = os.path.join( app_dir, "src" ) + resources_dir = os.path.join( app_dir, "resources" ) kernek_root_dir = os.environ["KERNEL_ROOT_DIR"] bin_dir = os.path.join( kernek_root_dir, "bin", "salome" ) template_dir = os.path.join( bin_dir, "app-template" ) @@ -89,10 +99,15 @@ def generate_sources( options, args ) : for f in contextFiles : shutil.copy( os.path.join( bin_dir, f ), src_dir ) + #Adapt source directory + profileReplaceStrings( os.path.join( template_dir, "resources", "SalomeApp.xml.in" ), os.path.join( resources_dir, "SalomeApp.xml.in" ), options ) + profileReplaceStrings( os.path.join( template_dir, "resources", "CMakeLists.txt" ), os.path.join( resources_dir, "CMakeLists.txt" ), options ) + profileReplaceStrings( os.path.join( template_dir, "CMakeLists.txt" ), os.path.join( app_dir, "CMakeLists.txt" ), options ) + # ----------------------------------------------------------------------------- if __name__ == '__main__': - (options, args) = ProfileQuickStartParser().parse_args() + (options, args) = profileQuickStartParser().parse_args() - generate_sources( options, args ) + profileGenerateSources( options, args ) diff --git a/bin/app-template/CMakeLists.txt b/bin/app-template/CMakeLists.txt index 494079eff..be8abd8d8 100644 --- a/bin/app-template/CMakeLists.txt +++ b/bin/app-template/CMakeLists.txt @@ -17,7 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR) - +PROJECT(Salome C CXX) # Find KERNEL # =========== @@ -38,9 +38,14 @@ ENDIF(EXISTS ${KERNEL_ROOT_DIR}) SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH "Install path: SALOME Python scripts") +# Specific to [NAME_OF_APPLICATION]: +SET(SALOME_[NAME_OF_APPLICATION]_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/(name_of_application)" CACHE PATH + "Install path: SALOME PYHELLO specific data") + MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_PYTHON) # Sources # ======== ADD_SUBDIRECTORY( src ) +ADD_SUBDIRECTORY( resources ) diff --git a/bin/app-template/resources/CMakeLists.txt b/bin/app-template/resources/CMakeLists.txt new file mode 100644 index 000000000..a957ad55d --- /dev/null +++ b/bin/app-template/resources/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright (C) 2012-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SalomeApp.xml.in ${CMAKE_CURRENT_BINARY_DIR}/SalomeApp.xml INSTALL ${SALOME_[NAME_OF_APPLICATION]_INSTALL_RES_DATA}) + diff --git a/bin/app-template/resources/SalomeApp.xml.in b/bin/app-template/resources/SalomeApp.xml.in new file mode 100644 index 000000000..11102af6c --- /dev/null +++ b/bin/app-template/resources/SalomeApp.xml.in @@ -0,0 +1,22 @@ + + +
+ + + + + + + + + + + + + + +
+
+ +
+
-- 2.39.2