Salome HOME
Merge branch 'V9_11_BR'
[modules/yacs.git] / src / wrappergen / src / hxx2salome_corba
1 # Copyright (C) 2006-2023  CEA, EDF
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, or (at your option) any later version.
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_corba_module_source()
20 {
21    cd ${tmp_dir}
22    if [ ${BE_QUIET} -lt 1 ] ; then
23        echo -e "\n\n\tCorba wrapper generation"
24    fi
25 #
26 # ------------------------- Corba generation ------------------------------------------------------
27    if [ ${BE_QUIET} -lt 1 ] ; then
28        echo -e "\n\n-> Generate Salome2 Corba files\n"
29    fi
30    cat ${CLASS_NAME}_public_functions |\
31    awk -v class_name=${CLASS_NAME} -f ${gene_dir}/parse3.awk
32
33    if [ `grep -c MEDMEM:: ${CLASS_NAME}_public_functions` -gt 0 ]
34    then
35        USE_MED=1
36     else
37        USE_MED=0
38     fi
39
40 # outputs
41
42    cat parse_result >> hxx2salome_journal
43    echo -e "\n----------------- IDL file ------------------\n" >> hxx2salome_journal
44    cat code_idl >> hxx2salome_journal
45    echo -e "\n----------------- hxx file ------------------\n" >> hxx2salome_journal
46    cat code_hxx >> hxx2salome_journal
47    echo -e "\n----------------- cxx file ------------------\n" >> hxx2salome_journal
48    cat code_cxx >> hxx2salome_journal
49
50    if [ ${BE_QUIET} -lt 1 ] ; then
51        echo -e "\n  IDL file:"
52        cat code_idl
53        echo
54    fi
55
56    if [ ${BE_QUIET} -lt 1 ] ; then
57        echo -e "\n-> Substitute generated code in idl file"
58    fi
59    echo "// this idl file was generated by hxx2salome" > tmpfile
60    cat ${CLASS_NAME}_SRC/idl/${CLASS_NAME}_Gen.idl |awk \
61        '$0 ~ "HXX2SALOME_IDL_CODE" {system("cat code_idl >> tmpfile")} 
62         $0 != "HXX2SALOME_IDL_CODE" { print $0 >> "tmpfile" }'
63    mv tmpfile ${CLASS_NAME}_SRC/idl/${CLASS_NAME}_Gen.idl
64 #
65    if [ ${BE_QUIET} -lt 1 ] ; then
66        echo -e "\n-> Substitute generated code in hxx file"
67    fi
68    echo "// this hxx file was generated by hxx2salome" > tmpfile
69    cat ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I/${CLASS_NAME}_i.hxx |awk '
70        $0 ~ "HXX2SALOME_HXX_CODE" {system("cat code_hxx >> tmpfile")}
71        $0 !~ "HXX2SALOME" { print $0 >> "tmpfile" }'
72    mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I/${CLASS_NAME}_i.hxx
73 #
74    if [ ${BE_QUIET} -lt 1 ] ; then
75        echo -e "\n-> Substitute generated code in cxx file"
76    fi
77    echo "// this cxx file was generated by hxx2salome" > tmpfile
78    cat ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I/${CLASS_NAME}_i.cxx |awk -v cpp_include=$hxx '
79        $0 ~ "HXX2SALOME_CXX_CODE" {system("cat code_cxx >> tmpfile")}
80        $0 ~ "HXX2SALOME_CPP_INCLUDE" { printf "#include \"%s\"\n",cpp_include >> "tmpfile" }
81        $0 !~ "HXX2SALOME" { print $0 >> "tmpfile" }'
82    mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I/${CLASS_NAME}_i.cxx
83
84    get_info_makefile
85    
86    if [ ${BE_QUIET} -lt 1 ] ; then
87        echo -e "\n-> Substitute flags in Makefile.am files"
88    fi
89
90 #    Root Makefile.am
91    sed -e "s/SUBDIRS = /SUBDIRS =  ${CLASS_NAME}_I/" \
92         < ${CLASS_NAME}_SRC/src/Makefile.am \
93         > ${CLASS_NAME}_SRC/src/Makefile.am_new
94    \mv -f  ${CLASS_NAME}_SRC/src/Makefile.am_new \
95         ${CLASS_NAME}_SRC/src/Makefile.am
96
97 #    IDL Makefile.am
98    if [ ${USE_MED} == 1 ]
99        then
100        sed "s?USE_MED=0?USE_MED=1\nIDL_FILES += MED.idl\nIDL_SRC += MEDSK.cc?" ${CLASS_NAME}_SRC/idl/Makefile.am > tmpfile
101        sed "s?XXX?XXX -DUSE_MED -I\${MED_ROOT_DIR}/idl/salome?" tmpfile > tmp2file
102        mv tmp2file ${CLASS_NAME}_SRC/idl/Makefile.am
103    fi
104
105 #    C++ implementation Makefile.am
106    sed "s?HXX2SALOME_INCLUDE?${makefile_include}?g
107         s?HXX2SALOME_PYTHON_FILE?${python_test_file}?g
108         s?HXX2SALOME_LIB?${makefile_lib}?g
109        " ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I/Makefile.am > tmpfile
110    sed "s?XXX?XXX -I$hxx_dir?" tmpfile > tmp2file
111    if [ ${BE_QUIET} -lt 1 ] ; then
112        cat ${CLASS_NAME}_public_functions
113    fi
114    if [ ${USE_MED} == 1 ]
115    then
116        sed "/AM_CXXFLAGS/s?\$? -DUSE_MED \${MED2_INCLUDES} -I\${MED_ROOT_DIR}/include/salome?" tmp2file > tmpfile
117        sed "s?USE_MED=0?USE_MED=1?" tmpfile > tmp2file
118    fi 
119    mv tmp2file ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I/Makefile.am
120    \rm -f tmpfile tmp2file
121 #
122 #    generate component catalog
123    if [ ${BE_QUIET} -lt 1 ] ; then
124        echo -e "\n-> Generate component catalog" | tee hxx2salome_journal
125    fi
126    if [ -f ${KERNEL_ROOT_DIR}/bin/salome/runIDLparser ]
127    then
128        idlparser=${KERNEL_ROOT_DIR}/bin/salome/runIDLparser
129    else
130        idlparser=${gene_dir}/runIDLparser
131    fi
132    if [ ${USE_MED} == 1 ]
133    then
134        idlparser="${idlparser} -DUSE_MED=1 -I${MED_ROOT_DIR}/idl/salome"
135    fi
136
137    cd ${CLASS_NAME}_SRC/resources
138    VER=`cat ${KERNEL_ROOT_DIR}/bin/salome/VERSION | awk ' { print $NF }'` # extract number of version 
139    ${idlparser} -Wbcatalog=tmp.xml,icon=${CLASS_NAME}.png,version=${VER} -I${KERNEL_ROOT_DIR}/idl/salome ../idl/${CLASS_NAME}_Gen.idl >& /dev/null | tee  hxx2salome_journal
140    cat tmp.xml | sed 's/_Gen//g' > ${CLASS_NAME}Catalog.xml
141    \rm -f tmp.xml
142
143 }
144
145 clean_corba_module_source()
146 {
147    \rm -rf ${CLASS_NAME}_SRC/src/${CLASS_NAME}_I
148    \rm -rf ${CLASS_NAME}_SRC/idl/*
149    touch ${CLASS_NAME}_SRC/idl/Makefile.am
150    sed -e "s/^CHECK_OMNIORB/dnl CHECK_OMNIORB/" -e "/CORBA/s/^/dnl /" ${CLASS_NAME}_SRC/configure.in.base > ${CLASS_NAME}_SRC/configure.in.temp
151    mv ${CLASS_NAME}_SRC/configure.in.temp ${CLASS_NAME}_SRC/configure.in.base
152 }