Salome HOME
decode pip version
[tools/sat.git] / commands / script.py
index bd2ee408435280b1fd7fb3aa75757f8a7dde9767..824a1331b20fc139ee661b600cf6fb15edbf6523 100644 (file)
@@ -23,13 +23,11 @@ import src
 # Define all possible option for the script command :  sat script <options>
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
-    _('Optional: products to configure. This option can be'
-    ' passed several time to configure several products.'))
+    _('Optional: products to configure. This option accepts a comma separated list.'))
 parser.add_option('', 'nb_proc', 'int', 'nb_proc',
-    _('Optional: The number of processors to use in the script if the make '
-      'command is used in it.\n\tWarning: the script has to be correctly written '
-      'if you want this option to work.\n\tThe $MAKE_OPTIONS has to be '
-      'used.'), 0)
+    _("""Optional: The number of processors to use in the script if the make command is used in it.
+      Warning: the script has to be correctly written if you want this option to work.
+      The $MAKE_OPTIONS has to be used."""), 0)
 
 
 def log_step(logger, header, step):
@@ -99,9 +97,16 @@ def run_script_of_product(p_name_info, nb_proc, config, logger):
         logger.write("\n", 3, False)
         return 0
 
+    if not os.path.isfile(p_info.compil_script):
+        msg_err="\n\nError : The compilation script file do not exists!"+\
+                "\n        It was not found by sat!"+\
+                "\n        Please check your salomeTool configuration\n"
+        logger.error(msg_err)
+        return 1
+
     # Instantiate the class that manages all the construction commands
     # like cmake, make, make install, make test, environment management, etc...
-    builder = src.compilation.Builder(config, logger, p_info)
+    builder = src.compilation.Builder(config, logger, p_name, p_info)
     
     # Prepare the environment
     log_step(logger, header, "PREPARE ENV")
@@ -122,15 +127,32 @@ def run_script_of_product(p_name_info, nb_proc, config, logger):
         logger.write("\r" + header + src.printcolors.printcError("KO"))
         logger.write("==== %(KO)s in script execution of %(name)s \n" %
             { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
+        logger.write("\n", 3, False)
         logger.flush()
-    else:
-        logger.write("\r%s%s" % (header, " " * len_end_line), 3)
-        logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
-        logger.write("==== %s \n" % src.printcolors.printcInfo("OK"), 4)
-        logger.write("==== Script execution of %(name)s %(OK)s \n" %
-            { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
-        logger.flush()
+        return res
+
+    if src.product.product_has_post_script(p_info):
+        # the product has a post install script we run
+        #script_path_display = src.printcolors.printcLabel(p_info.p_info.post_script)
+        #log_step(logger, header, "POST SCRIPT " + script_path_display)
+        res = builder.do_script_build(p_info.post_script)
+        #log_res_step(logger, res)
+        if res > 0:
+            logger.write("\r%s%s" % (header, " " * len_end_line), 3)
+            logger.write("\r" + header + src.printcolors.printcError("KO"))
+            logger.write("==== %(KO)s in post script execution of %(name)s \n" %
+                { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
+            logger.write("\n", 3, False)
+            logger.flush()
+            return res
+    
+    logger.write("\r%s%s" % (header, " " * len_end_line), 3)
+    logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
+    logger.write("==== %s \n" % src.printcolors.printcInfo("OK"), 4)
+    logger.write("==== Script execution of %(name)s %(OK)s \n" %
+        { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
     logger.write("\n", 3, False)
+    logger.flush()
 
     return res
 
@@ -158,6 +180,10 @@ def run(args, runner, logger):
 
     # Get the list of products to treat
     products_infos = src.product.get_products_list(options, runner.cfg, logger)
+    products_infos = [pi for pi in products_infos if not(
+                                     src.product.product_is_native(pi[1]) or 
+                                     src.product.product_is_fixed(pi[1]))]
+    
     
     # Print some informations
     logger.write(_('Executing the script in the build '
@@ -190,4 +216,4 @@ def run(args, runner, logger):
           'valid_result': nb_products - res,
           'nb_products': nb_products }, 1)    
     
-    return res 
\ No newline at end of file
+    return res