Salome HOME
sat #11028 dependance au module CONFIGURATION - remove also obsolete function in...
[tools/sat.git] / commands / compile.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 import os
20
21 import src
22 import src.debug as DBG
23
24 # Compatibility python 2/3 for input function
25 # input stays input for python 3 and input = raw_input for python 2
26 try: 
27     input = raw_input
28 except NameError: 
29     pass
30
31 # Define all possible option for the compile command :  sat compile <options>
32 parser = src.options.Options()
33 parser.add_option('p', 'products', 'list2', 'products',
34     _('Optional: products to compile. This option can be'
35     ' passed several time to compile several products.'))
36 parser.add_option('', 'with_fathers', 'boolean', 'fathers',
37     _("Optional: build all necessary products to the given product (KERNEL is "
38       "build before building GUI)."), False)
39 parser.add_option('', 'with_children', 'boolean', 'children',
40     _("Optional: build all products using the given product (all SMESH plugins"
41       " are build after SMESH)."), False)
42 parser.add_option('', 'clean_all', 'boolean', 'clean_all',
43     _("Optional: clean BUILD dir and INSTALL dir before building product."),
44     False)
45 parser.add_option('', 'clean_install', 'boolean', 'clean_install',
46     _("Optional: clean INSTALL dir before building product."), False)
47 parser.add_option('', 'make_flags', 'string', 'makeflags',
48     _("Optional: add extra options to the 'make' command."))
49 parser.add_option('', 'show', 'boolean', 'no_compile',
50     _("Optional: DO NOT COMPILE just show if products are installed or not."),
51     False)
52 parser.add_option('', 'stop_first_fail', 'boolean', 'stop_first_fail', _(
53                   "Optional: Stops the command at first product compilation"
54                   " fail."), False)
55 parser.add_option('', 'check', 'boolean', 'check', _(
56                   "Optional: execute the unit tests after compilation"), False)
57
58 parser.add_option('', 'clean_build_after', 'boolean', 'clean_build_after', 
59                   _('Optional: remove the build directory after successful compilation'), False)
60
61 def get_products_list(options, cfg, logger):
62     '''method that gives the product list with their informations from 
63        configuration regarding the passed options.
64     
65     :param options Options: The Options instance that stores the commands 
66                             arguments
67     :param cfg Config: The global configuration
68     :param logger Logger: The logger instance to use for the display and 
69                           logging
70     :return: The list of (product name, product_informations).
71     :rtype: List
72     '''
73     # Get the products to be prepared, regarding the options
74     if options.products is None:
75         # No options, get all products sources
76         products = cfg.APPLICATION.products
77     else:
78         # if option --products, check that all products of the command line
79         # are present in the application.
80         products = options.products
81         for p in products:
82             if p not in cfg.APPLICATION.products:
83                 raise src.SatException(_("Product %(product)s "
84                             "not defined in application %(application)s") %
85                         { 'product': p, 'application': cfg.VARS.application} )
86     
87     # Construct the list of tuple containing 
88     # the products name and their definition
89     products_infos = src.product.get_products_infos(products, cfg)
90     
91     products_infos = [pi for pi in products_infos if not(
92                                      src.product.product_is_fixed(pi[1]))]
93     
94     return products_infos
95
96 def get_children(config, p_name_p_info):
97     l_res = []
98     p_name, __ = p_name_p_info
99     # Get all products of the application
100     products = config.APPLICATION.products
101     products_infos = src.product.get_products_infos(products, config)
102     for p_name_potential_child, p_info_potential_child in products_infos:
103         if ("depend" in p_info_potential_child and 
104                 p_name in p_info_potential_child.depend):
105             l_res.append(p_name_potential_child)
106     return l_res
107
108 def get_recursive_children(config, p_name_p_info, without_native_fixed=False):
109     """ Get the recursive list of the product that depend on 
110         the product defined by prod_info
111     
112     :param config Config: The global configuration
113     :param prod_info Config: The specific config of the product
114     :param without_native_fixed boolean: If true, do not include the fixed
115                                          or native products in the result
116     :return: The list of product_informations.
117     :rtype: List
118     """
119     p_name, __ = p_name_p_info
120     # Initialization of the resulting list
121     l_children = []
122     
123     # Get the direct children (not recursive)
124     l_direct_children = get_children(config, p_name_p_info)
125     # Minimal case : no child
126     if l_direct_children == []:
127         return []
128     # Add the children and call the function to get the children of the
129     # children
130     for child_name in l_direct_children:
131         l_children_name = [pn_pi[0] for pn_pi in l_children]
132         if child_name not in l_children_name:
133             if child_name not in config.APPLICATION.products:
134                 msg = _("The product %(child_name)s that is in %(product_nam"
135                         "e)s children is not present in application "
136                         "%(appli_name)s" % {"child_name" : child_name, 
137                                     "product_name" : p_name.name, 
138                                     "appli_name" : config.VARS.application})
139                 raise src.SatException(msg)
140             prod_info_child = src.product.get_product_config(config,
141                                                               child_name)
142             pname_pinfo_child = (prod_info_child.name, prod_info_child)
143             # Do not append the child if it is native or fixed and 
144             # the corresponding parameter is called
145             if without_native_fixed:
146                 if not(src.product.product_is_native(prod_info_child) or 
147                        src.product.product_is_fixed(prod_info_child)):
148                     l_children.append(pname_pinfo_child)
149             else:
150                 l_children.append(pname_pinfo_child)
151             # Get the children of the children
152             l_grand_children = get_recursive_children(config,
153                                 pname_pinfo_child,
154                                 without_native_fixed = without_native_fixed)
155             l_children += l_grand_children
156     return l_children
157
158 def get_recursive_fathers(config, p_name_p_info, without_native_fixed=False):
159     """ Get the recursive list of the dependencies of the product defined by
160         prod_info
161     
162     :param config Config: The global configuration
163     :param prod_info Config: The specific config of the product
164     :param without_native_fixed boolean: If true, do not include the fixed
165                                          or native products in the result
166     :return: The list of product_informations.
167     :rtype: List
168     """
169     p_name, p_info = p_name_p_info
170     # Initialization of the resulting list
171     l_fathers = []
172     # Minimal case : no dependencies
173     if "depend" not in p_info or p_info.depend == []:
174         return []
175     # Add the dependencies and call the function to get the dependencies of the
176     # dependencies
177     for father_name in p_info.depend:
178         l_fathers_name = [pn_pi[0] for pn_pi in l_fathers]
179         if father_name not in l_fathers_name:
180             if father_name not in config.APPLICATION.products:
181                 msg = _("The product %(father_name)s that is in %(product_nam"
182                         "e)s dependencies is not present in application "
183                         "%(appli_name)s" % {"father_name" : father_name, 
184                                     "product_name" : p_name, 
185                                     "appli_name" : config.VARS.application})
186                 raise src.SatException(msg)
187             prod_info_father = src.product.get_product_config(config,
188                                                               father_name)
189             pname_pinfo_father = (prod_info_father.name, prod_info_father)
190             # Do not append the father if it is native or fixed and 
191             # the corresponding parameter is called
192             if without_native_fixed:
193                 if not(src.product.product_is_native(prod_info_father) or 
194                        src.product.product_is_fixed(prod_info_father)):
195                     l_fathers.append(pname_pinfo_father)
196             else:
197                 l_fathers.append(pname_pinfo_father)
198             # Get the dependencies of the dependency
199             l_grand_fathers = get_recursive_fathers(config,
200                                 pname_pinfo_father,
201                                 without_native_fixed = without_native_fixed)
202             for item in l_grand_fathers:
203                 if item not in l_fathers:
204                     l_fathers.append(item)
205     return l_fathers
206
207 def sort_products(config, p_infos):
208     """ Sort the p_infos regarding the dependencies between the products
209     
210     :param config Config: The global configuration
211     :param p_infos list: List of (str, Config) => (product_name, product_info)
212     """
213     l_prod_sorted = src.deepcopy_list(p_infos)
214     for prod in p_infos:
215         l_fathers = get_recursive_fathers(config,
216                                           prod,
217                                           without_native_fixed=True)
218         l_fathers = [father for father in l_fathers if father in p_infos]
219         if l_fathers == []:
220             continue
221         for p_sorted in l_prod_sorted:
222             if p_sorted in l_fathers:
223                 l_fathers.remove(p_sorted)
224             if l_fathers==[]:
225                 l_prod_sorted.remove(prod)
226                 l_prod_sorted.insert(l_prod_sorted.index(p_sorted)+1, prod)
227                 break
228         
229     return l_prod_sorted
230
231 def extend_with_fathers(config, p_infos):
232     p_infos_res = src.deepcopy_list(p_infos)
233     for p_name_p_info in p_infos:
234         fathers = get_recursive_fathers(config,
235                                         p_name_p_info,
236                                         without_native_fixed=True)
237         for p_name_p_info_father in fathers:
238             if p_name_p_info_father not in p_infos_res:
239                 p_infos_res.append(p_name_p_info_father)
240     return p_infos_res
241
242 def extend_with_children(config, p_infos):
243     p_infos_res = src.deepcopy_list(p_infos)
244     for p_name_p_info in p_infos:
245         children = get_recursive_children(config,
246                                         p_name_p_info,
247                                         without_native_fixed=True)
248         for p_name_p_info_child in children:
249             if p_name_p_info_child not in p_infos_res:
250                 p_infos_res.append(p_name_p_info_child)
251     return p_infos_res    
252
253 def check_dependencies(config, p_name_p_info):
254     l_depends_not_installed = []
255     fathers = get_recursive_fathers(config, p_name_p_info, without_native_fixed=True)
256     for p_name_father, p_info_father in fathers:
257         if not(src.product.check_installation(p_info_father)):
258             l_depends_not_installed.append(p_name_father)
259     return l_depends_not_installed
260
261 def log_step(logger, header, step):
262     logger.write("\r%s%s" % (header, " " * 30), 3)
263     logger.write("\r%s%s" % (header, step), 3)
264     logger.write("\n==== %s \n" % src.printcolors.printcInfo(step), 4)
265     logger.flush()
266
267 def log_res_step(logger, res):
268     if res == 0:
269         logger.write("%s \n" % src.printcolors.printcSuccess("OK"), 4)
270         logger.flush()
271     else:
272         logger.write("%s \n" % src.printcolors.printcError("KO"), 4)
273         logger.flush()
274
275 def compile_all_products(sat, config, options, products_infos, logger):
276     '''Execute the proper configuration commands 
277        in each product build directory.
278
279     :param config Config: The global configuration
280     :param products_info list: List of 
281                                  (str, Config) => (product_name, product_info)
282     :param logger Logger: The logger instance to use for the display and logging
283     :return: the number of failing commands.
284     :rtype: int
285     '''
286     res = 0
287     for p_name_info in products_infos:
288         
289         p_name, p_info = p_name_info
290         
291         # Logging
292         len_end_line = 30
293         logger.write("\n", 4, False)
294         logger.write("################ ", 4)
295         header = _("Compilation of %s") % src.printcolors.printcLabel(p_name)
296         header += " %s " % ("." * (len_end_line - len(p_name)))
297         logger.write(header, 3)
298         logger.write("\n", 4, False)
299         logger.flush()
300
301         # Do nothing if the product is not compilable
302         if ("properties" in p_info and
303             "compilation" in p_info.properties and
304             p_info.properties.compilation == "no"):
305
306             log_step(logger, header, "ignored")
307             logger.write("\n", 3, False)
308             continue
309
310         # Do nothing if the product is native
311         if src.product.product_is_native(p_info):
312             log_step(logger, header, "native")
313             logger.write("\n", 3, False)
314             continue
315
316         # Clean the build and the install directories 
317         # if the corresponding options was called
318         if options.clean_all:
319             log_step(logger, header, "CLEAN BUILD AND INSTALL ")
320             sat.clean(config.VARS.application + 
321                       " --products " + p_name + 
322                       " --build --install",
323                       batch=True,
324                       verbose=0,
325                       logger_add_link = logger)
326         
327         # Clean the the install directory 
328         # if the corresponding option was called
329         if options.clean_install and not options.clean_all:
330             log_step(logger, header, "CLEAN INSTALL ")
331             sat.clean(config.VARS.application + 
332                       " --products " + p_name + 
333                       " --install",
334                       batch=True,
335                       verbose=0,
336                       logger_add_link = logger)
337         
338         # Recompute the product information to get the right install_dir
339         # (it could change if there is a clean of the install directory)
340         p_info = src.product.get_product_config(config, p_name)
341         
342         # Check if sources was already successfully installed
343         check_source = src.product.check_source(p_info)
344         if not check_source:
345             logger.write(_("Sources of product not found (try 'sat -h prepare') "))
346             res += 1 #BUG
347             continue
348         
349         if src.product.product_is_salome(p_info):
350             # For salome modules, we check if the sources of configuration modules are present
351             # configuration modules have the property "configure_dependency"
352
353             # get the list of all modules in application 
354             all_products_infos = src.product.get_products_infos(config.APPLICATION.products,
355                                                                 config)
356             check_source = True
357             # for configuration modules, check if sources are present
358             for product_name, product_info in all_products_infos:
359                 if ("properties" in product_info and
360                     "configure_dependency" in product_info.properties and
361                     product_info.properties.configure_dependency == "yes"):
362                     check_source = check_source and src.product.check_source(product_info)
363                     if not check_source:
364                         logger.write(_("\nERROR : SOURCES of %s not found! It is required for" 
365                                        " the configuration\n" % product_name))
366                         logger.write(_("        Get it with the command : sat prepare %s -p %s \n" % 
367                                       (config.APPLICATION.name, product_name)))
368             if not check_source:
369                 # if at least one configuration module is not present, we stop compilation
370                 res += 1
371                 continue
372         
373         # Check if it was already successfully installed
374         if src.product.check_installation(p_info):
375             logger.write(_("Already installed\n"))
376             continue
377         
378         # If the show option was called, do not launch the compilation
379         if options.no_compile:
380             logger.write(_("Not installed\n"))
381             continue
382         
383         # Check if the dependencies are installed
384         l_depends_not_installed = check_dependencies(config, p_name_info)
385         if len(l_depends_not_installed) > 0:
386             log_step(logger, header, "")
387             logger.write(src.printcolors.printcError(
388                     _("ERROR : the following product(s) is(are) mandatory: ")))
389             for prod_name in l_depends_not_installed:
390                 logger.write(src.printcolors.printcError(prod_name + " "))
391             logger.write("\n")
392             continue
393         
394         # Call the function to compile the product
395         res_prod, len_end_line, error_step = compile_product(
396              sat, p_name_info, config, options, logger, header, len_end_line)
397         
398         if res_prod != 0:
399             res += 1
400             
401             if error_step != "CHECK":
402                 # Clean the install directory if there is any
403                 logger.write(_(
404                             "Cleaning the install directory if there is any\n"),
405                              5)
406                 sat.clean(config.VARS.application + 
407                           " --products " + p_name + 
408                           " --install",
409                           batch=True,
410                           verbose=0,
411                           logger_add_link = logger)
412         else:
413             # Clean the build directory if the compilation and tests succeed
414             if options.clean_build_after:
415                 log_step(logger, header, "CLEAN BUILD")
416                 sat.clean(config.VARS.application + 
417                           " --products " + p_name + 
418                           " --build",
419                           batch=True,
420                           verbose=0,
421                           logger_add_link = logger)
422
423         # Log the result
424         if res_prod > 0:
425             logger.write("\r%s%s" % (header, " " * len_end_line), 3)
426             logger.write("\r" + header + src.printcolors.printcError("KO ") + error_step)
427             logger.write("\n==== %(KO)s in compile of %(name)s \n" %
428                 { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
429             if error_step == "CHECK":
430                 logger.write(_("\nINSTALL directory = %s" % 
431                            src.printcolors.printcInfo(p_info.install_dir)), 3)
432             logger.flush()
433         else:
434             logger.write("\r%s%s" % (header, " " * len_end_line), 3)
435             logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
436             logger.write(_("\nINSTALL directory = %s" % 
437                            src.printcolors.printcInfo(p_info.install_dir)), 3)
438             logger.write("\n==== %s \n" % src.printcolors.printcInfo("OK"), 4)
439             logger.write("\n==== Compilation of %(name)s %(OK)s \n" %
440                 { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
441             logger.flush()
442         logger.write("\n", 3, False)
443         
444         
445         if res_prod != 0 and options.stop_first_fail:
446             break
447         
448     return res
449
450 def compile_product(sat, p_name_info, config, options, logger, header, len_end):
451     '''Execute the proper configuration command(s) 
452        in the product build directory.
453     
454     :param p_name_info tuple: (str, Config) => (product_name, product_info)
455     :param config Config: The global configuration
456     :param logger Logger: The logger instance to use for the display 
457                           and logging
458     :param header Str: the header to display when logging
459     :param len_end Int: the lenght of the the end of line (used in display)
460     :return: 1 if it fails, else 0.
461     :rtype: int
462     '''
463     
464     p_name, p_info = p_name_info
465           
466     # Get the build procedure from the product configuration.
467     # It can be :
468     # build_sources : autotools -> build_configure, configure, make, make install
469     # build_sources : cmake     -> cmake, make, make install
470     # build_sources : script    -> script executions
471     res = 0
472     if (src.product.product_is_autotools(p_info) or 
473                                           src.product.product_is_cmake(p_info)):
474         res, len_end_line, error_step = compile_product_cmake_autotools(sat,
475                                                                   p_name_info,
476                                                                   config,
477                                                                   options,
478                                                                   logger,
479                                                                   header,
480                                                                   len_end)
481     if src.product.product_has_script(p_info):
482         res, len_end_line, error_step = compile_product_script(sat,
483                                                                   p_name_info,
484                                                                   config,
485                                                                   options,
486                                                                   logger,
487                                                                   header,
488                                                                   len_end)
489
490     # Check that the install directory exists
491     if res==0 and not(os.path.exists(p_info.install_dir)):
492         res = 1
493         error_step = "NO INSTALL DIR"
494         msg = _("Error: despite the fact that all the steps ended successfully,"
495                 " no install directory was found !")
496         logger.write(src.printcolors.printcError(msg), 4)
497         logger.write("\n", 4)
498         return res, len_end, error_step
499     
500     # Add the config file corresponding to the dependencies/versions of the 
501     # product that have been successfully compiled
502     if res==0:       
503         logger.write(_("Add the config file in installation directory\n"), 5)
504         add_compile_config_file(p_info, config)
505         
506         if options.check:
507             # Do the unit tests (call the check command)
508             log_step(logger, header, "CHECK")
509             res_check = sat.check(
510                               config.VARS.application + " --products " + p_name,
511                               verbose = 0,
512                               logger_add_link = logger)
513             if res_check != 0:
514                 error_step = "CHECK"
515                 
516             res += res_check
517     
518     return res, len_end_line, error_step
519
520 def compile_product_cmake_autotools(sat,
521                                     p_name_info,
522                                     config,
523                                     options,
524                                     logger,
525                                     header,
526                                     len_end):
527     '''Execute the proper build procedure for autotools or cmake
528        in the product build directory.
529     
530     :param p_name_info tuple: (str, Config) => (product_name, product_info)
531     :param config Config: The global configuration
532     :param logger Logger: The logger instance to use for the display 
533                           and logging
534     :param header Str: the header to display when logging
535     :param len_end Int: the lenght of the the end of line (used in display)
536     :return: 1 if it fails, else 0.
537     :rtype: int
538     '''
539     p_name, p_info = p_name_info
540     
541     # Execute "sat configure", "sat make" and "sat install"
542     res = 0
543     error_step = ""
544     
545     # Logging and sat command call for configure step
546     len_end_line = len_end
547     log_step(logger, header, "CONFIGURE")
548     res_c = sat.configure(config.VARS.application + " --products " + p_name,
549                           verbose = 0,
550                           logger_add_link = logger)
551     log_res_step(logger, res_c)
552     res += res_c
553     
554     if res_c > 0:
555         error_step = "CONFIGURE"
556     else:
557         # Logging and sat command call for make step
558         # Logging take account of the fact that the product has a compilation 
559         # script or not
560         if src.product.product_has_script(p_info):
561             # if the product has a compilation script, 
562             # it is executed during make step
563             scrit_path_display = src.printcolors.printcLabel(
564                                                         p_info.compil_script)
565             log_step(logger, header, "SCRIPT " + scrit_path_display)
566             len_end_line = len(scrit_path_display)
567         else:
568             log_step(logger, header, "MAKE")
569         make_arguments = config.VARS.application + " --products " + p_name
570         # Get the make_flags option if there is any
571         if options.makeflags:
572             make_arguments += " --option -j" + options.makeflags
573         res_m = sat.make(make_arguments,
574                          verbose = 0,
575                          logger_add_link = logger)
576         log_res_step(logger, res_m)
577         res += res_m
578         
579         if res_m > 0:
580             error_step = "MAKE"
581         else: 
582             # Logging and sat command call for make install step
583             log_step(logger, header, "MAKE INSTALL")
584             res_mi = sat.makeinstall(config.VARS.application + 
585                                      " --products " + 
586                                      p_name,
587                                     verbose = 0,
588                                     logger_add_link = logger)
589
590             log_res_step(logger, res_mi)
591             res += res_mi
592             
593             if res_mi > 0:
594                 error_step = "MAKE INSTALL"
595                 
596     return res, len_end_line, error_step 
597
598 def compile_product_script(sat,
599                            p_name_info,
600                            config,
601                            options,
602                            logger,
603                            header,
604                            len_end):
605     '''Execute the script build procedure in the product build directory.
606     
607     :param p_name_info tuple: (str, Config) => (product_name, product_info)
608     :param config Config: The global configuration
609     :param logger Logger: The logger instance to use for the display 
610                           and logging
611     :param header Str: the header to display when logging
612     :param len_end Int: the lenght of the the end of line (used in display)
613     :return: 1 if it fails, else 0.
614     :rtype: int
615     '''
616     p_name, p_info = p_name_info
617     
618     # Execute "sat configure", "sat make" and "sat install"
619     error_step = ""
620     
621     # Logging and sat command call for the script step
622     scrit_path_display = src.printcolors.printcLabel(p_info.compil_script)
623     log_step(logger, header, "SCRIPT " + scrit_path_display)
624     len_end_line = len_end + len(scrit_path_display)
625     res = sat.script(config.VARS.application + " --products " + p_name,
626                      verbose = 0,
627                      logger_add_link = logger)
628     log_res_step(logger, res)
629               
630     return res, len_end_line, error_step 
631
632 def add_compile_config_file(p_info, config):
633     '''Execute the proper configuration command(s) 
634        in the product build directory.
635     
636     :param p_info Config: The specific config of the product
637     :param config Config: The global configuration
638     '''
639     # Create the compile config
640     compile_cfg = src.pyconf.Config()
641     for prod_name in p_info.depend:
642         if prod_name not in compile_cfg:
643             compile_cfg.addMapping(prod_name,
644                                    src.pyconf.Mapping(compile_cfg),
645                                    "")
646         prod_dep_info = src.product.get_product_config(config, prod_name, False)
647         compile_cfg[prod_name] = prod_dep_info.version
648     # Write it in the install directory of the product
649     compile_cfg_path = os.path.join(p_info.install_dir, src.CONFIG_FILENAME)
650     f = open(compile_cfg_path, 'w')
651     compile_cfg.__save__(f)
652     f.close()
653     
654 def description():
655     '''method that is called when salomeTools is called with --help option.
656     
657     :return: The text to display for the compile command description.
658     :rtype: str
659     '''
660     return _("The compile command constructs the products of the application"
661              "\n\nexample:\nsat compile SALOME-master --products KERNEL,GUI,"
662              "MEDCOUPLING --clean_all")
663   
664 def run(args, runner, logger):
665     '''method that is called when salomeTools is called with compile parameter.
666     '''
667     # DBG.write("compile runner.cfg", runner.cfg, True)
668     # Parse the options
669     (options, args) = parser.parse_args(args)
670
671     # Warn the user if he invoked the clean_all option 
672     # without --products option
673     if (options.clean_all and 
674         options.products is None and 
675         not runner.options.batch):
676         rep = input(_("You used --clean_all without specifying a product"
677                           " are you sure you want to continue? [Yes/No] "))
678         if rep.upper() != _("YES").upper():
679             return 0
680         
681     # check that the command has been called with an application
682     src.check_config_has_application( runner.cfg )
683
684     # Print some informations
685     logger.write(_('Executing the compile commands in the build '
686                                 'directories of the products of '
687                                 'the application %s\n') % 
688                 src.printcolors.printcLabel(runner.cfg.VARS.application), 1)
689     
690     info = [
691             (_("SOURCE directory"),
692              os.path.join(runner.cfg.APPLICATION.workdir, 'SOURCES')),
693             (_("BUILD directory"),
694              os.path.join(runner.cfg.APPLICATION.workdir, 'BUILD'))
695             ]
696     src.print_info(logger, info)
697
698     # Get the list of products to treat
699     products_infos = get_products_list(options, runner.cfg, logger)
700
701     if options.fathers:
702         # Extend the list with all recursive dependencies of the given products
703         products_infos = extend_with_fathers(runner.cfg, products_infos)
704
705     if options.children:
706         # Extend the list with all products that use the given products
707         products_infos = extend_with_children(runner.cfg, products_infos)
708
709     # Sort the list regarding the dependencies of the products
710     products_infos = sort_products(runner.cfg, products_infos)
711
712     
713     # Call the function that will loop over all the products and execute
714     # the right command(s)
715     res = compile_all_products(runner, runner.cfg, options, products_infos, logger)
716     
717     # Print the final state
718     nb_products = len(products_infos)
719     if res == 0:
720         final_status = "OK"
721     else:
722         final_status = "KO"
723    
724     logger.write(_("\nCompilation: %(status)s (%(valid_result)d/%(nb_products)d)\n") % \
725         { 'status': src.printcolors.printc(final_status), 
726           'valid_result': nb_products - res,
727           'nb_products': nb_products }, 1)    
728     
729     code = res
730     if code != 0:
731         code = 1
732     return code