]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
sat package --binaries: add the possibility to add sources of the products that have...
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 17 Feb 2017 10:35:33 +0000 (11:35 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 17 Feb 2017 10:35:33 +0000 (11:35 +0100)
commands/package.py
src/environment.py

index 14694f1e759f508a9aa2432a084cb3b8d6eae06d..e4284f62c15e3f0c54fd7e96daa045cd3b77e656 100644 (file)
@@ -333,7 +333,9 @@ def binary_package(config, logger, options, tmp_working_dir):
     l_product_info = src.product.get_products_infos(l_products_name,
                                                     config)
     l_install_dir = []
+    l_source_dir = []
     l_not_installed = []
+    l_sources_not_present = []
     for prod_name, prod_info in l_product_info:
         # ignore the native and fixed products
         if (src.product.product_is_native(prod_info) 
@@ -355,7 +357,16 @@ def binary_package(config, logger, options, tmp_working_dir):
                     l_install_dir.append((name_cpp, install_dir))
                 else:
                     l_not_installed.append(name_cpp)
-    
+        
+        # Add the sources of the products that have the property 
+        # sources_in_package : "yes"
+        if src.get_property_in_product_cfg(prod_info,
+                                           "sources_in_package") == "yes":
+            if os.path.exists(prod_info.source_dir):
+                l_source_dir.append((prod_name, prod_info.source_dir))
+            else:
+                l_sources_not_present.append(prod_name)
+        
     # Print warning or error if there are some missing products
     if len(l_not_installed) > 0:
         text_missing_prods = ""
@@ -372,7 +383,24 @@ def binary_package(config, logger, options, tmp_working_dir):
             logger.write("%s\n%s" % (src.printcolors.printcWarning(msg),
                                      text_missing_prods),
                          1)
-    
+
+    # Do the same for sources
+    if len(l_sources_not_present) > 0:
+        text_missing_prods = ""
+        for p_name in l_sources_not_present:
+            text_missing_prods += "-" + p_name + "\n"
+        if not options.force_creation:
+            msg = _("ERROR: there are missing products sources:")
+            logger.write("%s\n%s" % (src.printcolors.printcError(msg),
+                                     text_missing_prods),
+                         1)
+            return None
+        else:
+            msg = _("WARNING: there are missing products sources:")
+            logger.write("%s\n%s" % (src.printcolors.printcWarning(msg),
+                                     text_missing_prods),
+                         1)
     # construct the name of the directory that will contain the binaries
     binaries_dir_name = "BINARIES-" + config.VARS.dist
     
@@ -382,6 +410,10 @@ def binary_package(config, logger, options, tmp_working_dir):
     for prod_name, install_dir in l_install_dir:
         path_in_archive = os.path.join(binaries_dir_name, prod_name)
         d_products[prod_name] = (install_dir, path_in_archive)
+        
+    for prod_name, source_dir in l_source_dir:
+        path_in_archive = os.path.join("SOURCES", prod_name)
+        d_products[prod_name] = (source_dir, path_in_archive)
 
     # create the relative launcher and add it to the files to add
     if ("profile" in config.APPLICATION and 
index a203a485e112be238082ff74e9302484dda2e705..e66cabc795014638076b23bcc0a14cb68b2e1dae 100644 (file)
@@ -381,12 +381,19 @@ class SalomeEnviron:
                 logger.write("  " + _("No install_dir for product %s\n") %
                               product_info.name, 5)
         
-        if not self.for_package:
+        source_in_package = src.get_property_in_product_cfg(product_info,
+                                                           "sources_in_package")
+        if not self.for_package or source_in_package == "yes":
             # set source dir, unless no source dir
             if not src.product.product_is_fixed(product_info):
                 src_dir = product_info.name + "_SRC_DIR"
                 if not self.is_defined(src_dir):
-                    self.set(src_dir, product_info.source_dir)
+                    if not self.for_package:
+                        self.set(src_dir, product_info.source_dir)
+                    else:
+                        self.set(src_dir, os.path.join("out_dir_Path",
+                                                       "SOURCES",
+                                                       product_info.name))
 
     def set_salome_generic_product_env(self, pi):
         """Sets the generic environment for a SALOME product.