2 .. include:: ../../rst_prolog.rst
9 The **environ** command generates the environment files used
10 to run and compile your application (as SALOME_ is an example).
13 these files are **not** required,
14 salomeTool set the environment himself, when compiling.
15 And so does the salome launcher.
17 These files are useful when someone wants to check the environment.
18 They could be used in debug mode to set the environment for *gdb*.
20 The configuration part at the end of this page explains how
21 to specify the environment used by sat (at build or run time),
22 and saved in some files by *sat environ* command.
26 * Create the shell environment files of the application: ::
28 sat environ <application>
30 * Create the environment files of the application for a given shell.
31 Options are bash, bat (for windows) and cfg (the configuration format used by SALOME_): ::
33 sat environ <application> --shell [bash|cfg|all]
35 * Use a different prefix for the files (default is 'env'):
39 # This will create file <prefix>_launch.sh, <prefix>_build.sh
40 sat environ <application> --prefix <prefix>
42 * Use a different target directory for the files:
46 # This will create file env_launch.sh, env_build.sh
47 # in the directory corresponding to <path>
48 sat environ <application> --target <path>
50 * Generate the environment files only with the given products:
54 # This will create the environment files only for the given products
55 # and their prerequisites.
56 # It is useful when you want to visualise which environment uses
57 # sat to compile a given product.
58 sat environ <application> --product <product1>,<product2>, ...
64 The specification of the environment can be done through several mechanisms.
66 1. For salome products (the products with the property ``is_SALOME_module`` as ``yes``) the environment is set automatically by sat, in respect with SALOME_ requirements.
68 2. For other products, the environment is set with the use of the environ section within the pyconf file of the product. The user has two possibilities, either set directly the environment within the section, or specify a python script which wil be used to set the environment programmatically.
70 Within the section, the user can define environment variables. He can also modify PATH variables, by appending or prepending directories.
71 In the following example, we prepend *<install_dir>/lib* to ``LD_LIBRARY_PATH`` (note the *left first* underscore), append *<install_dir>/lib* to ``PYTHONPATH`` (note the *right last* underscore), and set ``LAPACK_ROOT_DIR`` to *<install_dir>*:
77 _LD_LIBRARY_PATH : $install_dir + $VARS.sep + "lib"
78 PYTHONPATH_ : $install_dir + $VARS.sep + "lib"
79 LAPACK_ROOT_DIR : $install_dir
82 It is possible to distinguish the build environment from the launch environment: use a subsection called *build* or *launch*. In the example below, ``LD_LIBRARY_PATH`` and ``PYTHONPATH`` are only modified at run time, not at compile time:
90 LAPACK_ROOT_DIR : $install_dir
94 LAPACK_ROOT_DIR : $install_dir
95 _LD_LIBRARY_PATH : $install_dir + $VARS.sep + "lib"
96 PYTHONPATH_ : $install_dir + $VARS.sep + "lib"
100 3. The last possibility is to set the environment with a python script. The script should be provided in the *products/env_scripts* directory of the sat project, and its name is specified in the environment section with the key ``environ.env_script``:
102 .. code-block:: python
106 env_script : 'lapack.py'
109 Please note that the two modes are complementary and are both taken into account.
110 Most of the time, the first mode is sufficient.
112 The second mode can be used when the environment has to be set programmatically.
113 The developer implements a handle (as a python method)
114 which is called by sat to set the environment.
117 .. code-block:: python
120 #!/usr/bin/env python
121 #-*- coding:utf-8 -*-
126 def set_env(env, prereq_dir, version):
127 env.set("TRUST_ROOT_DIR",prereq_dir)
128 env.prepend('PATH', os.path.join(prereq_dir, 'bin'))
129 env.prepend('PATH', os.path.join(prereq_dir, 'include'))
130 env.prepend('LD_LIBRARY_PATH', os.path.join(prereq_dir, 'lib'))
133 SalomeTools defines four handles:
135 * **set_env(env, prereq_dir, version)** : used at build and run time.
136 * **set_env_launch(env, prereq_dir, version)** : used only at run time (if defined!)
137 * **set_env_build(env, prereq_dir, version)** : used only at build time (if defined!)
138 * **set_native_env(env)** : used only for native products, at build and run time.