Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/yacs.git] / src / wrappergen / src / hxx2salome_cpp
1 # Copyright (C) 2006-2012  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 generate_cpp_module_source()
20 {
21    if [ ${BE_QUIET} -lt 1 ] ; then
22        echo -e "\n\n\tC++ wrapper generation"
23    fi
24    cd ${tmp_dir}
25 #
26 # ------------------------- C++ generation ------------------------------------------------------
27    sed -e "s/SUBDIRS = /SUBDIRS = ${CLASS_NAME}_CPP /" < ${CLASS_NAME}_SRC/src/Makefile.am > ${CLASS_NAME}_SRC/src/tmpfile
28    \mv -f ${CLASS_NAME}_SRC/src/tmpfile ${CLASS_NAME}_SRC/src/Makefile.am
29
30    if [ ${BE_QUIET} -lt 1 ] ; then
31        echo -e "\n\n-> Generate Salome2 C++ files\n"
32    fi
33    cat ${CLASS_NAME}_public_functions |\
34    awk -v class_name=${CLASS_NAME} -f ${gene_dir}/parse4.awk
35    echo "#include \""`basename ${hxx_file}`"\"" > ${CLASS_NAME}_SRC/src/${CLASS_NAME}_CPP/${CLASS_NAME}_CPP.cxx
36    echo >> ${CLASS_NAME}_SRC/src/${CLASS_NAME}_CPP/${CLASS_NAME}_CPP.cxx
37
38    cat code_dispatch >> ${CLASS_NAME}_SRC/src/${CLASS_NAME}_CPP/${CLASS_NAME}_CPP.cxx
39    get_info_makefile
40     
41    if [ ${BE_QUIET} -lt 1 ] ; then
42        echo -e "\n-> Substitute flags in Makefile.am"
43    fi
44    sed "s?HXX2SALOME_INCLUDE?${makefile_include}?g
45         s?HXX2SALOME_PYTHON_FILE?${python_test_file}?g
46         s?HXX2SALOME_LIB?${makefile_lib}?g
47        " ${CLASS_NAME}_SRC/src/${CLASS_NAME}_CPP/Makefile.am > tmpfile
48    sed "s?XXX?XXX -I$hxx_dir?" tmpfile > tmp2file
49    
50    if [ "x${USE_MED}" == "x1" ]
51    then
52        sed "/AM_CXXFLAGS/s?\$? -DMED_WITHOUT_KERNEL -DUSE_MED \${MED2_INCLUDES} -I\${MED_ROOT_DIR}/include/salome?" tmp2file > tmpfile
53        sed "s?USE_MED=0?USE_MED=1?" tmpfile > tmp2file
54    fi 
55    mv tmp2file ${CLASS_NAME}_SRC/src/${CLASS_NAME}_CPP/Makefile.am
56    \rm -f tmpfile tmp2file 
57
58    if [ ${BE_QUIET} -lt 1 ] ; then
59        echo -e "\n-> XML Catalog generation"
60    fi
61    cat ${CLASS_NAME}_public_functions | awk -v class_name=${CLASS_NAME} -f ${gene_dir}/parse5.awk
62    mv catalog.xml ${CLASS_NAME}_SRC/resources/${CLASS_NAME}Catalog.xml
63
64    echo "" >> ${CLASS_NAME}_SRC/resources/Makefile.am
65    echo "${CLASS_NAME}Catalog.xml: \${srcdir}/${CLASS_NAME}Catalog.xml" >> ${CLASS_NAME}_SRC/resources/Makefile.am
66    echo "       cp \$^ \$@" >> ${CLASS_NAME}_SRC/resources/Makefile.am
67
68 }
69
70 clean_cpp_module_source()
71 {
72    \rm -rf ${CLASS_NAME}_SRC/src/${CLASS_NAME}_CPP
73 }
74