Salome HOME
bc2e588df5bc92d64c75e76f801b047363f737f5
[tools/hxx2salome.git] / scripts / hxx2salome
1 #!/bin/bash
2 #
3 #
4 # salome2 environment file (.bash or .sh) - can also be specified with -e option
5 ENVIRON_FILE=
6 # if present, hxx2salome will try to compile new module, by sourcing ENVIRON_FILE file, and executing
7 # build_configure, configure, make & make install
8 # remark : hxx2salome has to be lanched with clean PATH, LD_LIBRARY_PATH & PYTHONPATH variables!
9 #
10 # options you want to pass to configure
11 CONFIGURE_OPTION=
12 #
13 #
14 usage()
15 {
16     echo -e "\n  Usage :\n"
17     echo -e "  Set HXX2SALOME_ROOT_DIR variable"
18     echo -e "  ${HXX2SALOME_ROOT_DIR}/hxx2salome [options] "
19     echo -e "             cppComponent_root_dir cppComponent.hxx"
20     echo -e "             libcppComponent.so salomeComponentRoot\n"
21     echo -e "     - cppComponent_root_dir : install directory (absolute path)"
22     echo -e "                               of the c++ component\n"
23     echo -e "     - cppComponent.hxx      : header of the component"
24     echo -e "     - libcppComponent.so    : library\n"
25     echo -e "       (cppComponent.hxx and libcppComponent.so have to be found"
26     echo -e "        in cppComponent_root_dir)\n"
27     echo -e "     - salomeComponentRoot   : directory of the source/build/install"
28     echo -e "                               of the Salome component\n"
29     echo -e "\n  Options :"
30     echo -e "    -h : help"
31     echo -e "    -e environment_script : to specify the name of a environment file that will be updated with new necessary commands"
32     echo -e "                            (this file is also used for sourcing environment before compilation if it has sh or bash syntax,"
33     echo -e "                             if the syntax is csh, it is not sourced and for compiling (-c option) environment must be set up before)"
34     echo -e "    -s script_extension   : to use if your environment file name doesn't have extension"
35     echo -e "    -g                    : to create a gui part in your component building tree"
36     echo -e "    -c                    : to compile after generation"
37     echo -e "                            (use this option only if you don't have dependencies in your header or libraries"
38     echo -e "                             if it is the case, you'll have to adapt your Makefile.in" 
39     echo -e "    -l                    : to launch salome "
40     exit
41 }
42 #
43 welcome()
44 {
45     echo -e "\n\n"
46     echo  "----------------------------------------------------------------------------"
47     echo
48     echo  "                              hxx2salome"
49     echo
50     echo  "     Automatic generation of a Salome2 component from a C++ component"
51     echo 
52     echo  "----------------------------------------------------------------------------"
53     echo 
54     echo 
55     echo 
56 }
57
58 check_arguments()
59 {
60
61     # check if $1 is a directory
62     echo -e "-> check arguments\n"
63     if [ ! -d $1 ]
64     then
65        echo -e "Error : directory $1 does not exist!\n"
66        usage
67     fi
68     CPP_ROOT_DIR=${1%%/} # remove trailing slash if present 
69     echo "    C++ Component directory : ${CPP_ROOT_DIR}"
70
71     # look for include file $2 - check number of files found and extension
72     nb=`find ${CPP_ROOT_DIR} -name $2 | wc -l` # number of files found, should be equal to 1
73     extension=${2##*\.}
74     if [ $nb -eq 0 ]
75     then
76           echo -e "\n  Error:\n  Include file $2 not found in $1 directory!\n"
77           usage
78     elif [ $nb -ge 2 ]
79     then
80          echo -e "\n  Error:\n  More than one file named $2 was found in $1!\n  Include file should be unique!"
81          usage
82     elif [ $extension != "hxx" -a $extension != "hh" -a $extension != "h" ]
83     then
84          echo -e "\n  Error:\n  Extension=$extension\n  Include file $2 should have extension .hxx .hh or .h !\n"
85          usage
86     fi
87     hxx_file=`find ${CPP_ROOT_DIR} -name $2` # name of c++ header we will parse to generate salome module
88     hxx=$2
89     echo "    C++ Component header    : ${hxx_file}"
90     hxx_dir=`dirname ${hxx_file}`
91
92     # look for library $3
93     nb=`find ${CPP_ROOT_DIR} -name $3 | wc -l` # number of files found, should be equal to 1
94     if [ $nb -eq 0 ]
95     then
96         echo -e "\n  Error:\n  Library file $3 not found in $1 directory!\n"
97         usage
98     elif [ $nb -ge 2 ]
99     then
100         echo -e "\n  Error:\n  More than one file named $3 was found in $1!\n  Library file should be unique!"
101         usage
102     fi
103     so_file=`find ${CPP_ROOT_DIR} -name $3` # absolute path of library containing c++ module
104     echo "    C++ Component library   : ${so_file}"
105     lib_dir=`dirname ${so_file}`
106     lib_file=${3%.so} # name without .so
107     lib_file=${lib_file#lib} # name of library without lib and .so (needed by makefile)
108
109     # installation directory
110     if [[ ! -d $4 ]]
111     then
112        mkdir -p $4
113     fi
114     salomeComponentRoot=${4%%/} # remove trailing slash
115     echo "    Salome Component directory : ${salomeComponentRoot}"
116 }
117
118 # retrieve python test file ending up with _test.py
119 get_python_test_file()
120 {
121     cd ${CPP_ROOT_DIR}
122     for file in `find . -name "*_test.py"`
123     do
124        cp $file ${tmp_dir}/${CLASS_NAME}_SRC/src/${CLASS_NAME}
125        python_test_file=${python_test_file}" "`basename $file`
126     done
127     echo -e "\nList of exported python file test : $python_test_file \n"
128     cd -
129 }
130
131 create_component_tree()
132 {
133     INSTALL_DIR=${salomeComponentRoot}/${CLASS_NAME}
134
135     export NEW_COMPONENT_SRC_DIR=${INSTALL_DIR}/${CLASS_NAME}_SRC
136     export NEW_COMPONENT_BUILD_DIR=${INSTALL_DIR}/${CLASS_NAME}_BUILD
137     export NEW_COMPONENT_ROOT_DIR=${INSTALL_DIR}/${CLASS_NAME}_INSTALL
138
139     \rm -rf ${NEW_COMPONENT_SRC_DIR}
140     mkdir -p ${NEW_COMPONENT_SRC_DIR}
141 }
142
143
144 get_info_makefile()
145 {
146     makefile_lib="-L\${${CLASS_NAME}CPP_ROOT_DIR}${lib_dir#${CPP_ROOT_DIR}} -l${lib_file}"
147     makefile_include="-I\${${CLASS_NAME}CPP_ROOT_DIR}${hxx_dir#${CPP_ROOT_DIR}}"
148     
149     echo -e "\nlinking option : $makefile_lib"
150     echo -e "include option : $makefile_include"
151 }
152
153 generate_module_source()
154 {
155 #
156 # go in temporary directory to work on code generation
157     cd ${tmp_dir}
158 #
159 #
160 # -------------------------  parse hxx file and generate code  ---------------------------------------
161 #
162     echo -e "\n-> Extract public functions\n"
163     cat ${hxx_file} | awk -f ${gene_dir}/parse01.awk | awk -f ${gene_dir}/parse1.awk > ${CLASS_NAME}_public_functions
164     cat ${CLASS_NAME}_public_functions
165     if [ ! -s ${CLASS_NAME}_public_functions ]
166     then
167         echo -e "\nError:\n  Sorry - No compatible function was found!\n  Please check your header file\n"
168         exit
169     fi
170 #
171     echo -e "\n\n-> Parse public functions and generate Salome2 files\n\n  compatibility      function\n"
172     cat ${CLASS_NAME}_public_functions | awk -f ${gene_dir}/parse2.awk |\
173     awk -v class_name=${CLASS_NAME} -f ${gene_dir}/parse3.awk
174 #
175 # outputs
176     echo -e "\n  IDL file:"
177     cat parse_result > hxx2salome_journal
178     echo -e "\n----------------- IDL file ------------------\n" >> hxx2salome_journal
179     cat code_idl >> hxx2salome_journal
180     cat code_idl
181     echo -e "\n----------------- hxx file ------------------\n" >> hxx2salome_journal
182     cat code_hxx >> hxx2salome_journal
183     echo -e "\n----------------- cxx file ------------------\n" >> hxx2salome_journal
184     cat code_cxx >> hxx2salome_journal
185     echo
186 #
187 #
188 # -------------------  duplicates template module and insert generated code  ------------------------------
189 #
190     echo -e "\n-> Duplicate template module" | tee hxx2salome_journal
191     tar xvfz ${gene_dir}/template_src.tgz >> hxx2salome_journal
192     mv HXX2SALOME_GENERIC_CLASS_NAME_SRC ${CLASS_NAME}_SRC
193     ${gene_dir}/renameSalomeModule -i HXX2SALOME_GENERIC_CLASS_NAME ${CLASS_NAME} ${CLASS_NAME}_SRC >> hxx2salome_journal
194 #
195     if [ $make_gui -eq 0 ]
196     then
197         echo -e "\n-> Delete GUI part from the tree" >> hxx2salome_journal
198         'rm' -rf ${CLASS_NAME}_SRC/src/${CLASS_NAME}GUI
199         sed "s/${CLASS_NAME}GUI//" < ${CLASS_NAME}_SRC/src/Makefile.in > /tmp/h2smkf.$$
200         mv /tmp/h2smkf.$$ ${CLASS_NAME}_SRC/src/Makefile.in
201     fi
202 #
203     echo -e "\n-> Substitute generated code in idl file"
204     echo "// this idl file was generated by hxx2salome" > tmpfile
205     cat ${CLASS_NAME}_SRC/idl/${CLASS_NAME}_Gen.idl |awk ' 
206         $0 ~ "HXX2SALOME_IDL_CODE" {system("cat code_idl >> tmpfile")} 
207         $0 != "HXX2SALOME_IDL_CODE" { print $0 >> "tmpfile" }'
208     mv tmpfile ${CLASS_NAME}_SRC/idl/${CLASS_NAME}_Gen.idl
209 #
210     echo -e "\n-> Substitute generated code in hxx file"
211     echo "// this hxx file was generated by hxx2salome" > tmpfile
212     cat ${CLASS_NAME}_SRC/src/${CLASS_NAME}/${CLASS_NAME}_i.hxx |awk '
213         $0 ~ "HXX2SALOME_HXX_CODE" {system("cat code_hxx >> tmpfile")}
214         $0 !~ "HXX2SALOME" { print $0 >> "tmpfile" }'
215     mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}/${CLASS_NAME}_i.hxx
216 #
217     echo -e "\n-> Substitute generated code in cxx file"
218     echo "// this cxx file was generated by hxx2salome" > tmpfile
219     cat ${CLASS_NAME}_SRC/src/${CLASS_NAME}/${CLASS_NAME}_i.cxx |awk -v cpp_include=$hxx '
220         $0 ~ "HXX2SALOME_CXX_CODE" {system("cat code_cxx >> tmpfile")}
221         $0 ~ "HXX2SALOME_CPP_INCLUDE" { printf "#include \"%s\"\n",cpp_include >> "tmpfile" }
222         $0 !~ "HXX2SALOME" { print $0 >> "tmpfile" }'
223     mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}/${CLASS_NAME}_i.cxx
224 #
225 # add flags in makefile
226     get_python_test_file
227     get_info_makefile
228     
229     echo -e "\n-> Substitute flags in Makefile.in"
230     sed "s?HXX2SALOME_INCLUDE?${makefile_include}?g
231          s?HXX2SALOME_PYTHON_FILE?${python_test_file}?g
232          s?HXX2SALOME_LIB?${makefile_lib}?g
233         " ${CLASS_NAME}_SRC/src/${CLASS_NAME}/Makefile.in > tmpfile
234     mv tmpfile ${CLASS_NAME}_SRC/src/${CLASS_NAME}/Makefile.in
235 #
236 # generate component catalog
237     echo -e "\n-> Generate component catalog" | tee hxx2salome_journal
238     if [ -f ${KERNEL_ROOT_DIR}/bin/salome/runIDLparser ]
239     then
240        idlparser=${KERNEL_ROOT_DIR}/bin/salome/runIDLparser
241     else
242        idlparser=${gene_dir}/runIDLparser
243     fi
244     cd ${CLASS_NAME}_SRC/resources
245     VER=`cat ${KERNEL_ROOT_DIR}/bin/salome/VERSION | awk ' { print $NF }'` # extract number of version 
246     ${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
247     cat tmp.xml | sed 's/_Gen//g' > ${CLASS_NAME}Catalog.xml
248     rm tmp.xml
249 #
250 }
251
252 compile()
253 {
254     echo "----------------- Configure -------------------"
255     
256     echo "----------------- Compile ---------------------"
257     make 
258     if [ $? -eq 0 ]
259     then
260         # compilation succeeded : we make install
261         echo
262         echo "----------------- Install ---------------------"
263         make install
264     else
265         exit 1
266     fi
267 }
268
269 update_environment()
270 {
271     if [ -z ${ENVIRON_FILE} ]
272     then
273         ENVIRON_FILE="${NEW_COMPONENT_SRC_DIR}/env_${CLASS_NAME}.${SHELL_EXT}"
274     fi
275
276     echo -e "\nEnvironment file : ", $ENVIRON_FILE
277     if [ -e ${ENVIRON_FILE} ]
278     then
279         cp ${ENVIRON_FILE} ${ENVIRON_FILE}.old
280     fi
281     touch ${ENVIRON_FILE}
282
283     if [ "${SHELL_EXT}" == "csh" ]
284     then
285         grep -q " ${CLASS_NAME}_SRC_DIR" ${ENVIRON_FILE}
286         res=$?
287         if [ $res == 1 ]
288         then
289             echo -e "###\n#------ ${CLASS_NAME}-Src ------" >>  ${ENVIRON_FILE}
290             echo -e "setenv ${CLASS_NAME}_BASE ${INSTALL_DIR}" >> ${ENVIRON_FILE}
291             echo -e "setenv ${CLASS_NAME}_SRC_DIR \${${CLASS_NAME}_BASE}/${CLASS_NAME}_SRC\n" >> ${ENVIRON_FILE}
292         fi
293         
294         grep -q " ${CLASS_NAME}_ROOT_DIR" ${ENVIRON_FILE}
295         res=$?
296         if [ $res == 1 ]
297         then
298             echo -e "###\n#------ ${CLASS_NAME}-Bin ------" >>  ${ENVIRON_FILE}
299             echo -e "setenv ${CLASS_NAME}_ROOT_DIR \${${CLASS_NAME}_BASE}/${CLASS_NAME}_INSTALL" >> ${ENVIRON_FILE}
300             echo -e "setenv ${CLASS_NAME}CPP_ROOT_DIR ${CPP_ROOT_DIR}" >> ${ENVIRON_FILE}
301             echo -e "setenv LD_LIBRARY_PATH \${${CLASS_NAME}CPP_ROOT_DIR}${lib_dir#${CPP_ROOT_DIR}}:\${LD_LIBRARY_PATH}" >> ${ENVIRON_FILE}
302         fi
303     fi
304     if [ "${SHELL_EXT}" == "sh" ]
305     then
306         grep -q " ${CLASS_NAME}_SRC_DIR=" ${ENVIRON_FILE}
307         res=$?
308         if [ $res == 1 ]
309         then
310             echo -e "###\n#------ ${CLASS_NAME}-Src ------" >>  ${ENVIRON_FILE}
311             echo -e "export ${CLASS_NAME}_BASE=${INSTALL_DIR}" >> ${ENVIRON_FILE}
312             echo -e "export ${CLASS_NAME}_SRC_DIR=\${${CLASS_NAME}_BASE}/${CLASS_NAME}_SRC\n" >> ${ENVIRON_FILE}
313         fi
314         
315         grep -q " ${CLASS_NAME}_ROOT_DIR=" ${ENVIRON_FILE}
316         res=$?
317         if [ $res == 1 ]
318         then
319             echo -e "###\n#------ ${CLASS_NAME}-Bin ------" >>  ${ENVIRON_FILE}
320             echo -e "export ${CLASS_NAME}_ROOT_DIR=\${${CLASS_NAME}_BASE}/${CLASS_NAME}_INSTALL" >> ${ENVIRON_FILE}
321             echo -e "export ${CLASS_NAME}CPP_ROOT_DIR=${CPP_ROOT_DIR}" >> ${ENVIRON_FILE}
322             echo -e "export LD_LIBRARY_PATH=\${${CLASS_NAME}CPP_ROOT_DIR}${lib_dir#${CPP_ROOT_DIR}}:\${LD_LIBRARY_PATH}" \
323             >> ${ENVIRON_FILE}
324         fi
325         
326     fi
327 }
328
329 copy_component_source()
330 {
331     mv ${tmp_dir}/${CLASS_NAME}_SRC/* ${NEW_COMPONENT_SRC_DIR}
332     mkdir -p ${NEW_COMPONENT_BUILD_DIR}
333     mkdir -p ${NEW_COMPONENT_ROOT_DIR}
334 }
335
336 good_bye()
337 {
338     echo -e "\n\nModule was created in ${NEW_COMPONENT_SRC_DIR}"
339     echo -e "\nTo compile it, do the following : \n"
340     echo -e "\tsource ${ENVIRON_FILE}"
341     echo -e "\tcd \${${CLASS_NAME}_SRC_DIR}"
342     echo -e "\t./build_configure"
343     echo -e "\tmkdir -p \${${CLASS_NAME}_BUILD_DIR}"
344     echo -e "\tcd \${${CLASS_NAME}_BUILD_DIR}"
345     echo -e "\t\${${CLASS_NAME}_SRC_DIR}/configure ${CONFIGURE_OPTION} --prefix=\${${CLASS_NAME}_ROOT_DIR}"
346     echo -e "\tmake"
347     echo -e "\tmake install"
348     echo -e "\nTo use it :\n"
349     echo -e "\tsource the Salome environment"
350     echo -e "\tsource the component environment file (${ENVIRON_FILE})"
351     echo -e "\trun Salome"
352     echo -e "\tadd ${CLASS_NAME} to the Salome modules list"
353     echo -e "\t\t(with the --modules option of the runSalome command or"
354     echo -e "\t\tby editing your own per-user configuration file ~/.SalomeApprc.3.x.x)"
355     echo -e "\nIf the header of your component includes other headers that are not in the same directories,"
356     echo -e "or if your library has dependencies you want to specify,"
357     echo -e "you'll have to modify the following files Makefile.in: "
358     echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}/Makefile.in"
359     echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}GUI/Makefile.in"
360 }
361
362 launch_salome()
363 {
364     ${KERNEL_ROOT_DIR}/bin/salome/runSalome --gui --modules=GEOM,SMESH,VISU,SUPERV,MED,`echo ${CLASS_NAME}`  --containers=cpp,python --killall
365 }
366
367 compile_module()
368 {
369     if [ ! -d ${NEW_COMPONENT_BUILD_DIR} ]
370     then
371         mkdir -p ${NEW_COMPONENT_BUILD_DIR}
372     fi
373     if [ ! -d ${NEW_COMPONENT_ROOT_DIR} ]
374     then
375         mkdir -p ${NEW_COMPONENT_ROOT_DIR}
376     fi
377     \rm -rf ${NEW_COMPONENT_ROOT_DIR}/* ${NEW_COMPONENT_BUILD_DIR}/*
378
379 #    source ${ENVIRON_FILE}
380     echo 
381     echo -e "\n-> Build Configure"
382     cd ${NEW_COMPONENT_SRC_DIR}
383     ./build_configure
384     cd ${NEW_COMPONENT_BUILD_DIR}
385     echo -e "\n-> Configure in ${NEW_COMPONENT_BUILD_DIR}"
386     echo -e "\n-> Install in ${NEW_COMPONENT_ROOT_DIR}"
387     ${NEW_COMPONENT_SRC_DIR}/configure ${CONFIGURE_OPTION} --prefix=${NEW_COMPONENT_ROOT_DIR}
388     echo
389
390     if [[ $do_compile -eq 1 ]]
391     then
392         compile
393     fi
394     
395     if [[ $do_launch -eq 1 ]]
396     then
397         launch_salome
398     fi
399 }
400 #
401 #
402 # ------------------------------------------------------------------------
403 # --------------------------- MAIN PROGRAM -------------------------------
404 # ------------------------------------------------------------------------
405 #
406 CPP_ROOT_DIR=
407 NEW_COMPONENT_ROOT_DIR=
408 NEW_COMPONENT_SRC_DIR=
409 NEW_COMPONENT_BUILD_DIR=
410 SHELL_EXT=sh
411 do_compile=0
412 do_launch=0
413 make_gui=0
414  #
415 welcome # print some welcome info
416 #
417 while getopts "cs:e:h:lg" Option
418 do
419    case $Option in
420      h) usage
421         exit;;
422      e) ENVIRON_FILE=$OPTARG;;
423      s) case $OPTARG in
424             bash) SHELL_EXT=sh;;
425             csh)  SHELL_EXT=csh;;      
426             *)    SHELL_EXT=sh;;
427         esac;;
428      g) make_gui=1;;
429      c) do_compile=1;;
430      l) do_launch=1;;
431      *) echo "Unimplemented option chosen : $Option."
432         usage
433         exit;;   # DEFAULT
434    esac
435 done
436
437 shift $(($OPTIND - 1))
438
439 # check number of other arguments
440 #
441 if [ $# -ne 4 ]
442 then
443    echo -e "\nBad number of arguments\n\n"
444    usage
445    exit
446 fi
447
448 check_arguments $1 $2 $3 $4
449
450 # if there is a sh compatible environment file, source it
451 if [[ -n ${ENVIRON_FILE} && -f ${ENVIRON_FILE} ]]
452 then
453    # analyse extension of environment file
454    case ${ENVIRON_FILE##*\.} in 
455        bash) SHELL_EXT=sh;;
456        ksh)  SHELL_EXT=sh;;
457        csh)  SHELL_EXT=csh;;
458        sh)   SHELL_EXT=sh;;
459    esac
460 fi
461
462 # Environment policy :
463 #   - an existing sh file was specified : we source environment file
464 #   - else (no file or csh syntax)      : we don't source environment file, and do compile 
465 #                                         only if KERNEL_ROOT_DIR and MED_ROOT_DIR are defined
466 if [ "${SHELL_EXT}" == "sh" ] && [ ${ENVIRON_FILE} ] && [ -f ${ENVIRON_FILE} ]
467 then
468    echo -e "\n    Environment file with sh syntax specified => we source ${ENVIRON_FILE}"
469    source ${ENVIRON_FILE}
470 else
471    if [ ${KERNEL_ROOT_DIR} ] && [ -d ${KERNEL_ROOT_DIR} ] && [ ${MED_ROOT_DIR} ] && [ -d ${MED_ROOT_DIR} ]
472    then
473        # if KERNEL_ROOT_DIR and MED_ROOT_DIR are defined, we consider that environment is set
474        echo -e "\n    Environment already set (KERNEL_ROOT_DIR and MED_ROOT_DIR are defined)"
475    else
476        if [ $do_compile -eq 1 ]
477        then 
478           echo -e "\n    Warning - Cannot compile : Environment shoud be set up before, or specify a environment file with sh syntax!\n"
479           do_compile=0
480        fi
481    fi
482 fi
483
484 #
485 if [ ${HXX2SALOME_ROOT_DIR} ] && [ -d ${HXX2SALOME_ROOT_DIR} ]
486 then
487     gene_dir=${HXX2SALOME_ROOT_DIR}
488 else
489     gene_dir=`pwd` # case where hxx2salome was launched from HXX2SALOME directory
490 fi
491 echo "    hxx2salome directory : $gene_dir"
492 if [ ! -f ${gene_dir}/parse1.awk -o ! -f ${gene_dir}/parse2.awk ] # check if script are found
493 then
494     echo -e "\nError : Variable HXX2SALOME_ROOT_DIR shoud be set, or hxx2salome should be launched localy from bin directory"
495     usage
496 fi
497 #
498 # get class name
499 #
500 CLASS_NAME=`awk '$1 == "class" && $0 !~ /;/ {print $2}' ${hxx_file}|awk -F: '{print $1}'`
501 echo "    Name of class :" $CLASS_NAME
502 if [ ! $CLASS_NAME ]
503 then
504     echo -e "\nError:\n  Sorry - No class definition was found!\n  Please check your header file\n"
505     exit
506 fi
507
508 #
509 # create temporary working directory
510 #
511 tmp_dir="/tmp/${USER}/${CLASS_NAME}"
512 if [ -d ${tmp_dir} ]
513 then
514     rm -rf ${tmp_dir}/*
515 else
516     mkdir -p ${tmp_dir}
517 fi
518
519 #
520 # ---------------------  Generation of module source from template ------------------------------------------
521 #
522 get_info_makefile
523 generate_module_source
524
525 #
526 # ---------------------- Installation of new module sources  ------------------------------------------------
527 #
528 create_component_tree
529
530 #
531 # ---------------------- Modification of Salome environment file  -------------------------------------------
532 #
533 update_environment
534 export `echo ${CLASS_NAME}`_ROOT_DIR=${NEW_COMPONENT_ROOT_DIR}  # to avoid resource env for compiling and launching salome
535 export `echo ${CLASS_NAME}`CPP_ROOT_DIR=${CPP_ROOT_DIR}  # idem
536 #
537 # ---------------------- Copy the generated source from temp dir  -------------------------------------------
538 #
539 copy_component_source
540
541 #
542 # ---------------------- If requested, compilation of the Salome component ----------------------------------
543 if [ ${do_compile} -eq 1 ]
544 then
545     compile_module
546 else
547     good_bye
548 fi
549
550 echo -e "\nGeneration done\n"