]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Adding links to the micro commands in the macro commands
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 30 May 2016 08:28:07 +0000 (10:28 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 30 May 2016 08:28:07 +0000 (10:28 +0200)
commands/compile.py
commands/prepare.py
salomeTools.py

index f48f29d729f669931e8c11866dda4f6a4b332d5e..b1efa73397b6fca91a35b87d7ae49371ebd34ec0 100644 (file)
@@ -173,7 +173,7 @@ def get_recursive_fathers(config, p_name_p_info, without_native_fixed=False):
                 msg = _("The product %(father_name)s that is in %(product_nam"
                         "e)s dependencies is not present in application "
                         "%(appli_name)s" % {"father_name" : father_name, 
-                                    "product_name" : p_name.name
+                                    "product_name" : p_name, 
                                     "appli_name" : config.VARS.application})
                 raise src.SatException(msg)
             prod_info_father = src.product.get_product_config(config,
@@ -191,7 +191,9 @@ def get_recursive_fathers(config, p_name_p_info, without_native_fixed=False):
             l_grand_fathers = get_recursive_fathers(config,
                                 pname_pinfo_father,
                                 without_native_fixed = without_native_fixed)
-            l_fathers += l_grand_fathers
+            for item in l_grand_fathers:
+                if item not in l_fathers:
+                    l_fathers.append(item)
     return l_fathers
 
 def sort_products(config, p_infos):
@@ -291,10 +293,11 @@ def compile_all_products(sat, config, options, products_infos, logger):
         p_name, p_info = p_name_info
         
         # Logging
+        len_end_line = 30
         logger.write("\n", 4, False)
         logger.write("################ ", 4)
         header = _("Compilation of %s") % src.printcolors.printcLabel(p_name)
-        header += " %s " % ("." * (30 - len(p_name)))
+        header += " %s " % ("." * (len_end_line - len(p_name)))
         logger.write(header, 3)
         logger.write("\n", 4, False)
         logger.flush()
@@ -336,15 +339,46 @@ def compile_all_products(sat, config, options, products_infos, logger):
             continue
         
         # Call the function to compile the product
-        res_prod = compile_product(sat, p_name_info, config, options, logger, header)
+        res_prod, len_end_line, error_step = compile_product(sat,
+                                                             p_name_info,
+                                                             config,
+                                                             options,
+                                                             logger,
+                                                             header,
+                                                             len_end_line)
+        
         if res_prod != 0:
+            # Clean the install directory if there is any
+            sat.clean(config.VARS.application + 
+                      " --products " + p_name + 
+                      " --install", batch=True, verbose=0)
             res += 1
-            if options.stop_first_fail:
-                break
             
+        # Log the result
+        if res > 0:
+            logger.write("\r%s%s" % (header, " " * len_end_line), 3)
+            logger.write("\r" + header + src.printcolors.printcError("KO ") + error_step)
+            logger.write("\n==== %(KO)s in compile of %(name)s \n" %
+                { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
+            logger.flush()
+        else:
+            logger.write("\r%s%s" % (header, " " * len_end_line), 3)
+            logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
+            logger.write(_("\nINSTALL directory = %s" % 
+                           src.printcolors.printcInfo(p_info.install_dir)), 3)
+            logger.write("\n==== %s \n" % src.printcolors.printcInfo("OK"), 4)
+            logger.write("\n==== Compilation of %(name)s %(OK)s \n" %
+                { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
+            logger.flush()
+        logger.write("\n", 3, False)
+        
+        
+        if res_prod != 0 and options.stop_first_fail:
+            break
+        
     return res
 
-def compile_product(sat, p_name_info, config, options, logger, header):
+def compile_product(sat, p_name_info, config, options, logger, header, len_end):
     '''Execute the proper configuration command(s) 
        in the product build directory.
     
@@ -359,62 +393,61 @@ def compile_product(sat, p_name_info, config, options, logger, header):
     p_name, p_info = p_name_info
        
     # Execute "sat configure", "sat make" and "sat install"
-    len_end_line = 30
     res = 0
+    error_step = ""
     
-    # Logging and sat command call for configure step 
+    # Logging and sat command call for configure step
+    len_end_line = len_end
     log_step(logger, header, "CONFIGURE")
-    res_c = sat.configure(config.VARS.application + " --products " + p_name,
-                          verbose = 0)
+    res_c, __ = sat.configure(config.VARS.application + " --products " + p_name,
+                          verbose = 0,
+                          logger_add_link = logger)
     log_res_step(logger, res_c)
     res += res_c
     
-    # Logging and sat command call for make step
-    # Logging take account of the fact that the product has a compilation 
-    # script or not
-    if src.product.product_has_script(p_info):
-        # if the product has a compilation script, 
-        # it is executed during make step
-        scrit_path_display = src.printcolors.printcLabel(p_info.compil_script)
-        log_step(logger, header, "SCRIPT " + scrit_path_display)
-        len_end_line = len(scrit_path_display)
-    else:
-        log_step(logger, header, "MAKE")
-    make_arguments = config.VARS.application + " --products " + p_name
-    # Get the make_flags option if there is any
-    if options.makeflags:
-        make_arguments += " --option -j" + options.makeflags
-    res_c = sat.make(make_arguments,
-                     verbose = 0)
-    log_res_step(logger, res_c)
-    res += res_c
+    if res_c > 0:
+        error_step = "CONFIGURE"
+    else:    
+        # Logging and sat command call for make step
+        # Logging take account of the fact that the product has a compilation 
+        # script or not
+        if src.product.product_has_script(p_info):
+            # if the product has a compilation script, 
+            # it is executed during make step
+            scrit_path_display = src.printcolors.printcLabel(
+                                                        p_info.compil_script)
+            log_step(logger, header, "SCRIPT " + scrit_path_display)
+            len_end_line = len(scrit_path_display)
+        else:
+            log_step(logger, header, "MAKE")
+        make_arguments = config.VARS.application + " --products " + p_name
+        # Get the make_flags option if there is any
+        if options.makeflags:
+            make_arguments += " --option -j" + options.makeflags
+        res_m, __ = sat.make(make_arguments,
+                         verbose = 0,
+                         logger_add_link = logger)
+        log_res_step(logger, res_m)
+        res += res_m
+        
+        if res_m > 0:
+            error_step = "MAKE"
+        else: 
+            # Logging and sat command call for make install step
+            log_step(logger, header, "MAKE INSTALL")
+            res_mi, __ = sat.makeinstall(config.VARS.application + 
+                                     " --products " + 
+                                     p_name,
+                                    verbose = 0,
+                                    logger_add_link = logger)
 
-    # Logging and sat command call for make install step
-    log_step(logger, header, "MAKE INSTALL")
-    res_c = sat.makeinstall(config.VARS.application + " --products " + p_name,
-                            verbose = 0)
-    log_res_step(logger, res_c)
-    res += res_c
-    
-    # Log the result
-    if res > 0:
-        logger.write("\r%s%s" % (header, " " * len_end_line), 3)
-        logger.write("\r" + header + src.printcolors.printcError("KO"))
-        logger.write("\n==== %(KO)s in compile of %(name)s \n" %
-            { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
-        logger.flush()
-    else:
-        logger.write("\r%s%s" % (header, " " * len_end_line), 3)
-        logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
-        logger.write(_("\nINSTALL directory = %s" % 
-                       src.printcolors.printcInfo(p_info.install_dir)), 3)
-        logger.write("\n==== %s \n" % src.printcolors.printcInfo("OK"), 4)
-        logger.write("\n==== Compilation of %(name)s %(OK)s \n" %
-            { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
-        logger.flush()
-    logger.write("\n", 3, False)
+            log_res_step(logger, res_mi)
+            res += res_mi
+            
+            if res_m > 0:
+                error_step = "MAKE INSTALL"
 
-    return res
+    return res, len_end_line, error_step
 
 def description():
     '''method that is called when salomeTools is called with --help option.
index 7e18a2faf6441affb67ed21630d95b84d5ab2515..8930ac94c1162847eab2745dbcd4463125091f27 100644 (file)
@@ -157,12 +157,29 @@ def run(args, runner, logger):
     if do_clean:
         msg = _("Clean the source directories ...")
         logger.write(msg, 3)
-        res_clean = runner.clean(args_clean, batch=True, verbose = 0)
+        res_clean, __ = runner.clean(args_clean, batch=True, verbose = 0,
+                                    logger_add_link = logger)
         if res_clean == 0:
-            logger.write('%s\n\n' % src.printcolors.printc(src.OK_STATUS), 3)
+            logger.write('%s\n' % src.printcolors.printc(src.OK_STATUS), 3)
+        else:
+            logger.write('%s\n' % src.printcolors.printc(src.KO_STATUS), 3)
     if do_source:
-        res_source = runner.source(args_source)
+        msg = _("Get the sources of the products ...")
+        logger.write(msg, 5)
+        res_source, __ = runner.source(args_source,
+                                    logger_add_link = logger)
+        if res_source == 0:
+            logger.write('%s\n' % src.printcolors.printc(src.OK_STATUS), 5)
+        else:
+            logger.write('%s\n' % src.printcolors.printc(src.KO_STATUS), 5)
     if do_patch:
-        res_patch = runner.patch(args_patch)
+        msg = _("Patch the product sources (if any) ...")
+        logger.write(msg, 5)
+        res_patch, __ = runner.patch(args_patch,
+                                    logger_add_link = logger)
+        if res_patch == 0:
+            logger.write('%s\n' % src.printcolors.printc(src.OK_STATUS), 5)
+        else:
+            logger.write('%s\n' % src.printcolors.printc(src.KO_STATUS), 5)
     
     return res_clean + res_source + res_patch
\ No newline at end of file
index 618294b2b3636877d6da192a1199c61c1e26eaf0..1f28c7a55f1c713cafbdfad029a76d78a830b675 100755 (executable)
@@ -141,7 +141,7 @@ class Sat(object):
             (file_, pathname, description) = imp.find_module(nameCmd, [dirPath])
             module = imp.load_module(nameCmd, file_, pathname, description)
             
-            def run_command(args='', batch = False, verbose = -1):
+            def run_command(args='', batch = False, verbose = -1, logger_add_link = None):
                 '''The function that will load the configuration (all pyconf)
                 and return the function run of the command corresponding to module
                 
@@ -191,6 +191,9 @@ class Sat(object):
                                                    silent_sysstd=silent,
                                                    all_in_terminal=self.options.all_in_terminal)
                 
+                if logger_add_link is not None:
+                    logger_add_link.xmlFile.append_node_attrib("Links", attrib={__nameCmd__ : logger_command.logFilePath})
+                
                 try:
                     # Execute the hooks (if there is any) 
                     # and run method of the command
@@ -219,7 +222,7 @@ class Sat(object):
                                                 args])
                     logger_command.end_write({"launchedCommand" : launchedCommand})
                 
-                return res
+                return res, logger_command.logFilePath
 
             # Make sure that run_command will be redefined 
             # at each iteration of the loop
@@ -407,5 +410,5 @@ if __name__ == "__main__":
     
     # exit salomeTools with the right code (0 if no errors, else 1)
     if code is None: code = 0
-    sys.exit(code)
+    sys.exit(code[0])
         
\ No newline at end of file