Changes between Version 1 and Version 2 of Soclib Cc/Soclib Conf


Ignore:
Timestamp:
May 19, 2010, 10:36:07 PM (14 years ago)
Author:
Nicolas Pouillon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Soclib Cc/Soclib Conf

    v1 v2  
    66SoCLib's configuration file is used by [SoclibCc soclib-cc] to find
    77your tools paths. You may override:
    8  * SystemC implementation to use (its paths, ...)
    9  * Compiler and compiler flags
    10  * Where objects reside
     8 * 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, ...)
    1111
    1212Let's suppose we want to override SystemC's path, we can write the following `~/.soclib/global.conf`:
    1313{{{
    14 config.systemc_22 = Config(
    15         base = config.systemc,
     14config.libsystemc_22 = Library(
     15        parent = config.systemc,
    1616        dir = "/home/me/tools/systemc/2.2"
    1717        )
    1818
    19 config.default = Config(
    20         base = config.default,
    21         systemc = config.systemc_22
    22         )
     19config.foo = BuildEnv(
     20        parent = config.build_env,
     21        libraries = [config.libsystemc_22],
     22        )
     23
     24config.default = config.foo
    2325}}}
    2426
    2527Now 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,
     28We don't want compiled objects to mix-up, so we'll set another repository for built files.
     29
     30{{{
     31config.libsystemcass = Library(
     32        parent = config.systemc,
    3133        dir = "/home/me/tools/systemc/cass",
    3234        libs = config.systemc.libs + ["-Wl,-rpath,%(libdir)s", "-ldl", "-fopenmp"],
    3335        )
    3436
    35 config.use_systemcass = Config(
    36         base = config.default,
     37config.systemcass = BuildEnv(
     38        parent = config.default,
    3739        repos = "repos/systemcass_objs",
    38         systemc = config.systemc_cass
     40        libraries = [config.libsystemccass],
    3941        )
    4042}}}
     
    4244Now if we want to compile a platform with SystemCass, the only thing to is to tell it to `soclib-cc`:
    4345{{{
    44 $ soclib-cc -t use_systemcass
     46$ soclib-cc -t systemcass
    4547}}}
    4648
    4749The argument after `-t` is the configuration name, attribute set to `config` in this line:
    4850{{{
    49 config.use_systemcass = Config( ....
    50 }}}
     51config.systemcass = BuildEnv( ....
     52}}}
     53
     54The only configuration names that can be passed to `-t` are the ones associated to `BuildEnv`s.
    5155
    5256= The long theory =
    5357
    54 == Default configuration ==
     58== Configuration objects ==
    5559
    5660SoCLib's configuration file is using inherence in order to be able to share
    5761parameters among different similar instances.
    5862
    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:
     63There 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
     68You must define a set of these classes. There is
     69a default configuration. It is composed of 3
     70default configuration classes:
    6571 * `config.systemc`.
    66    * It inherits from `config.systemc`, you may inherit from either of them
     72   * It is a `Library`.
    6773   * 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.
    7180
    7281== Inheriting ==
    7382
    74 Inherence is written using `base =` as follows:
    75 {{{
    76 my_new_config = Config(
    77     base = parent,
    78     other_var = ....
     83Inherence is written using `parent =` as follows:
     84{{{
     85config.my_new_toolchain = Toolchain(
     86    parent = config.toolchain,
     87    cflags = ....
    7988    )
    8089}}}
    8190
    8291`config` is a global object defined by configuration system. It holds current configuration status.
     92
     93== Inherence and default fields values ==
     94
     95Using a `parent` is optional. If you use `parent =`, all the parent's fields are used
     96as default values for the newly created configuration. Thus you only have to override
     97custom fields.
     98
     99You can also use no `parent`, then all fields are needed, see below for the list.
    83100
    84101== Variables ==
     
    90107
    91108{{{
    92 
    93109# Defining a SystemC implementation inheriting everything
    94110# from default SystemC declaration
    95 config.systemc_22 = Config(
    96         base = config.systemc,
     111config.libsystemc_22 = Library(
     112        parent = config.systemc,
    97113        dir = "/home/me/tools/systemc/2.2"
    98114        )
    99115
    100116# 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
     118config.sc22 = BuildEnv(
     119        parent = config.build_env,
     120        libraries = [config.libsystemc_22],
     121        )
     122config.default = config.sc22
    106123
    107124# Now with SystemCASS
    108125
    109126# Declare a new SystemC implementation
    110 config.systemc_cass = Config(
    111         base = config.systemc,
     127config.libsystemccass = Library(
     128        parent = config.systemc,
    112129        dir = "/home/me/tools/systemc/cass",
    113130        )
    114131
    115 config.use_systemcass = Config(
    116         base = config.default,
     132config.scass = BuildEnv(
     133        parent = config.default,
    117134
    118135        # This defines a new path to store compiled objects to
     
    122139        # and here we tell this configuration use the SystemC implentation
    123140        # declared above.
    124         systemc = config.systemc_cass,
     141        libraries = [config.libsystemcass],
    125142        )
    126143}}}
     
    131148value of `name` attribute in the same class. See `systemc` definition below.
    132149
    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"
     150cflags, <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.
    155158 `libs`::
    156159  Link flags. default: ['-L%(libdir)s', '-lsystemc']
    157160 `cflags`::
    158161  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{{{
     178config.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}}}
    159195
    160196== Toolchain ==
    161197
    162198 `prefix`::
    163   a string prepended to all tollchain tools. (eg: "i686-pc-linux-gnu-")
     199  a string prepended to all toolchain tools.
    164200 `cflags`::
    165   global cflags. default: "-Wall"
     201  global cflags.
    166202 `libs`::
    167   global linking arguments. default: "-lbfd"
     203  global linking arguments.
    168204 `release_cflags`::
    169   cflags used for a "release" build, ie everyday build. default: "-O2"
     205  cflags used for a "release" build, ie everyday build.
    170206 `release_libs`::
    171   linking arguments for a "release" build. default: none
     207  linking arguments for a "release" build.
    172208 `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.
    174210 `debug_libs`::
    175   linking arguments for a "debug" build. default: none
     211  linking arguments for a "debug" build.
    176212 `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.
    178214 `prof_libs`::
    179   linking arguments for a "profiling" build. default: "-pg"
     215  linking arguments for a "profiling" build.
    180216 `max_processes`::
    181217  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
     225This is the one you may specify from command line with `-t`. By default, this is
     226the 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)
    182234 `max_name_length`::
    183235  Maximum file name length for the file system `repos`
    184236  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`.
    190243
    191244= Adding other component libraries to soclib-cc search path =
    192245
    193246Soclib-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:
     247be tweaked to add other paths on search list. Simply call `addDescPath`:
    196248{{{
    197249config.addDescPath("/path/to/my/components")