From 4945e5dd869a6b0c5d6a1b6018a7956c9e8bd2de Mon Sep 17 00:00:00 2001 From: crouzet Date: Fri, 11 Oct 2019 11:15:53 +0200 Subject: [PATCH] =?utf8?q?sat=20#17766=20et=20sat=20#17848=20:=20traitemen?= =?utf8?q?t=20des=20modules=20par=20ordre=20de=20d=C3=A9pendance,=20correc?= =?utf8?q?tion=20probl=C3=A8me=20ordore=20SALOME=5FMODULES=20et=20SalomeAp?= =?utf8?q?pConfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/compile.py | 4 +-- doc/src/configuration.rst | 14 ++++++++++ doc/src/usage_of_sat.rst | 9 ++++--- src/environment.py | 38 ++++++++++++++++++++++----- src/fileEnviron.py | 54 ++++++++++++++++++++++++++++++++++----- 5 files changed, 101 insertions(+), 18 deletions(-) diff --git a/commands/compile.py b/commands/compile.py index b519b02..8010b33 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -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=[] diff --git a/doc/src/configuration.rst b/doc/src/configuration.rst index 19fed19..643275b 100644 --- a/doc/src/configuration.rst +++ b/doc/src/configuration.rst @@ -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. diff --git a/doc/src/usage_of_sat.rst b/doc/src/usage_of_sat.rst index 30df114..3bc67e3 100644 --- a/doc/src/usage_of_sat.rst +++ b/doc/src/usage_of_sat.rst @@ -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: diff --git a/src/environment.py b/src/environment.py index c094300..09f5b76 100644 --- a/src/environment.py +++ b/src/environment.py @@ -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) diff --git a/src/fileEnviron.py b/src/fileEnviron.py index e43e0e5..3c173e2 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -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:] -- 2.39.2