"""Get the products name to add in SALOME_MODULES environment variable
It is the name of the product, except in the case where the is a
component name. And it has to be in SALOME_MODULES variable only
- if has_gui = "yes"
+ if the product has the property has_salome_hui = "yes"
:param lProducts list: List of products to potentially add
"""
- lProdHasGui = [p for p in lProducts if 'type ' in
- src.product.get_product_config(self.cfg, p) and
- src.product.get_product_config(self.cfg, p).type=='salome']
+ lProdHasGui = [p for p in lProducts if 'properties' in
+ src.product.get_product_config(self.cfg, p) and
+ 'has_salome_gui' in
+ src.product.get_product_config(self.cfg, p).properties and
+ src.product.get_product_config(self.cfg,
+ p).properties.has_salome_gui=='yes']
lProdName = []
for ProdName in lProdHasGui:
pi = src.product.get_product_config(self.cfg, ProdName)
if 'environ' in self.cfg.APPLICATION:
self.add_comment("APPLICATION environment")
for p in self.cfg.APPLICATION.environ:
- self.set(p, self.cfg.APPLICATION.environ[p])
+ val = self.cfg.APPLICATION.environ[p]
+ # "_" means that the value must be prepended
+ if p.startswith("_"):
+ # separator exception for PV_PLUGIN_PATH
+ if p[1:] == 'PV_PLUGIN_PATH':
+ self.prepend(p[1:], val, ';')
+ else:
+ self.prepend(p[1:], val)
+ elif p.endswith("_"):
+ # separator exception for PV_PLUGIN_PATH
+ if p[:-1] == 'PV_PLUGIN_PATH':
+ self.append(p[:-1], val, ';')
+ else:
+ self.append(p[:-1], val)
+ else:
+ self.set(p, val)
self.add_line(1)
# If there is an "environ_script" section, load the scripts
if not self.is_defined(src_dir):
self.set(src_dir, product_info.source_dir)
- def set_salome_generic_product_env(self, product):
+ def set_salome_generic_product_env(self, pi):
"""Sets the generic environment for a SALOME product.
- :param product str: The product name
+ :param pi Config: The product description
"""
- # get the product descritption
- pi = src.product.get_product_config(self.cfg, product)
# 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
- if compo_name + "CPP" == product:
+ if compo_name + "CPP" == pi.name:
compo_root_dir = compo_name + "_ROOT_DIR"
envcompo_root_dir = os.path.join(
self.cfg.TOOLS.common.install_root, compo_name )
]
self.prepend('PYTHONPATH', l)
+ def set_cpp_env(self, product_info):
+ """Sets the generic environment for a SALOME cpp product.
+
+ :param product_info Config: The product description
+ """
+ # Construct XXX_ROOT_DIR
+ env_root_dir = self.get(product_info.name + "_ROOT_DIR")
+ l_binpath_libpath = []
+
+ # Construct the paths to prepend to PATH and LD_LIBRARY_PATH and
+ # PYTHONPATH
+ bin_path = os.path.join(env_root_dir, 'bin')
+ lib_path = os.path.join(env_root_dir, 'lib')
+ l_binpath_libpath.append( (bin_path, lib_path) )
+
+ for bin_path, lib_path in l_binpath_libpath:
+ if not self.forBuild:
+ self.prepend('PATH', bin_path)
+ if src.architecture.is_windows():
+ self.prepend('PATH', lib_path)
+ else :
+ self.prepend('LD_LIBRARY_PATH', lib_path)
+
+ l = [ bin_path, lib_path,
+ os.path.join(env_root_dir, self.python_lib0),
+ os.path.join(env_root_dir, self.python_lib1)
+ ]
+ self.prepend('PYTHONPATH', l)
+
def load_cfg_environment(self, cfg_env):
"""Loads environment defined in cfg_env
if src.product.product_is_salome(pi):
# set environment using definition of the product
self.set_salome_minimal_product_env(pi, logger)
- self.set_salome_generic_product_env(product)
-
+ self.set_salome_generic_product_env(pi)
+
+ if src.product.product_is_cpp(pi):
+ # set a specific environment for cpp modules
+ self.set_salome_minimal_product_env(pi, logger)
+ self.set_cpp_env(pi)
+
+ if src.product.product_is_generated(pi):
+ if "component_name" in pi:
+ # hack the source and install directories in order to point
+ # on the generated product source install directories
+ install_dir_save = pi.install_dir
+ source_dir_save = pi.source_dir
+ name_save = pi.name
+ pi.install_dir = os.path.join(self.cfg.APPLICATION.workdir,
+ "INSTALL",
+ pi.component_name)
+ pi.source_dir = os.path.join(self.cfg.APPLICATION.workdir,
+ "GENERATED",
+ pi.component_name)
+ pi.name = pi.component_name
+ self.set_salome_minimal_product_env(pi, logger)
+ self.set_salome_generic_product_env(pi)
+
+ # Put original values
+ pi.install_dir = install_dir_save
+ pi.source_dir = source_dir_save
+ pi.name = name_save
+
# Put the environment define in the configuration of the product
if "environ" in pi:
self.load_cfg_environment(pi.environ)
self.add_line(1)
self.add_comment('setting environ for all products')
- self.set_python_libdirs()
-
# Set the application working directory
if src_root is None:
src_root = self.cfg.APPLICATION.workdir
self.set("SALOME_APPLI_ROOT",
os.path.join(self.cfg.APPLICATION.workdir, appli_name))
+ # Make sure that the python lib dirs are set after python
+ if "Python" in self.cfg.APPLICATION.products:
+ self.set_a_product("Python", logger)
+ self.set_python_libdirs()
+
# The loop on the products
for product in self.cfg.APPLICATION.products.keys():
+ if product == "Python":
+ continue
self.set_a_product(product, logger)
self.finish(False)
env.set_application_env(self.logger)
# The list of products to launch
- lProductsName = env.get_names(self.cfg.APPLICATION.products.keys())
+ lProductsName = env.get_names(self.config.APPLICATION.products.keys())
env.set( "SALOME_MODULES", ','.join(lProductsName))
# set the products