]> SALOME platform Git repositories - tools/sat.git/blob - commands/compile.py
Salome HOME
fix #8576 #8646
[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 "compilation" in p_info.properties and 
303                                             p_info.properties.compilation == "no"):
304             log_step(logger, header, "ignored")
305             logger.write("\n", 3, False)
306             continue
307
308         # Do nothing if the product is native
309         if src.product.product_is_native(p_info):
310             log_step(logger, header, "native")
311             logger.write("\n", 3, False)
312             continue
313
314         # Clean the build and the install directories 
315         # if the corresponding options was called
316         if options.clean_all:
317             log_step(logger, header, "CLEAN BUILD AND INSTALL ")
318             sat.clean(config.VARS.application + 
319                       " --products " + p_name + 
320                       " --build --install",
321                       batch=True,
322                       verbose=0,
323                       logger_add_link = logger)
324         
325         # Clean the the install directory 
326         # if the corresponding option was called
327         if options.clean_install and not options.clean_all:
328             log_step(logger, header, "CLEAN INSTALL ")
329             sat.clean(config.VARS.application + 
330                       " --products " + p_name + 
331                       " --install",
332                       batch=True,
333                       verbose=0,
334                       logger_add_link = logger)
335         
336         # Recompute the product information to get the right install_dir
337         # (it could change if there is a clean of the install directory)
338         p_info = src.product.get_product_config(config, p_name)
339         
340         # Check if sources was already successfully installed
341         check_source = src.product.check_source(p_info)
342         if not check_source:
343             logger.write(_("Sources of product not found (try 'sat -h prepare')\n"))
344             res += 1 #BUG
345             continue
346         
347         # Check if it was already successfully installed
348         if src.product.check_installation(p_info):
349             logger.write(_("Already installed\n"))
350             continue
351         
352         # If the show option was called, do not launch the compilation
353         if options.no_compile:
354             logger.write(_("Not installed\n"))
355             continue
356         
357         # Check if the dependencies are installed
358         l_depends_not_installed = check_dependencies(config, p_name_info)
359         if len(l_depends_not_installed) > 0:
360             log_step(logger, header, "")
361             logger.write(src.printcolors.printcError(
362                     _("ERROR : the following product(s) is(are) mandatory: ")))
363             for prod_name in l_depends_not_installed:
364                 logger.write(src.printcolors.printcError(prod_name + " "))
365             logger.write("\n")
366             continue
367         
368         # Call the function to compile the product
369         res_prod, len_end_line, error_step = compile_product(
370              sat, p_name_info, config, options, logger, header, len_end_line)
371         
372         if res_prod != 0:
373             res += 1
374             
375             if error_step != "CHECK":
376                 # Clean the install directory if there is any
377                 logger.write(_(
378                             "Cleaning the install directory if there is any\n"),
379                              5)
380                 sat.clean(config.VARS.application + 
381                           " --products " + p_name + 
382                           " --install",
383                           batch=True,
384                           verbose=0,
385                           logger_add_link = logger)
386         else:
387             # Clean the build directory if the compilation and tests succeed
388             if options.clean_build_after:
389                 log_step(logger, header, "CLEAN BUILD")
390                 sat.clean(config.VARS.application + 
391                           " --products " + p_name + 
392                           " --build",
393                           batch=True,
394                           verbose=0,
395                           logger_add_link = logger)
396
397         # Log the result
398         if res_prod > 0:
399             logger.write("\r%s%s" % (header, " " * len_end_line), 3)
400             logger.write("\r" + header + src.printcolors.printcError("KO ") + error_step)
401             logger.write("\n==== %(KO)s in compile of %(name)s \n" %
402                 { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
403             if error_step == "CHECK":
404                 logger.write(_("\nINSTALL directory = %s" % 
405                            src.printcolors.printcInfo(p_info.install_dir)), 3)
406             logger.flush()
407         else:
408             logger.write("\r%s%s" % (header, " " * len_end_line), 3)
409             logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
410             logger.write(_("\nINSTALL directory = %s" % 
411                            src.printcolors.printcInfo(p_info.install_dir)), 3)
412             logger.write("\n==== %s \n" % src.printcolors.printcInfo("OK"), 4)
413             logger.write("\n==== Compilation of %(name)s %(OK)s \n" %
414                 { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
415             logger.flush()
416         logger.write("\n", 3, False)
417         
418         
419         if res_prod != 0 and options.stop_first_fail:
420             break
421         
422     return res
423
424 def compile_product(sat, p_name_info, config, options, logger, header, len_end):
425     '''Execute the proper configuration command(s) 
426        in the product build directory.
427     
428     :param p_name_info tuple: (str, Config) => (product_name, product_info)
429     :param config Config: The global configuration
430     :param logger Logger: The logger instance to use for the display 
431                           and logging
432     :param header Str: the header to display when logging
433     :param len_end Int: the lenght of the the end of line (used in display)
434     :return: 1 if it fails, else 0.
435     :rtype: int
436     '''
437     
438     p_name, p_info = p_name_info
439           
440     # Get the build procedure from the product configuration.
441     # It can be :
442     # build_sources : autotools -> build_configure, configure, make, make install
443     # build_sources : cmake     -> cmake, make, make install
444     # build_sources : script    -> script executions
445     res = 0
446     if (src.product.product_is_autotools(p_info) or 
447                                           src.product.product_is_cmake(p_info)):
448         res, len_end_line, error_step = compile_product_cmake_autotools(sat,
449                                                                   p_name_info,
450                                                                   config,
451                                                                   options,
452                                                                   logger,
453                                                                   header,
454                                                                   len_end)
455     if src.product.product_has_script(p_info):
456         res, len_end_line, error_step = compile_product_script(sat,
457                                                                   p_name_info,
458                                                                   config,
459                                                                   options,
460                                                                   logger,
461                                                                   header,
462                                                                   len_end)
463
464     # Check that the install directory exists
465     if res==0 and not(os.path.exists(p_info.install_dir)):
466         res = 1
467         error_step = "NO INSTALL DIR"
468         msg = _("Error: despite the fact that all the steps ended successfully,"
469                 " no install directory was found !")
470         logger.write(src.printcolors.printcError(msg), 4)
471         logger.write("\n", 4)
472         return res, len_end, error_step
473     
474     # Add the config file corresponding to the dependencies/versions of the 
475     # product that have been successfully compiled
476     if res==0:       
477         logger.write(_("Add the config file in installation directory\n"), 5)
478         add_compile_config_file(p_info, config)
479         
480         if options.check:
481             # Do the unit tests (call the check command)
482             log_step(logger, header, "CHECK")
483             res_check = sat.check(
484                               config.VARS.application + " --products " + p_name,
485                               verbose = 0,
486                               logger_add_link = logger)
487             if res_check != 0:
488                 error_step = "CHECK"
489                 
490             res += res_check
491     
492     return res, len_end_line, error_step
493
494 def compile_product_cmake_autotools(sat,
495                                     p_name_info,
496                                     config,
497                                     options,
498                                     logger,
499                                     header,
500                                     len_end):
501     '''Execute the proper build procedure for autotools or cmake
502        in the product build directory.
503     
504     :param p_name_info tuple: (str, Config) => (product_name, product_info)
505     :param config Config: The global configuration
506     :param logger Logger: The logger instance to use for the display 
507                           and logging
508     :param header Str: the header to display when logging
509     :param len_end Int: the lenght of the the end of line (used in display)
510     :return: 1 if it fails, else 0.
511     :rtype: int
512     '''
513     p_name, p_info = p_name_info
514     
515     # Execute "sat configure", "sat make" and "sat install"
516     res = 0
517     error_step = ""
518     
519     # Logging and sat command call for configure step
520     len_end_line = len_end
521     log_step(logger, header, "CONFIGURE")
522     res_c = sat.configure(config.VARS.application + " --products " + p_name,
523                           verbose = 0,
524                           logger_add_link = logger)
525     log_res_step(logger, res_c)
526     res += res_c
527     
528     if res_c > 0:
529         error_step = "CONFIGURE"
530     else:
531         # Logging and sat command call for make step
532         # Logging take account of the fact that the product has a compilation 
533         # script or not
534         if src.product.product_has_script(p_info):
535             # if the product has a compilation script, 
536             # it is executed during make step
537             scrit_path_display = src.printcolors.printcLabel(
538                                                         p_info.compil_script)
539             log_step(logger, header, "SCRIPT " + scrit_path_display)
540             len_end_line = len(scrit_path_display)
541         else:
542             log_step(logger, header, "MAKE")
543         make_arguments = config.VARS.application + " --products " + p_name
544         # Get the make_flags option if there is any
545         if options.makeflags:
546             make_arguments += " --option -j" + options.makeflags
547         res_m = sat.make(make_arguments,
548                          verbose = 0,
549                          logger_add_link = logger)
550         log_res_step(logger, res_m)
551         res += res_m
552         
553         if res_m > 0:
554             error_step = "MAKE"
555         else: 
556             # Logging and sat command call for make install step
557             log_step(logger, header, "MAKE INSTALL")
558             res_mi = sat.makeinstall(config.VARS.application + 
559                                      " --products " + 
560                                      p_name,
561                                     verbose = 0,
562                                     logger_add_link = logger)
563
564             log_res_step(logger, res_mi)
565             res += res_mi
566             
567             if res_mi > 0:
568                 error_step = "MAKE INSTALL"
569                 
570     return res, len_end_line, error_step 
571
572 def compile_product_script(sat,
573                            p_name_info,
574                            config,
575                            options,
576                            logger,
577                            header,
578                            len_end):
579     '''Execute the script build procedure in the product build directory.
580     
581     :param p_name_info tuple: (str, Config) => (product_name, product_info)
582     :param config Config: The global configuration
583     :param logger Logger: The logger instance to use for the display 
584                           and logging
585     :param header Str: the header to display when logging
586     :param len_end Int: the lenght of the the end of line (used in display)
587     :return: 1 if it fails, else 0.
588     :rtype: int
589     '''
590     p_name, p_info = p_name_info
591     
592     # Execute "sat configure", "sat make" and "sat install"
593     error_step = ""
594     
595     # Logging and sat command call for the script step
596     scrit_path_display = src.printcolors.printcLabel(p_info.compil_script)
597     log_step(logger, header, "SCRIPT " + scrit_path_display)
598     len_end_line = len_end + len(scrit_path_display)
599     res = sat.script(config.VARS.application + " --products " + p_name,
600                      verbose = 0,
601                      logger_add_link = logger)
602     log_res_step(logger, res)
603               
604     return res, len_end_line, error_step 
605
606 def add_compile_config_file(p_info, config):
607     '''Execute the proper configuration command(s) 
608        in the product build directory.
609     
610     :param p_info Config: The specific config of the product
611     :param config Config: The global configuration
612     '''
613     # Create the compile config
614     compile_cfg = src.pyconf.Config()
615     for prod_name in p_info.depend:
616         if prod_name not in compile_cfg:
617             compile_cfg.addMapping(prod_name,
618                                    src.pyconf.Mapping(compile_cfg),
619                                    "")
620         prod_dep_info = src.product.get_product_config(config, prod_name, False)
621         compile_cfg[prod_name] = prod_dep_info.version
622     # Write it in the install directory of the product
623     compile_cfg_path = os.path.join(p_info.install_dir, src.CONFIG_FILENAME)
624     f = open(compile_cfg_path, 'w')
625     compile_cfg.__save__(f)
626     f.close()
627     
628 def description():
629     '''method that is called when salomeTools is called with --help option.
630     
631     :return: The text to display for the compile command description.
632     :rtype: str
633     '''
634     return _("The compile command constructs the products of the application"
635              "\n\nexample:\nsat compile SALOME-master --products KERNEL,GUI,"
636              "MEDCOUPLING --clean_all")
637   
638 def run(args, runner, logger):
639     '''method that is called when salomeTools is called with compile parameter.
640     '''
641     # DBG.write("compile runner.cfg", runner.cfg, True)
642     # Parse the options
643     (options, args) = parser.parse_args(args)
644
645     # Warn the user if he invoked the clean_all option 
646     # without --products option
647     if (options.clean_all and 
648         options.products is None and 
649         not runner.options.batch):
650         rep = input(_("You used --clean_all without specifying a product"
651                           " are you sure you want to continue? [Yes/No] "))
652         if rep.upper() != _("YES").upper():
653             return 0
654         
655     # check that the command has been called with an application
656     src.check_config_has_application( runner.cfg )
657
658     # Print some informations
659     logger.write(_('Executing the compile commands in the build '
660                                 'directories of the products of '
661                                 'the application %s\n') % 
662                 src.printcolors.printcLabel(runner.cfg.VARS.application), 1)
663     
664     info = [
665             (_("SOURCE directory"),
666              os.path.join(runner.cfg.APPLICATION.workdir, 'SOURCES')),
667             (_("BUILD directory"),
668              os.path.join(runner.cfg.APPLICATION.workdir, 'BUILD'))
669             ]
670     src.print_info(logger, info)
671
672     # Get the list of products to treat
673     products_infos = get_products_list(options, runner.cfg, logger)
674
675     if options.fathers:
676         # Extend the list with all recursive dependencies of the given products
677         products_infos = extend_with_fathers(runner.cfg, products_infos)
678
679     if options.children:
680         # Extend the list with all products that use the given products
681         products_infos = extend_with_children(runner.cfg, products_infos)
682
683     # Sort the list regarding the dependencies of the products
684     products_infos = sort_products(runner.cfg, products_infos)
685
686     
687     # Call the function that will loop over all the products and execute
688     # the right command(s)
689     res = compile_all_products(runner, runner.cfg, options, products_infos, logger)
690     
691     # Print the final state
692     nb_products = len(products_infos)
693     if res == 0:
694         final_status = "OK"
695     else:
696         final_status = "KO"
697    
698     logger.write(_("\nCompilation: %(status)s (%(valid_result)d/%(nb_products)d)\n") % \
699         { 'status': src.printcolors.printc(final_status), 
700           'valid_result': nb_products - res,
701           'nb_products': nb_products }, 1)    
702     
703     code = res
704     if code != 0:
705         code = 1
706     return code