Changes between Version 1 and Version 2 of Soclib Cc/Soclib Conf
- Timestamp:
- May 19, 2010, 10:36:07 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Soclib Cc/Soclib Conf
v1 v2 6 6 SoCLib's configuration file is used by [SoclibCc soclib-cc] to find 7 7 your tools paths. You may override: 8 * SystemC implementation to use (its paths, ...)9 * Compiler and compiler flags10 * Where objects reside8 * libraries: SystemC implementation to use (its paths, ...), tlm, ... 9 * toolchain: Compiler and compiler flags 10 * build env: toolchain, libraries and other flags (where objects reside, ...) 11 11 12 12 Let's suppose we want to override SystemC's path, we can write the following `~/.soclib/global.conf`: 13 13 {{{ 14 config. systemc_22 = Config(15 base= config.systemc,14 config.libsystemc_22 = Library( 15 parent = config.systemc, 16 16 dir = "/home/me/tools/systemc/2.2" 17 17 ) 18 18 19 config.default = Config( 20 base = config.default, 21 systemc = config.systemc_22 22 ) 19 config.foo = BuildEnv( 20 parent = config.build_env, 21 libraries = [config.libsystemc_22], 22 ) 23 24 config.default = config.foo 23 25 }}} 24 26 25 27 Now let's suppose we would like to add another configuration where we use SystemCass. 26 We don't want compiled objects to mix-up, so we'll set another built files repository.27 28 {{{ 29 config. systemc_cass = Config(30 base= config.systemc,28 We don't want compiled objects to mix-up, so we'll set another repository for built files. 29 30 {{{ 31 config.libsystemcass = Library( 32 parent = config.systemc, 31 33 dir = "/home/me/tools/systemc/cass", 32 34 libs = config.systemc.libs + ["-Wl,-rpath,%(libdir)s", "-ldl", "-fopenmp"], 33 35 ) 34 36 35 config. use_systemcass = Config(36 base= config.default,37 config.systemcass = BuildEnv( 38 parent = config.default, 37 39 repos = "repos/systemcass_objs", 38 systemc = config.systemc_cass40 libraries = [config.libsystemccass], 39 41 ) 40 42 }}} … … 42 44 Now if we want to compile a platform with SystemCass, the only thing to is to tell it to `soclib-cc`: 43 45 {{{ 44 $ soclib-cc -t use_systemcass46 $ soclib-cc -t systemcass 45 47 }}} 46 48 47 49 The argument after `-t` is the configuration name, attribute set to `config` in this line: 48 50 {{{ 49 config.use_systemcass = Config( .... 50 }}} 51 config.systemcass = BuildEnv( .... 52 }}} 53 54 The only configuration names that can be passed to `-t` are the ones associated to `BuildEnv`s. 51 55 52 56 = The long theory = 53 57 54 == Default configuration==58 == Configuration objects == 55 59 56 60 SoCLib's configuration file is using inherence in order to be able to share 57 61 parameters among different similar instances. 58 62 59 There are 3 base configurations to inherit from: 60 * `config.toolchain` to define a compiler suite 61 * `config.systemc` to define a SystemC implementation 62 * `config.build_env` to define a build environment. This one must reference one instance of each of the above. 63 64 There are 2 default configuration classes: 63 There are 3 base configurations objects to define: 64 * `Toolchain` to define a compiler suite 65 * `Library` to define a library, like a SystemC implementation 66 * `BuildEnv` to define a build environment. This one must reference one instance of each of the above. 67 68 You must define a set of these classes. There is 69 a default configuration. It is composed of 3 70 default configuration classes: 65 71 * `config.systemc`. 66 * It i nherits from `config.systemc`, you may inherit from either of them72 * It is a `Library`. 67 73 * It expects the environment variable `$SYSTEMC` to point to your actual SystemC installation directory 68 * `config.default`. 69 * It inherits from `config.build_env`, you may inherit from either of them 70 * It uses the default compiler (`gcc` & `g++`) and `config.systemc` 74 * `config.toolchain`. 75 * It is a `Toolchain`. 76 * It uses the default compiler (`gcc` & `g++`) 77 * `config.build_env`. 78 * It is a `BuildEnv`. 79 * It uses the two previous ones. 71 80 72 81 == Inheriting == 73 82 74 Inherence is written using ` base=` as follows:75 {{{ 76 my_new_config = Config(77 base = parent,78 other_var= ....83 Inherence is written using `parent =` as follows: 84 {{{ 85 config.my_new_toolchain = Toolchain( 86 parent = config.toolchain, 87 cflags = .... 79 88 ) 80 89 }}} 81 90 82 91 `config` is a global object defined by configuration system. It holds current configuration status. 92 93 == Inherence and default fields values == 94 95 Using a `parent` is optional. If you use `parent =`, all the parent's fields are used 96 as default values for the newly created configuration. Thus you only have to override 97 custom fields. 98 99 You can also use no `parent`, then all fields are needed, see below for the list. 83 100 84 101 == Variables == … … 90 107 91 108 {{{ 92 93 109 # Defining a SystemC implementation inheriting everything 94 110 # from default SystemC declaration 95 config. systemc_22 = Config(96 base= config.systemc,111 config.libsystemc_22 = Library( 112 parent = config.systemc, 97 113 dir = "/home/me/tools/systemc/2.2" 98 114 ) 99 115 100 116 # Then defining a new default configuration, 101 # inheriting from previous default configuration 102 config.default = Config( 103 base = config.default, 104 systemc = config.systemc_22, 105 ) 117 # inheriting from default build environment 118 config.sc22 = BuildEnv( 119 parent = config.build_env, 120 libraries = [config.libsystemc_22], 121 ) 122 config.default = config.sc22 106 123 107 124 # Now with SystemCASS 108 125 109 126 # Declare a new SystemC implementation 110 config. systemc_cass = Config(111 base= config.systemc,127 config.libsystemccass = Library( 128 parent = config.systemc, 112 129 dir = "/home/me/tools/systemc/cass", 113 130 ) 114 131 115 config. use_systemcass = Config(116 base= config.default,132 config.scass = BuildEnv( 133 parent = config.default, 117 134 118 135 # This defines a new path to store compiled objects to … … 122 139 # and here we tell this configuration use the SystemC implentation 123 140 # declared above. 124 systemc = config.systemc_cass,141 libraries = [config.libsystemcass], 125 142 ) 126 143 }}} … … 131 148 value of `name` attribute in the same class. See `systemc` definition below. 132 149 133 == Build environment == 134 135 This is the one you may specify from command line with `-t`. By default, this is 136 `default`. It inherits directly or indirectly from `config.build_env`. 137 138 toolchain:: 139 A class derived from `config.toolchain` 140 systemc:: 141 A class derived from `config.systemc` 142 mode:: 143 Default mode. default: "release" 144 repos:: 145 Path where object files are stored, it may be absolute or relative to current path (where soclib-cc is run) 146 147 == SystemC == 148 149 `dir`:: 150 The directory containing SystemC installation 151 `os`:: 152 The current os, for expansion in following variable 153 `libdir`:: 154 "%(dir)s/lib-%(os)s" 150 cflags, <mode>_cflags, libs, <mode>_libs are all optional. 151 152 == Library == 153 154 `name`:: 155 Name of the library (what it implements), "systemc" is currently the only specified value. 156 `vendor`:: 157 Provider of the library, used for some quirks in soclib-cc. "modelsim" and "OSCI" are currently the only specified values. 155 158 `libs`:: 156 159 Link flags. default: ['-L%(libdir)s', '-lsystemc'] 157 160 `cflags`:: 158 161 Cflags. default: [ '-I%(dir)s/include' ] 162 `release_cflags`:: 163 cflags used for a "release" build, ie everyday build. 164 `release_libs`:: 165 linking arguments for a "release" build. 166 `debug_cflags`:: 167 cflags used for a "debug" build, ie when there is a bug to nail down. 168 `debug_libs`:: 169 linking arguments for a "debug" build. 170 `prof_cflags`:: 171 cflags used for a "profiling" build, ie performance test build. 172 `prof_libs`:: 173 linking arguments for a "profiling" build. 174 175 176 [source:trunk/soclib/utils/lib/python/soclib_cc/config/built-in.conf#L38 Default config.systemc] example: 177 {{{ 178 config.systemc = Library( 179 name = 'systemc', 180 vendor = 'OSCI', 181 libs = ['-L%(libdir)s', '-lsystemc', '-lpthread'], 182 cflags = ['-I%(dir)s/include'], 183 184 # libs and cflags are implemented a generic way, now we 185 # have to provide "libdir" and "dir" 186 187 libdir = '%(dir)s/lib-%(os)s', 188 dir = "${SYSTEMC}", 189 190 # Again, libdir uses 'dir' and 'os', thus we have to define "os" 191 # here we use the value provided by a function. 192 os = _platform(), 193 ) 194 }}} 159 195 160 196 == Toolchain == 161 197 162 198 `prefix`:: 163 a string prepended to all to llchain tools. (eg: "i686-pc-linux-gnu-")199 a string prepended to all toolchain tools. 164 200 `cflags`:: 165 global cflags. default: "-Wall"201 global cflags. 166 202 `libs`:: 167 global linking arguments. default: "-lbfd"203 global linking arguments. 168 204 `release_cflags`:: 169 cflags used for a "release" build, ie everyday build. default: "-O2"205 cflags used for a "release" build, ie everyday build. 170 206 `release_libs`:: 171 linking arguments for a "release" build. default: none207 linking arguments for a "release" build. 172 208 `debug_cflags`:: 173 cflags used for a "debug" build, ie when there is a bug to nail down. default: "-ggdb"209 cflags used for a "debug" build, ie when there is a bug to nail down. 174 210 `debug_libs`:: 175 linking arguments for a "debug" build. default: none211 linking arguments for a "debug" build. 176 212 `prof_cflags`:: 177 cflags used for a "profiling" build, ie performance test build. default: "-pg"213 cflags used for a "profiling" build, ie performance test build. 178 214 `prof_libs`:: 179 linking arguments for a "profiling" build. default: "-pg"215 linking arguments for a "profiling" build. 180 216 `max_processes`:: 181 217 Maximum simultaneous compilation processes run (same as -j command-line flag) 218 219 * Cflags used for compilation will be `cflags` + ''mode''`_cflags` 220 * Libs used for compilation will be `libs` + ''mode''`_libs` 221 * ''mode'' is selected in current build environment, or on command line (flag `-m`) 222 223 == Build environment == 224 225 This is the one you may specify from command line with `-t`. By default, this is 226 the configuration set to `config.default` last. The following fields must be set. 227 228 `toolchain`:: 229 A `Toolchain` to use for compilation 230 `libraries`:: 231 A list (enclosed in []) of `Library` to be used for compilation and linkage of programs. 232 `repos`:: 233 Path where object files are stored, it may be absolute or relative to current path (where soclib-cc is run) 182 234 `max_name_length`:: 183 235 Maximum file name length for the file system `repos` 184 236 is located in. If object file has a longer name, 185 it is hashed to get a shorter one, around 16 chars. 186 187 * Cflags used for compilation will be `cflags` + ''mode''`_cflags` 188 * Libs used for compilation will be `libs` + ''mode''`_libs` 189 * ''mode'' is selected in current build environment, or on command line (flag `-m`) 237 it is hashed to get a shorter one, around 12 chars. 238 `repos`:: 239 A directory to store temporary build files. 240 `cache_file`:: 241 A path to a file where to store metadata file indexation cache. Default is 242 "%(repos)s/soclib_cc.cache", i.e. a path relative to `repos`. 190 243 191 244 = Adding other component libraries to soclib-cc search path = 192 245 193 246 Soclib-cc searches metadata files in soclib's module directories. This default behavior can 194 be tweaked to add other paths on search list. Simply call `addDescPath` in any of your configuration 195 files: 247 be tweaked to add other paths on search list. Simply call `addDescPath`: 196 248 {{{ 197 249 config.addDescPath("/path/to/my/components")