Salome HOME
sat #17766 et sat #17848 : traitement des modules par ordre de dépendance, correction...
authorcrouzet <nicolas.crouzet@cea.fr>
Fri, 11 Oct 2019 09:15:53 +0000 (11:15 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Fri, 11 Oct 2019 09:15:53 +0000 (11:15 +0200)
commands/compile.py
doc/src/configuration.rst
doc/src/usage_of_sat.rst
src/environment.py
src/fileEnviron.py

index b519b02080c285fdccd3bf15e032e633a1bb6574..8010b33125d449e99f88f351b2fa6156d8776b57 100644 (file)
@@ -480,7 +480,7 @@ def compile_product_pip(sat,
         #log_res_step(logger, res)
         res=1
         error_step = "PIP"
-        logger.write("\nError in pip command, please consult details with sat log command's internal traces\n", 5)
+        logger.write("\nError in pip command, please consult details with sat log command's internal traces\n", 3)
 
     return res, len_end_line, error_step 
 
@@ -683,7 +683,7 @@ def run(args, runner, logger):
     for n in all_products_graph:
         if n not in visited_nodes:
             visited_nodes,sorted_nodes=depth_first_topo_graph(all_products_graph, n, visited_nodes,sorted_nodes)
-    logger.write("Complete depndency graph topological search (sorting): %s\n" % sorted_nodes, 6)
+    logger.write("Complete dependency graph topological search (sorting): %s\n" % sorted_nodes, 6)
 
 #   use the sorted list of all products to sort the list of products we have to compile
     sorted_product_list=[]
index 19fed19f785d4dfafb1c4b574e2d9477b1180cd9..643275b15dbff3c999dd8d577b8ae3abe1a0e2cc 100644 (file)
@@ -48,6 +48,20 @@ APPLICATION section
     # to get the current setting
     sat config SALOME-xx --value APPLICATION
 
+
+Globals
+
+  * name : the name of the application
+  * workdir : the directory in which the application is produced
+  * tag : the default tag to use for the git bases
+  * dev : activate the dev mode. in dev mode git bases are checked out only one time, to avoid risks of removing developments.
+  * verbose : activate verbosity in the compilation
+  * debug : activate debug mode in the compilation, i.e -g option
+  * python3 : 'yes/no' tell sat that the application uses python3 
+  * no_base : 'yes/no' 
+  * base : 'yes/no/name'
+
+
 PRODUCTS section
 ---------------------
 | This section contains all the information required to build the products contained in the application.
index 30df114d66333f4c8a415b178c8d9752043b3ca9..3bc67e35c17486b7f42d444a3da5f32ab3c34d96 100644 (file)
@@ -12,13 +12,16 @@ sat is a Command Line Interface (CLI_) based on python langage.
 Its purpose is to cover the maintenance and the production of the salome platform and its applications.
 
 Notably:
+
 * the definition of the applications content (the products, the resources, the options, the environment, the launcher, etc.)
-* the description of the products (the environment to set, how to get the sources; how to compilation, the dependencies, etc).
+* the description of the products (the environment to set, how to get the sources; how to compilation (which options), , the dependencies, etc).
 * the complete preparation and build
 * the management of unit or integration tests
 * the production of binary or source packages
 
-It can be used from interactively from a terminal, or in batch mode.
+It is designed to run on several Linux OS and Windows, with
+the possibility to specify platform dependent specifics (with the **__overwrite__** functionality. 
+It can be used from interactively from a terminal, or in batch mode. 
 
 .. code-block:: bash
 
@@ -38,7 +41,7 @@ To get help in terminal mode as simple text, use **--help** or **-h** option:
     sat -h          # or --help : get the list of existing commands and main options
     sat compile -h  # get the help on the specific command 'compile'
 
-completion mode
+Completion mode
 ---------------
 
 When getting started with sat, the use of the competion mode is usefull. This mode will display by type twice on the **tab key** the available options, command, applications or product available. The completion mode has to be activated by sourcing the file **complete_sat.sh** contained in salomeTool directory:
index c094300832bbde7613ef0fa3e19c1e1fe454c4a2..09f5b76e83c71a4d0bc1f902cea9c882bec56d6f 100644 (file)
@@ -212,6 +212,7 @@ class SalomeEnviron:
         self.enable_simple_env_script = enable_simple_env_script
         self.silent = False
         self.has_python = False
+        self.__set_sorted_products_list()
 
     def __repr__(self):
         """easy almost exhaustive quick resume for debug print"""
@@ -222,6 +223,25 @@ class SalomeEnviron:
         }
         return "%s(\n%s\n)" % (self.__class__.__name__, PP.pformat(res))
 
+    def __set_sorted_products_list(self):
+        from compile import get_dependencies_graph, depth_first_topo_graph
+        all_products_infos = src.product.get_products_infos(
+                                 self.cfg.APPLICATION.products,
+                                 self.cfg)
+        
+        all_products_graph=get_dependencies_graph(all_products_infos)
+        visited_nodes=[]
+        sorted_nodes=[]
+        for n in all_products_graph:
+            if n not in visited_nodes:
+                visited_nodes,sorted_nodes=depth_first_topo_graph(
+                                               all_products_graph, 
+                                               n, 
+                                               visited_nodes,
+                                               sorted_nodes)
+        self.sorted_product_list=sorted_nodes
+
+
     def append(self, key, value, sep=os.pathsep):
         """\
         append value to key using sep
@@ -415,7 +435,7 @@ class SalomeEnviron:
             compo_name = pi.component_name
         else:
             compo_name = pi.name
-        self.prepend('SALOME_MODULES', compo_name, ',')
+        self.append('SALOME_MODULES', compo_name, ',')
         
         
     def set_salome_generic_product_env(self, pi):
@@ -707,7 +727,6 @@ class SalomeEnviron:
             traceback.print_tb(exceptionTraceback)
             traceback.print_exc()
 
-
     def set_products(self, logger, src_root=None):
         """\
         Sets the environment for all the products. 
@@ -719,12 +738,12 @@ class SalomeEnviron:
         self.add_comment('setting environ for all products')
 
         # Make sure that the python lib dirs are set after python
-        if "Python" in self.cfg.APPLICATION.products:
+        if "Python" in self.sorted_product_list:
             self.set_a_product("Python", logger)
             self.set_python_libdirs()
 
         # The loop on the products
-        for product in self.cfg.APPLICATION.products.keys():
+        for product in self.sorted_product_list:
             if product == "Python":
                 continue
             self.set_a_product(product, logger)
@@ -743,12 +762,19 @@ class SalomeEnviron:
         # set product environ
         self.set_application_env(logger)
 
-        if "Python" in env_info:
+        # use the sorted list of all products to sort the list of products 
+        # we have to set
+        sorted_product_list=[]
+        for n in self.sorted_nodes:
+            if n in env_info:
+                sorted_product_list.append(n)
+
+        if "Python" in sorted_product_list:
             self.set_a_product("Python", logger)
             self.set_python_libdirs()
 
         # set products
-        for product in env_info:
+        for product in sorted_product_list:
             if product == "Python":
                 continue
             self.set_a_product(product, logger)
index e43e0e5e72da8abdfdd45385d8f45b421b0a2652..3c173e26ef8a9556e46732fcfde610e4f39a205d 100644 (file)
@@ -277,7 +277,6 @@ class TclFileEnviron(FileEnviron):
         :param key str: the environment variable to set
         :param value str: the value
         """
-        #print "CNC TclFileEnviron set ", key, " to ", value
         self.output.write('setenv  %s "%s"\n' % (key, value))
         self.environ.set(key, value)
         
@@ -503,16 +502,45 @@ class LauncherFileEnviron(FileEnviron):
         """
         self.output.write('# "WARNING %s"\n' % warning)
 
-    def append_value(self, key, value, sep=":"):
+    def append_value(self, key, value, sep=os.pathsep):
         """append value to key using sep,
         if value contains ":" or ";" then raise error
         
-        :param key str: the environment variable to append
-        :param value str: the value to append to key
+        :param key str: the environment variable to prepend
+        :param value str: the value to prepend to key
         :param sep str: the separator string
         """
-        # append is not defined in context api
-        self.prepend_value(key, value)
+        # check that value so no contain the system separator
+        separator=os.pathsep
+        msg="LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'"
+        if separator in value:
+            raise Exception(msg % (key, value, separator))
+
+        if (self.init_path and (not self.environ.is_defined(key))):
+            # reinitialisation mode set to true (the default)
+            # for the first occurrence of key, we set it.
+            # therefore key will not be inherited from environment
+            self.set(key, value)
+            return
+
+        # in all other cases we use append (except if value is already the key
+        do_append=True
+        if self.environ.is_defined(key):
+            value_list = self.environ.get(key).split(sep)
+            # rem : value cannot be expanded (unlike bash/bat case) - but it doesn't matter.
+            if value in value_list:
+                do_append=False  # value is already in key path : we don't append it again
+            
+        if do_append:
+            self.environ.append_value(key, value,sep) # register value in self.environ
+            if key in self.specialKeys.keys():
+                #for these special keys we use the specific salomeContext function
+                self.output.write(self.begin+'addTo%s(r"%s")\n' % 
+                                  (self.specialKeys[key], self.value_filter(value)))
+            else:
+                # else we use the general salomeContext addToVariable function
+                self.output.write(self.indent+'appendPath(r"%s", r"%s",separator="%s")\n' 
+                                  % (key, self.value_filter(value), sep))
 
     def append(self, key, value, sep=":"):
         """Same as append_value but the value argument can be a list
@@ -898,7 +926,19 @@ launcher_tail_py3="""\
     import logging
     logging.getLogger("salome").error(e)
     sys.exit(1)
-#
+# salomeContext only prepend variables, we use our own appendPath when required
+def appendPath(name, value, separator=os.pathsep):
+    if value == '':
+      return
+
+    value = os.path.expandvars(value) # expand environment variables
+    env = os.getenv(name, None)
+    if env is None:
+      os.environ[name] = value
+    else:
+      os.environ[name] = env + separator + value
+
 
 if __name__ == "__main__":
   args = sys.argv[1:]