Salome HOME
suppress check on OMNIORBDIR variable.
[tools/hxx2salome.git] / scripts / hxx2salome
index 77187ed710c641d6f3150ebae365647bc76a896f..c343ee0180faff48db94348d6b495ccbff46e2ce 100755 (executable)
@@ -28,7 +28,9 @@ 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 "    -c                    : to compile after generation"
     echo -e "                            (use this option only if you don't have dependencies in your header or libraries"
@@ -157,7 +159,7 @@ generate_module_source()
 # -------------------------  parse hxx file and generate code  ---------------------------------------
 #
     echo -e "\n-> Extract public functions\n"
-    cat ${hxx_file} | awk -f ${gene_dir}/parse1.awk > ${CLASS_NAME}_public_functions
+    cat ${hxx_file} | awk -f ${gene_dir}/parse01.awk | awk -f ${gene_dir}/parse1.awk > ${CLASS_NAME}_public_functions
     cat ${CLASS_NAME}_public_functions
     if [ ! -s ${CLASS_NAME}_public_functions ]
     then
@@ -276,7 +278,7 @@ update_environment()
        if [ $res == 1 ]
        then
            echo -e "###\n#------ ${CLASS_NAME}-Src ------" >>  ${ENVIRON_FILE}
-           echo -e "setenv ${CLASS_NAME}_BASE ${INSTALL_DIR}\n" >> ${ENVIRON_FILE}
+           echo -e "setenv ${CLASS_NAME}_BASE ${INSTALL_DIR}" >> ${ENVIRON_FILE}
            echo -e "setenv ${CLASS_NAME}_SRC_DIR \${${CLASS_NAME}_BASE}/${CLASS_NAME}_SRC\n" >> ${ENVIRON_FILE}
        fi
        
@@ -285,7 +287,7 @@ update_environment()
        if [ $res == 1 ]
        then
            echo -e "###\n#------ ${CLASS_NAME}-Bin ------" >>  ${ENVIRON_FILE}
-           echo -e "setenv ${CLASS_NAME}_ROOT_DIR \${${CLASS_NAME}_BASE}/${CLASS_NAME}_INSTALL\n" >> ${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}
        fi
@@ -297,7 +299,7 @@ update_environment()
        if [ $res == 1 ]
        then
            echo -e "###\n#------ ${CLASS_NAME}-Src ------" >>  ${ENVIRON_FILE}
-           echo -e "export ${CLASS_NAME}_BASE=${INSTALL_DIR}\n" >> ${ENVIRON_FILE}
+           echo -e "export ${CLASS_NAME}_BASE=${INSTALL_DIR}" >> ${ENVIRON_FILE}
            echo -e "export ${CLASS_NAME}_SRC_DIR=\${${CLASS_NAME}_BASE}/${CLASS_NAME}_SRC\n" >> ${ENVIRON_FILE}
        fi
        
@@ -306,7 +308,7 @@ update_environment()
        if [ $res == 1 ]
        then
            echo -e "###\n#------ ${CLASS_NAME}-Bin ------" >>  ${ENVIRON_FILE}
-           echo -e "export ${CLASS_NAME}_ROOT_DIR=\${${CLASS_NAME}_BASE}/${CLASS_NAME}_INSTALL\n" >> ${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}" \
            >> ${ENVIRON_FILE}
@@ -362,7 +364,7 @@ compile_module()
     fi
     \rm -rf ${NEW_COMPONENT_ROOT_DIR}/* ${NEW_COMPONENT_BUILD_DIR}/*
 
-    source ${ENVIRON_FILE}
+#    source ${ENVIRON_FILE}
     echo 
     echo -e "\n-> Build Configure"
     cd ${NEW_COMPONENT_SRC_DIR}
@@ -440,36 +442,42 @@ then
        csh)  SHELL_EXT=csh;;
        sh)   SHELL_EXT=sh;;
    esac
-   if [ "${SHELL_EXT}" == "csh" ]
+fi
+
+# 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
+   echo -e "\n    Environment file with sh syntax specified => we source ${ENVIRON_FILE}"
+   source ${ENVIRON_FILE}
+else
+   if [ ${KERNEL_ROOT_DIR} ] && [ -d ${KERNEL_ROOT_DIR} ] && [ ${MED_ROOT_DIR} ] && [ -d ${MED_ROOT_DIR} ]
    then
-       # source csh environment and retrieve it in bash father shell
-       cp ${ENVIRON_FILE} __tmp__env.csh
-       cat >>__tmp__env.csh<<-EOF
-setenv | awk -F= '{print "export " \$1 "=\"" \$2 "\""}' >__tmp__env.sh
-EOF
-       csh __tmp__env.csh
-       . __tmp__env.sh
-       rm -f __tmp__env.csh
-       rm -f __tmp__env.sh
+       # 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
-       source ${ENVIRON_FILE}
+       if [ $do_compile -eq 1 ]
+       then 
+         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
-else
-    echo -e "\nSorry - Cannot compile : Environment file shoud be set up for compiling!\n"
-    do_compile=0
 fi
+
 #
 if [ ${HXX2SALOME_ROOT_DIR} ] && [ -d ${HXX2SALOME_ROOT_DIR} ]
 then
     gene_dir=${HXX2SALOME_ROOT_DIR}
 else
-    if [ ! -f parse1.awk -o ! -f parse2.awk ]
-    then
-        echo -e "\nError : Variable HXX2SALOME_ROOT_DIR shoud be set, or hxx2salome should be launched localy"
-        usage
-    else
-        gene_dir=`pwd` # case where hxx2salome was launched from HXX2SALOME directory
-    fi
+    gene_dir=`pwd` # case where hxx2salome was launched from HXX2SALOME directory
+fi
+echo "    hxx2salome directory : $gene_dir"
+if [ ! -f ${gene_dir}/parse1.awk -o ! -f ${gene_dir}/parse2.awk ] # check if script are found
+then
+    echo -e "\nError : Variable HXX2SALOME_ROOT_DIR shoud be set, or hxx2salome should be launched localy from bin directory"
+    usage
 fi
 #
 # get class name
@@ -508,7 +516,8 @@ create_component_tree
 # ---------------------- Modification of Salome environment file  -------------------------------------------
 #
 update_environment
-export `echo ${SOURCE_NAME}`_ROOT_DIR=${NEW_COMPONENT_ROOT_DIR}  # to avoid resource env for compiling and launching salome
+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
 #
 # ---------------------- Copy the generated source from temp dir  -------------------------------------------
 #