]> SALOME platform Git repositories - tools/sat.git/blob - doc/src/commands/environ.rst
Salome HOME
Merge branch 'cvw/sprint_180319' of https://codev-tuleap.cea.fr/plugins/git/spns...
[tools/sat.git] / doc / src / commands / environ.rst
1
2 Command environ
3 ****************
4
5 Description
6 ===========
7 The **environ** command generates the environment files used to run and compile SALOME.
8 Please note that these files are not required, 
9 salomeTool set the environment himself, when compiling.
10 And so does the salome launcher.
11 These files are useful when someone wants to check the environment.
12 They could be used in debug mode to set the environment for gdb.
13 The configuration part at the end of this page explains how 
14 to specify the environment which will be used by sat (at build or run time), 
15 and which is written in files by sat environ command.
16
17 Usage
18 =====
19 * Create the (sh) environment files of the application: ::
20
21     sat environ <application>
22
23 * Create the environment files of the application for a given shell. 
24   Options are bash, bat (for windows) and cfg (the configuration format used by salomé): ::
25
26     sat environ <application> --shell [bash|cfg|all]
27
28 * Use a different prefix for the files (default is 'env'): ::
29
30     sat environ <application> --prefix <prefix>
31     This will create file <prefix>_launch.sh, <prefix>_build.sh...
32
33 * Use a different target directory for the files: ::
34
35     sat environ <application> --target <path>
36     This will create file env_launch.sh, env_build.sh... in the directory corresponding to <path>
37
38 * Generate the environment files only with the given products: ::
39
40     sat environ <application> --product <product1> --product <product2> ....
41     This will create the environment files only for the given products and their prerequisites.
42     It is useful when you want to visualise which environment uses sat to compile a given product.
43
44
45 Configuration
46 =============
47
48 The specification of the environment can be done through sevaral mechanisms.
49
50 1. For salome products (the products with the property is_SALOME_module : "yes") the environment is set automatically by sat, in respect with Salomé requirements.
51
52 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.
53
54 Within the section, the user can define environment variables. He can also modify PATH variables, by appending or prepending directories.
55 In the following example, we prepend <install_dir>/lib to LD_LIBRARY_PATH (note the underscore before), append <install_dir>/lib to PYTHONPATH (the underscore is after!), and set LAPACK_ROOT_DIR  to <install_dir>: ::
56
57     environ :
58     {
59        _LD_LIBRARY_PATH : $install_dir + $VARS.sep + "lib"
60        PYTHONPATH_ : $install_dir + $VARS.sep + "lib"
61        LAPACK_ROOT_DIR : $install_dir
62     }
63
64 It is possible here to distinguish the build environment from the launch environment. For that, 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: ::
65
66     environ :
67     {
68         build
69         {
70             LAPACK_ROOT_DIR : $install_dir
71         }
72         launch
73         {
74             LAPACK_ROOT_DIR : $install_dir
75            _LD_LIBRARY_PATH : $install_dir + $VARS.sep + "lib"
76            PYTHONPATH_ : $install_dir + $VARS.sep + "lib"
77         }
78     }
79
80 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 **env_script**: ::
81
82     environ :
83     {
84         env_script : "lapack.py"   
85     }
86
87 Please note that the two modes are complementary and are both taken into account.
88 Most of the time, the first mode is sufficient. The second mode can be used when the environment has to be set programmatically.
89 Here is an example: ::
90
91     #!/usr/bin/env python
92     #-*- coding:utf-8 -*-
93
94     import os.path
95     import platform
96
97     def set_env(env, prereq_dir, version):
98         env.set("TRUST_ROOT_DIR",prereq_dir)
99         env.prepend('PATH', os.path.join(prereq_dir, 'bin'))
100         env.prepend('PATH', os.path.join(prereq_dir, 'include'))
101         env.prepend('LD_LIBRARY_PATH', os.path.join(prereq_dir, 'lib'))
102         pass
103
104 The developer implements a handle which is called by sat to set the environment.
105 sat defines four handles:
106
107 * *set_env(env, prereq_dir, version)* : used at build and run time. 
108 * *set_env_launch(env, prereq_dir, version)* : used only at run time (if defined!)
109 * *set_env_build(env, prereq_dir, version)* : used only at build time (if defined!)
110 * *set_native_env(env)* : used only for native products, at build and run time.