Salome HOME
Copyright update 2022
[modules/yacs.git] / src / wrappergen / src / hxx2salome_check
1 # Copyright (C) 2006-2022  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, 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 check_arguments()
20 {
21     # check if $1 is a directory
22     if [ ${BE_QUIET} -lt 1 ] ; then
23        echo -e "-> check arguments\n"
24     fi
25     if [ ! -d $1 ]
26     then
27        echo -e "Error : directory $1 does not exist!\n"
28        usage
29     fi
30     CPP_ROOT_DIR=${1%%/} # remove trailing slash if present 
31     OLD_DIR=`pwd`
32     cd $CPP_ROOT_DIR
33     CPP_ROOT_DIR=`pwd`
34     cd $OLD_DIR
35     if [ ${BE_QUIET} -lt 2 ] ; then
36        echo "    C++ Component directory : ${CPP_ROOT_DIR}"
37     fi
38
39     # look for include file $2 - check number of files found and extension
40     nb=`find ${CPP_ROOT_DIR} -name $2 | wc -l` # number of files found, should be equal to 1
41     extension=${2##*\.}
42     if [ $nb -eq 0 ]
43     then
44        echo -e "\n  Error:\n  Include file $2 not found in $1 directory!\n"
45        usage
46     elif [ $nb -ge 2 ]
47     then
48        echo -e "\n  Error:\n  More than one file named $2 was found in $1!\n  Include file should be unique!"
49      usage
50     elif [ $extension != "hxx" -a $extension != "hh" -a $extension != "h" ]
51     then
52         echo -e "\n  Error:\n  Extension=$extension\n  Include file $2 should have extension .hxx .hh or .h !\n"
53      usage
54     fi
55     hxx_file=`find ${CPP_ROOT_DIR} -name $2` # name of c++ header we will parse to generate salome module
56     hxx=$2
57     if [ ${BE_QUIET} -lt 2 ] ; then
58        echo "    C++ Component header    : ${hxx_file}"
59     fi
60     hxx_dir=`dirname ${hxx_file}`
61
62     # look for library $3
63     nb=`find ${CPP_ROOT_DIR} -name $3 | wc -l` # number of files found, should be equal to 1
64     if [ $nb -eq 0 ]
65     then
66         echo -e "\n  Error:\n  Library file $3 not found in $1 directory!\n"
67     usage
68     elif [ $nb -ge 2 ]
69     then
70         echo -e "\n  Error:\n  More than one file named $3 was found in $1!\n  Library file should be unique!"
71     usage
72     fi
73     so_file=`find ${CPP_ROOT_DIR} -name $3` # absolute path of library containing c++ module
74     if [ ${BE_QUIET} -lt 2 ] ; then
75        echo "    C++ Component library   : ${so_file}"
76     fi
77     lib_dir=`dirname ${so_file}`
78     lib_file=${3%.so} # name without .so
79     lib_file=${lib_file#lib} # name of library without lib and .so (needed by makefile)
80
81     # installation directory
82     if [[ ! -d $4 ]]
83     then
84        mkdir -p $4
85     fi
86     salomeComponentRoot=${4%%/} # remove trailing slash
87     OLD_DIR=`pwd`
88     cd $salomeComponentRoot
89     salomeComponentRoot=`pwd`
90     cd $OLD_DIR
91     if [ ${BE_QUIET} -lt 2 ] ; then
92        echo "    Salome Component directory : ${salomeComponentRoot}"
93     fi
94 }
95
96 validate_generation_choices()
97 {
98     declare -a arr
99     arr=( `echo "$@"` )
100    
101     echo "$@" 
102     if [ x${arr[$iCORBA]} == "xyes" ]
103     then
104        if [ "x${KERNEL_ROOT_DIR}" == "x" ]
105        then
106           arr[$iCORBA]="no"
107        else
108            if [ ! -f ${KERNEL_ROOT_DIR}/idl/salome/SALOME_Component.idl ]
109            then
110                arr[$iCORBA]="no"
111            fi
112        fi
113     fi
114 }