Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[tools/hxx2salome.git] / scripts / hxx2salome
index bc2e588df5bc92d64c75e76f801b047363f737f5..c8a7507948f176869a17236a30c05b55a69942f7 100755 (executable)
@@ -35,7 +35,7 @@ usage()
     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
+    echo -e "                             if it is the case, you'll have to adapt your Makefile.am
     echo -e "    -l                    : to launch salome "
     exit
 }
@@ -190,14 +190,19 @@ generate_module_source()
     echo -e "\n-> Duplicate template module" | tee hxx2salome_journal
     tar xvfz ${gene_dir}/template_src.tgz >> 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
+    ${gene_dir}/renameSalomeModule -i HXX2SALOME_GENERIC_CLASS_NAME ${CLASS_NAME} ${CLASS_NAME}_SRC 
+    ###>> hxx2salome_journal
+    ${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
+       sed "s/${CLASS_NAME}GUI//" < ${CLASS_NAME}_SRC/src/Makefile.am > /tmp/h2smkf.$$
+       mv /tmp/h2smkf.$$ ${CLASS_NAME}_SRC/src/Makefile.am
+       cat ${CLASS_NAME}_SRC/configure.ac | awk ' $0 !~ "^.*GUI/Makefile"  { print $0}' > /tmp/h2scac.$$
+       mv /tmp/h2scac.$$  ${CLASS_NAME}_SRC/configure.ac
     fi
 #
     echo -e "\n-> Substitute generated code in idl file"
@@ -226,12 +231,12 @@ generate_module_source()
     get_python_test_file
     get_info_makefile
     
-    echo -e "\n-> Substitute flags in Makefile.in"
+    echo -e "\n-> Substitute flags in Makefile.am"
     sed "s?HXX2SALOME_INCLUDE?${makefile_include}?g
          s?HXX2SALOME_PYTHON_FILE?${python_test_file}?g
          s?HXX2SALOME_LIB?${makefile_lib}?g
-        " ${CLASS_NAME}_SRC/src/${CLASS_NAME}/Makefile.in > tmpfile
-    mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}/Makefile.in
+        " ${CLASS_NAME}_SRC/src/${CLASS_NAME}/Makefile.am > tmpfile
+    mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}/Makefile.am
 #
 # generate component catalog
     echo -e "\n-> Generate component catalog" | tee hxx2salome_journal
@@ -243,8 +248,15 @@ generate_module_source()
     fi
     cd ${CLASS_NAME}_SRC/resources
     VER=`cat ${KERNEL_ROOT_DIR}/bin/salome/VERSION | awk ' { print $NF }'` # extract number of version 
+    export PYTHONPATH=${PYTHONPATH}:${KERNEL_ROOT_DIR}/bin/salome  # to be sure IDLparser is in PYTHONPATH
     ${idlparser} -Wbcatalog=tmp.xml,icon=${CLASS_NAME}.png,version=${VER} -I${KERNEL_ROOT_DIR}/idl/salome -I${MED_ROOT_DIR}/idl/salome ../idl/${CLASS_NAME}_Gen.idl >& /dev/null | tee  hxx2salome_journal
-    cat tmp.xml | sed 's/_Gen//g' > ${CLASS_NAME}Catalog.xml
+    if [ -f tmp.xml ]
+    then
+       cat tmp.xml | sed 's/_Gen//g' > ${CLASS_NAME}Catalog.xml
+    else
+       echo Error with runIDLparser - the catalog was not generated
+       exit
+    fi
     rm tmp.xml
 #
 }
@@ -354,9 +366,9 @@ good_bye()
     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 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"
+    echo -e "you'll have to modify the following files Makefile.am: "
+    echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}/Makefile.am"
+    echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}GUI/Makefile.am"
 }
 
 launch_salome()
@@ -481,17 +493,38 @@ else
    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
 #
@@ -499,6 +532,9 @@ fi
 #
 CLASS_NAME=`awk '$1 == "class" && $0 !~ /;/ {print $2}' ${hxx_file}|awk -F: '{print $1}'`
 echo "    Name of class :" $CLASS_NAME
+class_name=`echo ${CLASS_NAME} | awk '{print tolower($0)}'`
+echo class_name = ${class_name}
+
 if [ ! $CLASS_NAME ]
 then
     echo -e "\nError:\n  Sorry - No class definition was found!\n  Please check your header file\n"