X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fhxx2salome;h=964ce0f041465b8d7b8250817db791af626a6f95;hb=refs%2Ftags%2FT32x_16Aug2007_16h00m;hp=1e3575c59637062c81e40b5885d6996a2c51d8ee;hpb=53f7af15eebcc3d8b2b98cba636fb8c9d4fba8dd;p=tools%2Fhxx2salome.git diff --git a/scripts/hxx2salome b/scripts/hxx2salome index 1e3575c..964ce0f 100755 --- a/scripts/hxx2salome +++ b/scripts/hxx2salome @@ -28,8 +28,11 @@ usage() echo -e " of the Salome component\n" echo -e "\n Options :" echo -e " -h : help" - echo -e " -e environment_script : to specify the name of a environment file that will be source for compiling" + echo -e " -e environment_script : to specify the name of a environment file that will be updated with new necessary commands" + echo -e " (this file is also used for sourcing environment before compilation if it has sh or bash syntax," + echo -e " if the syntax is csh, it is not sourced and for compiling (-c option) environment must be set up before)" echo -e " -s script_extension : to use if your environment file name doesn't have extension" + echo -e " -g : to create a gui part in your component building tree" echo -e " -c : to compile after generation" echo -e " (use this option only if you don't have dependencies in your header or libraries" echo -e " if it is the case, you'll have to adapt your Makefile.in" @@ -140,8 +143,8 @@ create_component_tree() get_info_makefile() { - makefile_lib="-L\${${CLASS_NAME}_CPP_ROOT}${lib_dir#${CPP_ROOT_DIR}} -l${lib_file}" - makefile_include="-I\${${CLASS_NAME}_CPP_ROOT}${hxx_dir#${CPP_ROOT_DIR}}" + makefile_lib="-L\${${CLASS_NAME}CPP_ROOT_DIR}${lib_dir#${CPP_ROOT_DIR}} -l${lib_file}" + makefile_include="-I\${${CLASS_NAME}CPP_ROOT_DIR}${hxx_dir#${CPP_ROOT_DIR}}" echo -e "\nlinking option : $makefile_lib" echo -e "include option : $makefile_include" @@ -172,7 +175,7 @@ generate_module_source() # outputs echo -e "\n IDL file:" cat parse_result > hxx2salome_journal - echo -e "\n----------------- IDL file ------------------\n">>hxx2salome_journal + echo -e "\n----------------- IDL file ------------------\n" >> hxx2salome_journal cat code_idl >> hxx2salome_journal cat code_idl echo -e "\n----------------- hxx file ------------------\n" >> hxx2salome_journal @@ -186,8 +189,16 @@ generate_module_source() # echo -e "\n-> Duplicate template module" | tee hxx2salome_journal tar xvfz ${gene_dir}/template_src.tgz >> hxx2salome_journal - mv TEMPLATE_SRC ${CLASS_NAME}_SRC - ${gene_dir}/renameSalomeModule -i TEMPLATE ${CLASS_NAME} ${CLASS_NAME}_SRC >> hxx2salome_journal + mv HXX2SALOME_GENERIC_CLASS_NAME_SRC ${CLASS_NAME}_SRC + ${gene_dir}/renameSalomeModule -i HXX2SALOME_GENERIC_CLASS_NAME ${CLASS_NAME} ${CLASS_NAME}_SRC >> hxx2salome_journal +# + if [ $make_gui -eq 0 ] + then + echo -e "\n-> Delete GUI part from the tree" >> hxx2salome_journal + 'rm' -rf ${CLASS_NAME}_SRC/src/${CLASS_NAME}GUI + sed "s/${CLASS_NAME}GUI//" < ${CLASS_NAME}_SRC/src/Makefile.in > /tmp/h2smkf.$$ + mv /tmp/h2smkf.$$ ${CLASS_NAME}_SRC/src/Makefile.in + fi # echo -e "\n-> Substitute generated code in idl file" echo "// this idl file was generated by hxx2salome" > tmpfile @@ -286,8 +297,8 @@ update_environment() then echo -e "###\n#------ ${CLASS_NAME}-Bin ------" >> ${ENVIRON_FILE} echo -e "setenv ${CLASS_NAME}_ROOT_DIR \${${CLASS_NAME}_BASE}/${CLASS_NAME}_INSTALL" >> ${ENVIRON_FILE} - echo -e "setenv ${CLASS_NAME}_CPP_ROOT ${CPP_ROOT_DIR}" >> ${ENVIRON_FILE} - echo -e "setenv LD_LIBRARY_PATH \${${CLASS_NAME}_CPP_ROOT}${lib_dir#${CPP_ROOT_DIR}}:\${LD_LIBRARY_PATH}" >> ${ENVIRON_FILE} + echo -e "setenv ${CLASS_NAME}CPP_ROOT_DIR ${CPP_ROOT_DIR}" >> ${ENVIRON_FILE} + echo -e "setenv LD_LIBRARY_PATH \${${CLASS_NAME}CPP_ROOT_DIR}${lib_dir#${CPP_ROOT_DIR}}:\${LD_LIBRARY_PATH}" >> ${ENVIRON_FILE} fi fi if [ "${SHELL_EXT}" == "sh" ] @@ -307,8 +318,8 @@ update_environment() then echo -e "###\n#------ ${CLASS_NAME}-Bin ------" >> ${ENVIRON_FILE} echo -e "export ${CLASS_NAME}_ROOT_DIR=\${${CLASS_NAME}_BASE}/${CLASS_NAME}_INSTALL" >> ${ENVIRON_FILE} - echo -e "export ${CLASS_NAME}_CPP_ROOT=${CPP_ROOT_DIR}" >> ${ENVIRON_FILE} - echo -e "export LD_LIBRARY_PATH=\${${CLASS_NAME}_CPP_ROOT}${lib_dir#${CPP_ROOT_DIR}}:\${LD_LIBRARY_PATH}" \ + echo -e "export ${CLASS_NAME}CPP_ROOT_DIR=${CPP_ROOT_DIR}" >> ${ENVIRON_FILE} + echo -e "export LD_LIBRARY_PATH=\${${CLASS_NAME}CPP_ROOT_DIR}${lib_dir#${CPP_ROOT_DIR}}:\${LD_LIBRARY_PATH}" \ >> ${ENVIRON_FILE} fi @@ -318,6 +329,8 @@ update_environment() copy_component_source() { mv ${tmp_dir}/${CLASS_NAME}_SRC/* ${NEW_COMPONENT_SRC_DIR} + mkdir -p ${NEW_COMPONENT_BUILD_DIR} + mkdir -p ${NEW_COMPONENT_ROOT_DIR} } good_bye() @@ -338,11 +351,12 @@ good_bye() echo -e "\trun Salome" echo -e "\tadd ${CLASS_NAME} to the Salome modules list" echo -e "\t\t(with the --modules option of the runSalome command or" - echo -e "\t\tby editing the ~/.salome_2.2.4/salome.launch file)" + echo -e "\t\tby editing your own per-user configuration file ~/.SalomeApprc.3.x.x)" echo -e "\nIf the header of your component includes other headers that are not in the same directories," - echo -e "or if yout library has dependencies you want to specify," - echo -e "you'll have to modify the following Makefile:in : " + echo -e "or if your library has dependencies you want to specify," + echo -e "you'll have to modify the following files Makefile.in: " echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}/Makefile.in" + echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}GUI/Makefile.in" } launch_salome() @@ -393,12 +407,14 @@ CPP_ROOT_DIR= NEW_COMPONENT_ROOT_DIR= NEW_COMPONENT_SRC_DIR= NEW_COMPONENT_BUILD_DIR= +SHELL_EXT=sh do_compile=0 do_launch=0 -# +make_gui=0 + # welcome # print some welcome info # -while getopts "cs:e:h:l" Option +while getopts "cs:e:h:lg" Option do case $Option in h) usage @@ -409,6 +425,7 @@ do csh) SHELL_EXT=csh;; *) SHELL_EXT=sh;; esac;; + g) make_gui=1;; c) do_compile=1;; l) do_launch=1;; *) echo "Unimplemented option chosen : $Option." @@ -442,44 +459,66 @@ then esac fi -if [ ${KERNEL_ROOT_DIR} ] && [ -d ${KERNEL_ROOT_DIR} ] && [ ${OMNIORBDIR} ] && [ -d ${OMNIORBDIR} ] +# Environment policy : +# - an existing sh file was specified : we source environment file +# - else (no file or csh syntax) : we don't source environment file, and do compile +# only if KERNEL_ROOT_DIR and MED_ROOT_DIR are defined +if [ "${SHELL_EXT}" == "sh" ] && [ ${ENVIRON_FILE} ] && [ -f ${ENVIRON_FILE} ] then - # if KERNEL_ROOT_DIR ans OMNIORBDIR are defined, we consider that environment is set - echo -e "\n Environment already set" + echo -e "\n Environment file with sh syntax specified => we source ${ENVIRON_FILE}" + source ${ENVIRON_FILE} else - # if KERNEL_ROOT_DIR is not defined : - # - sh file : we source environment file - # - csh file : we do not compile - if [ "${SHELL_EXT}" == "sh" ] && [ ${ENVIRON_FILE} ] && [ -f ${ENVIRON_FILE} ] - then - echo -e "\n Environment not set : source ${ENVIRON_FILE}" - source ${ENVIRON_FILE} - else + if [ ${KERNEL_ROOT_DIR} ] && [ -d ${KERNEL_ROOT_DIR} ] && [ ${MED_ROOT_DIR} ] && [ -d ${MED_ROOT_DIR} ] + then + # if KERNEL_ROOT_DIR and MED_ROOT_DIR are defined, we consider that environment is set + echo -e "\n Environment already set (KERNEL_ROOT_DIR and MED_ROOT_DIR are defined)" + else if [ $do_compile -eq 1 ] then - echo -e "\n Warning - Cannot compile : Environment shoud be set up for compiling!\n" - do_compile=0 + echo -e "\n Warning - Cannot compile : Environment shoud be set up before, or specify a environment file with sh syntax!\n" + do_compile=0 fi - fi + fi fi +# look up hxx2salome scripts +# - first search in directory ${HXX2SALOME_ROOT_DIR} (if the variable is defined) +# - then search in directory ${HXX2SALOME_ROOT_DIR}/bin +# - finally seach locally. # if [ ${HXX2SALOME_ROOT_DIR} ] && [ -d ${HXX2SALOME_ROOT_DIR} ] then - gene_dir=${HXX2SALOME_ROOT_DIR} + echo " HXX2SALOME_ROOT_DIR variable is defined : ${HXX2SALOME_ROOT_DIR} => we look up hxx2salome scripts inside" + if [ -f ${HXX2SALOME_ROOT_DIR}/parse1.awk -a -f ${HXX2SALOME_ROOT_DIR}/parse2.awk ] # check if script are found in ${HXX2SALOME_ROOT_DIR} + then + gene_dir=${HXX2SALOME_ROOT_DIR} + elif [ -f ${HXX2SALOME_ROOT_DIR}/bin/parse1.awk -a -f ${HXX2SALOME_ROOT_DIR}/bin/parse2.awk ] # else check /bin directory + then + gene_dir=${HXX2SALOME_ROOT_DIR}/bin + else + echo -e "\nError : Variable HXX2SALOME_ROOT_DIR not correctly set" + usage + fi else - gene_dir=`pwd` # case where hxx2salome was launched from HXX2SALOME directory + echo "HXX2SALOME_ROOT_DIR directory not set => we look up hxx2salome scripts locally" + if [ -f parse1.awk -a -f parse2.awk ] # check if script are found locally + then + gene_dir=`pwd` # case where hxx2salome was launched from HXX2SALOME directory + else + echo -e "\nError : Variable HXX2SALOME_ROOT_DIR is not set, and hxx2salome didn't find his scripts locally" + usage + fi fi -echo " hxx2salome directory : $gene_dir" -if [ ! -f ${gene_dir}/parse1.awk -o ! -f ${gene_dir}/parse2.awk ] # check if script are found +echo " hxx2salome directory found : $gene_dir" +if [ ! -f ${gene_dir}/parse3.awk -o ! -f ${gene_dir}/template_src.tgz ] # final check then - echo -e "\nError : Variable HXX2SALOME_ROOT_DIR shoud be set, or hxx2salome should be launched localy from bin directory" + echo -e "\nError : scripts parse3.awk or template_src.tgz not present in hxx2salome directory : $gene_dir" usage fi # # get class name # -CLASS_NAME=`awk '$1 == "class" && $0 !~ /;/ {print $2}' ${hxx_file}` +CLASS_NAME=`awk '$1 == "class" && $0 !~ /;/ {print $2}' ${hxx_file}|awk -F: '{print $1}'` echo " Name of class :" $CLASS_NAME if [ ! $CLASS_NAME ] then @@ -514,7 +553,7 @@ create_component_tree # update_environment export `echo ${CLASS_NAME}`_ROOT_DIR=${NEW_COMPONENT_ROOT_DIR} # to avoid resource env for compiling and launching salome -export `echo ${CLASS_NAME}`_CPP_ROOT=${CPP_ROOT_DIR} # idem +export `echo ${CLASS_NAME}`CPP_ROOT_DIR=${CPP_ROOT_DIR} # idem # # ---------------------- Copy the generated source from temp dir ------------------------------------------- #