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