From 25a849819d0c399a4713d1720424aedbd1c5e198 Mon Sep 17 00:00:00 2001 From: crouzet Date: Tue, 28 Jul 2020 16:24:52 +0200 Subject: [PATCH] =?utf8?q?prise=20en=20compte=20d'un=20champ=20build=5Fdep?= =?utf8?q?end=20pour=20le=20calcul=20des=20d=C3=A9pendance=20compile=20tim?= =?utf8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/compile.py | 19 ++++++++++--------- commands/config.py | 4 ++++ src/environment.py | 29 +---------------------------- src/product.py | 21 ++++++++++++++++++--- 4 files changed, 33 insertions(+), 40 deletions(-) diff --git a/commands/compile.py b/commands/compile.py index 4d3a35c..f2b98d6 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -64,10 +64,16 @@ parser.add_option('', 'clean_build_after', 'boolean', 'clean_build_after', # from sat product infos, represent the product dependencies in a simple python graph # keys are nodes, the list of dependencies are values -def get_dependencies_graph(p_infos): +def get_dependencies_graph(p_infos, compile_time=True): graph={} for (p_name,p_info) in p_infos: - graph[p_name]=p_info.depend + depprod=[] + for d in p_info.depend: + depprod.append(d) + if compile_time and "build_depend" in p_info: + for d in p_info.build_depend: + depprod.append(d) + graph[p_name]=depprod return graph # this recursive function calculates all the dependencies of node start @@ -740,12 +746,7 @@ def run(args, runner, logger): # store at beginning compile time products, we need to compile them before! for n in sorted_nodes: if n in products_list: - if src.product.product_is_compile_time(all_products_dict[n][1]) or\ - src.product.product_is_compile_and_runtime(all_products_dict[n][1]): - product_list_compiletime.append(n) - else: - product_list_runtime.append(n) - sorted_product_list = product_list_compiletime + product_list_runtime + sorted_product_list.append(n) logger.write("Sorted list of products to compile : %s\n" % sorted_product_list, 5) # from the sorted list of products to compile, build a sorted list of products infos @@ -754,7 +755,7 @@ def run(args, runner, logger): products_infos.append(all_products_dict[product]) # for all products to compile, store in "depend_all" field the complete dependencies (recursive) - # (will be used by check_dependencies funvtion) + # (will be used by check_dependencies function) for pi in products_infos: dep_prod=[] dep_prod=depth_search_graph(all_products_graph,pi[0], dep_prod) diff --git a/commands/config.py b/commands/config.py index f5e539c..abba1a8 100644 --- a/commands/config.py +++ b/commands/config.py @@ -649,6 +649,10 @@ def show_product_info(config, name, logger): if "opt_depend" in pinfo: src.printcolors.print_value(logger, "optional", sorted(pinfo.opt_depend), 2) + if "build_depend" in pinfo: + src.printcolors.print_value(logger, "build depend on", sorted(pinfo.build_depend), 2) + + # information on pyconf logger.write("\n", 2) logger.write(src.printcolors.printcLabel("configuration:") + "\n", 2) diff --git a/src/environment.py b/src/environment.py index 6294338..17029b1 100644 --- a/src/environment.py +++ b/src/environment.py @@ -234,7 +234,7 @@ class SalomeEnviron: self.cfg.APPLICATION.products, self.cfg) - all_products_graph=get_dependencies_graph(all_products_infos) + all_products_graph=get_dependencies_graph(all_products_infos, self.forBuild) visited_nodes=[] sorted_nodes=[] for n in all_products_graph: @@ -246,15 +246,6 @@ class SalomeEnviron: sorted_nodes) self.sorted_product_list=sorted_nodes - # store the list of compile time products - # they should be added in build env - compile_time_products=[] - for (pname,pinfo) in all_products_infos: - if src.product.product_is_compile_time(pinfo) or\ - src.product.product_is_compile_and_runtime(pinfo) : - compile_time_products.append(pname) - self.compile_time_products=compile_time_products - def append(self, key, value, sep=os.pathsep): """\ @@ -763,19 +754,10 @@ class SalomeEnviron: self.set_a_product("Python", logger) self.set_python_libdirs() - # for a build environment, add compile time products (like cmake) - if self.forBuild : - for product in self.compile_time_products: - if product == "Python": - continue - self.set_a_product(product, logger) - # The loop on the products for product in self.sorted_product_list: if product == "Python": continue - if self.forBuild and product in self.compile_time_products: - continue self.set_a_product(product, logger) def set_full_environ(self, logger, env_info): @@ -802,19 +784,10 @@ class SalomeEnviron: self.set_a_product("Python", logger) self.set_python_libdirs() - # for a build environment, add compile time products (like cmake) - if self.forBuild : - for product in self.compile_time_products: - if product == "Python": - continue - self.set_a_product(product, logger) - # set products for product in sorted_product_list: if product == "Python": continue - if self.forBuild and product in self.compile_time_products: - continue self.set_a_product(product, logger) class FileEnvWriter: diff --git a/src/product.py b/src/product.py index e0bc087..7311ba7 100644 --- a/src/product.py +++ b/src/product.py @@ -608,7 +608,13 @@ def add_compile_config_file(p_info, config): res.addMapping(p_info.name, src.pyconf.Mapping(res), "") res[p_info.name]= p_info.version - for prod_name in p_info.depend: + depprod=[] + for d in p_info.depend: + depprod.append(d) + if "build_depend" in p_info: + for d in p_info.build_depend: + depprod.append(d) + for prod_name in depprod: if prod_name not in res: res.addMapping(prod_name, src.pyconf.Mapping(res), "") prod_dep_info = src.product.get_product_config(config, prod_name, False) @@ -808,10 +814,19 @@ def get_product_dependencies(config, product_info): :return: the list of products in dependence :rtype: list """ - if "depend" not in product_info or product_info.depend == []: + depend_all=[] + if "depend" in product_info: + for d in product_info.depend: + depend_all.append(d) + if "build_depend" in product_info: + for d in product_info.build_depend: + depend_all.append(d) + + if len(depend_all) == 0: return [] + res = [] - for prod in product_info.depend: + for prod in depend_all: if prod == product_info.name: continue if prod not in res: -- 2.39.2