Salome HOME
sat launcher : nouvelle option -p qui permet de générer un lanceur pour un sous ensem...
[tools/sat.git] / src / environment.py
index fd94a36196bae716cd2d8df3ce54ac9524ded6e8..0699a3d1ece9cf32b450ac025f0a9093ef4217b9 100644 (file)
@@ -54,10 +54,15 @@ class Environ:
         :return: the replaced variable
         :rtype: str
         """
-        if "$" in value:
+        if src.architecture.is_windows():
+            delim = "%"
+        else:
+            delim = "$"
+        if delim in value:
             # The string.Template class is a string class 
             # for supporting $-substitutions
             zt = string.Template(value)
+            zt.delimiter = delim
             try:
                 value = zt.substitute(self.environ)
             except KeyError as exc:
@@ -224,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:
@@ -240,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):
@@ -375,17 +381,14 @@ class SalomeEnviron:
         """
         
         if self.for_package:
-           self.set("PRODUCT_ROOT_DIR", "out_dir_Path")
+           if src.architecture.is_windows():
+              self.set("PRODUCT_ROOT_DIR", "%out_dir_Path%")
+           else:
+              self.set("PRODUCT_ROOT_DIR", "out_dir_Path")
+
         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")
-        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:
@@ -447,7 +450,6 @@ class SalomeEnviron:
         # Construct XXX_ROOT_DIR
         env_root_dir = self.get(pi.name + "_ROOT_DIR")
         l_binpath_libpath = []
-
         # create additional ROOT_DIR for CPP components
         if 'component_name' in pi:
             compo_name = pi.component_name
@@ -573,7 +575,6 @@ class SalomeEnviron:
 
         # Get the informations corresponding to the product
         pi = src.product.get_product_config(self.cfg, product)
-        
         # skip compile time products at run time 
         if not self.forBuild:
             if src.product.product_is_compile_time(pi):
@@ -600,10 +601,14 @@ class SalomeEnviron:
                
         
         if self.for_package:
+            prod_base_name=os.path.basename(pi.install_dir)
+            if prod_base_name.startswith("config"):
+                # case of a products installed in base. We remove "config-i"
+                prod_base_name=os.path.basename(os.path.dirname(pi.install_dir))
             pi.install_dir = os.path.join(
                                  "out_dir_Path",
                                  self.for_package,
-                                 os.path.basename(pi.install_dir))
+                                 prod_base_name)
 
         if not self.silent:
             logger.write(_("Setting environment for %s\n") % product, 4)
@@ -634,6 +639,12 @@ class SalomeEnviron:
             logger.write("licence file found for product %s : %s\n" % (pi.name, licence_file_name), 5) 
             self.set("LICENCE_FILE", licence_file_name)
 
+        # these infos may be needed for the environment of some products
+        if "debug" in pi and pi.debug == "yes":
+            self.set("SAT_DEBUG", "1")
+        if "verbose" in pi and pi.verbose == "yes":
+            self.set("SAT_VERBOSE", "1")
+
         if src.product.product_is_cpp(pi):
             # set a specific environment for cpp modules
             self.set_salome_minimal_product_env(pi, logger)
@@ -750,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
@@ -758,15 +769,18 @@ class SalomeEnviron:
         """
         DBG.write("set_full_environ for", env_info)
         # DBG.write("set_full_environ config", self.cfg.APPLICATION.environ, True)
-
         # set product environ
         self.set_application_env(logger)
 
         # 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:
@@ -908,7 +922,6 @@ class FileEnvWriter:
         if not self.silent:
             self.logger.write(_("Create environment file %s\n") % 
                               src.printcolors.printcLabel(filename), 3)
-
         # create then env object
         env_file = open(os.path.join(self.out_dir, filename), "w")
 
@@ -936,11 +949,9 @@ class FileEnvWriter:
         else:
             # set env from the APPLICATION
             env.set_application_env(self.logger)
-            
             # set the products
             env.set_products(self.logger,
                             src_root=self.src_root)
-
         # Add the additional environment if it is not empty
         if len(additional_env) != 0:
             env.add_line(1)