From c76437f0fb9f7f66bfca0eb10674fbdd3d22ba6c Mon Sep 17 00:00:00 2001 From: crouzet Date: Wed, 9 Jun 2021 15:08:05 +0200 Subject: [PATCH] =?utf8?q?sat=20launcher=20:=20nouvelle=20option=20-p=20qu?= =?utf8?q?i=20permet=20de=20g=C3=A9n=C3=A9rer=20un=20lanceur=20pour=20un?= =?utf8?q?=20sous=20ensemble=20de=20salome?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/launcher.py | 17 +++++++++++++++-- complete_sat.sh | 2 +- doc/src/commands/launcher.rst | 9 +++++++++ src/environment.py | 11 ++++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/commands/launcher.py b/commands/launcher.py index aec0ff8..bfbdc92 100644 --- a/commands/launcher.py +++ b/commands/launcher.py @@ -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 diff --git a/complete_sat.sh b/complete_sat.sh index 7470b1b..d8e623b 100755 --- a/complete_sat.sh +++ b/complete_sat.sh @@ -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 ;; diff --git a/doc/src/commands/launcher.rst b/doc/src/commands/launcher.rst index 8ec433f..0a4efef 100644 --- a/doc/src/commands/launcher.rst +++ b/doc/src/commands/launcher.rst @@ -52,6 +52,15 @@ Usage sat launcher --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 --product GEOM,SMESH -n salome-pre + Configuration ============= diff --git a/src/environment.py b/src/environment.py index f44c131..0699a3d 100644 --- a/src/environment.py +++ b/src/environment.py @@ -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: -- 2.39.2