]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
sat launcher : nouvelle option -p qui permet de générer un lanceur pour un sous ensem...
authorcrouzet <nicolas.crouzet@cea.fr>
Wed, 9 Jun 2021 13:08:05 +0000 (15:08 +0200)
committerCROUZET Nicolas <crouzet@is243948.intra.cea.fr>
Mon, 23 Aug 2021 09:03:36 +0000 (11:03 +0200)
commands/launcher.py
complete_sat.sh
doc/src/commands/launcher.rst
src/environment.py

index aec0ff8eb8c4fa6a08ed0c2fce76bccc8ea02278..bfbdc92802771b29c2b41a72957932e933f74955 100644 (file)
@@ -33,6 +33,8 @@ parser.add_option('n', 'name', 'string', 'name', _('Optional: The name of the'
 parser.add_option('e', 'exe', 'string', 'path_exe', _('Use this option to generate a launcher which sets'
                   ' the environment and call the executable given as argument'
                   ' (its relative path to application workdir, or an exe name present in appli PATH)'))
+parser.add_option('p', 'products', 'list2', 'products',
+    _("Optional: Includes only the specified products."))
 parser.add_option('c', 'catalog', 'string', 'catalog',
                   _('Optional: The resources catalog to use'))
 parser.add_option('', 'gencat', 'string', 'gencat',
@@ -54,6 +56,7 @@ def generate_launch_file(config,
                          launcher_name,
                          pathlauncher,
                          path_exe,
+                         env_info,
                          display=True,
                          additional_env={},
                          no_path_init=False):
@@ -69,6 +72,7 @@ def generate_launch_file(config,
     :param display boolean: If False, do not print anything in the terminal
     :param additional_env dict: The dict giving additional 
                                 environment variables
+    :param env_info str: The list of products to add in the files.
     :return: The launcher file path.
     :rtype: str
     '''
@@ -151,8 +155,8 @@ def generate_launch_file(config,
     writer = src.environment.FileEnvWriter(config,
                                            logger,
                                            pathlauncher,
-                                           src_root=None,
-                                           env_info=None)
+                                           None,
+                                           env_info)
 
     # Display some information
     if display:
@@ -302,6 +306,14 @@ def run(args, runner, logger):
     src.check_config_has_application( runner.cfg )
     
     # Determine the launcher name (from option, profile section or by default "salome")
+    if options.products is None:
+        environ_info = None
+    else:
+        # add products specified by user (only products 
+        # included in the application)
+        environ_info = filter(lambda l:
+                              l in runner.cfg.APPLICATION.products.keys(),
+                              options.products)
     if options.name:
         launcher_name = options.name
     else:
@@ -341,6 +353,7 @@ def run(args, runner, logger):
                          launcher_path,
                          options.path_exe,
                          additional_env = additional_environ,
+                         env_info=environ_info,
                          no_path_init = no_path_initialisation )
 
     return 0
index 7470b1bbc7763b398767fea08c134409dd4a3b7f..d8e623bb2551cdc79ac73549a93ac4c9c1fdfb50 100755 (executable)
@@ -212,7 +212,7 @@ _salomeTools_complete()
             return 0
             ;;
         launcher)
-            opts="--name --exe --catalog --gencat --no_path_init --use_mesa"
+            opts="--products --name --exe --catalog --gencat --no_path_init --use_mesa"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
index 8ec433f881c3b101ea940637d42005502eec4bd8..0a4efef7e0387d76f73009677465cbf1c8a53db6 100644 (file)
@@ -52,6 +52,15 @@ Usage
 
     sat launcher <application> --use_mesa
 
+* Generate the environment files only with the given products:
+
+  .. code-block:: bash
+
+    # This will create a launcher file called salome-pre,
+    # which will contain GEOM,SMESH and their prerequisites.
+    # It is useful if you want to create a launcher with only a part of Salome
+    sat launcher  <application> --product GEOM,SMESH -n salome-pre
+
 
 Configuration
 =============
index f44c13105716ade802d17f4278d30c3579a7e53e..0699a3d1ece9cf32b450ac025f0a9093ef4217b9 100644 (file)
@@ -229,11 +229,11 @@ 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)
         
+        from compile import get_dependencies_graph,depth_first_topo_graph
         all_products_graph=get_dependencies_graph(all_products_infos, self.forBuild)
         visited_nodes=[]
         sorted_nodes=[]
@@ -245,6 +245,7 @@ class SalomeEnviron:
                                                visited_nodes,
                                                sorted_nodes)
         self.sorted_product_list=sorted_nodes
+        self.all_products_graph=all_products_graph
 
 
     def append(self, key, value, sep=os.pathsep):
@@ -760,7 +761,7 @@ class SalomeEnviron:
  
     def set_full_environ(self, logger, env_info):
         """\
-        Sets the full environment for products 
+        Sets the full environment for products, with their dependencies 
         specified in env_info dictionary. 
         
         :param logger Logger: The logger instance to display messages
@@ -773,9 +774,13 @@ class SalomeEnviron:
 
         # use the sorted list of all products to sort the list of products 
         # we have to set
+        visited=[]
+        from compile import depth_search_graph # to get the dependencies
+        for p_name in env_info:
+            visited=depth_search_graph(self.all_products_graph, p_name, visited)
         sorted_product_list=[]
         for n in self.sorted_product_list:
-            if n in env_info:
+            if n in visited:
                 sorted_product_list.append(n)
 
         if "Python" in sorted_product_list: