Salome HOME
spns #34338: post build script is not embedded in archive
[tools/sat.git] / src / environment.py
index 62943389339565b15113bf4f9259be26f1db232f..a706d5deab31149f876575522860b92198d41b46 100644 (file)
@@ -229,12 +229,12 @@ 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)
+        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=[]
         for n in all_products_graph:
@@ -245,15 +245,7 @@ class SalomeEnviron:
                                                visited_nodes,
                                                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
+        self.all_products_graph=all_products_graph
 
 
     def append(self, key, value, sep=os.pathsep):
@@ -397,14 +389,6 @@ class SalomeEnviron:
         else:
            self.cfg.APPLICATION.environ.PRODUCT_ROOT_DIR = src.pyconf.Reference(self.cfg, src.pyconf.DOLLAR, "workdir")
 
-        # these sensitive variables are reset to avoid bad environment interactions
-        self.add_line(1)
-        self.add_comment("reset these sensitive variables to avoid bad environment interactions")
-        self.add_comment("comment these to lines if you wish a different behaviour")
-        if not src.architecture.is_windows():
-           self.set("LD_LIBRARY_PATH", "")
-        self.set("PYTHONPATH", "")
-        self.add_line(1)
 
         # Set the variables defined in the "environ" section
         if 'environ' in self.cfg.APPLICATION:
@@ -427,10 +411,20 @@ class SalomeEnviron:
         :param product_info Config: The product description
         :param logger Logger: The logger instance to display messages        
         """
-        # set root dir
         DBG.write("set_salome_minimal_product_env", product_info)
+
+        # set root dir
         root_dir = product_info.name + "_ROOT_DIR"
-        if 'install_dir' in product_info and product_info.install_dir:
+        
+        if src.product.product_is_configuration(product_info):
+            # configuration modules are not installed, root_dir points at source dir
+            if not self.for_package:
+                self.set(root_dir, product_info.source_dir)
+            else:
+                self.set(root_dir, os.path.join("out_dir_Path",
+                         "SOURCES",
+                         os.path.basename(product_info.source_dir)))
+        elif 'install_dir' in product_info and product_info.install_dir:
             self.set(root_dir, product_info.install_dir)
         elif not self.silent:
             logger.write("  " + _("No install_dir for product %s\n") %
@@ -463,6 +457,10 @@ class SalomeEnviron:
         
         :param pi Config: The product description
         """
+        if src.product.product_is_configuration(pi):
+            # configuration modules are not installed and should not be set like others
+            return
+
         # Construct XXX_ROOT_DIR
         env_root_dir = self.get(pi.name + "_ROOT_DIR")
         l_binpath_libpath = []
@@ -595,6 +593,10 @@ class SalomeEnviron:
         if not self.forBuild:
             if src.product.product_is_compile_time(pi):
                 return
+        else:
+            if src.product.product_is_native(pi) :
+                self.set("SAT_%s_IS_NATIVE"%pi.name, "1")
+                
 
         # skip pip products when pip is activated and installation is done in python 
         #if (src.appli_test_property(self.cfg,"pip", "yes") and 
@@ -763,24 +765,15 @@ 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):
         """\
-        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
@@ -793,28 +786,23 @@ 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:
             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:
@@ -943,6 +931,7 @@ class FileEnvWriter:
         :return: The path to the generated file
         :rtype: str
         """
+        additional_env["sat_dist"]=self.config.VARS.dist
         if not self.silent:
             self.logger.write(_("Create environment file %s\n") % 
                               src.printcolors.printcLabel(filename), 3)