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