Changeset 624954b in rtems-source-builder


Ignore:
Timestamp:
Apr 26, 2013, 2:05:53 AM (6 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 4.9, master
Children:
dbede73
Parents:
8f30997
Message:

Add macro include support. Use it for building from head.

This change provides a simple way to build all parts of the tools from
version control.

Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • doc/source-builder.txt

    r8f30997 r624954b  
    780780currently detected and will cause the tool to lock up.
    781781
    782 Maps are declared anywhere in the map using:
     782Maps are declared anywhere in the map using the map directive:
    783783
    784784-------------------------------------------------------------
    785785# Comments
    786 [my-special-map]
     786[my-special-map] <1>
    787787_host:  none, override, 'abc-xyz'
    788788multiline: none, override, '''First line,
     
    790790and finally the last line'''
    791791-------------------------------------------------------------
     792<1> The map is set to `my-special-map`.
    792793
    793794Any macro defintions following a map declaration are placed in that map and the
     
    804805please make sure you use the `override` attibute.
    805806
    806 The macro files are looked for in the `_configdir` paths. See
    807 <<X1,+_configdir+>> variable for details.
     807The macro files specificed on the command line are looked for in the
     808`_configdir` paths. See <<X1,+_configdir+>> variable for details. Included
     809files need to add the `%{_configdir}` macro to the start of the file.
     810
     811Macro map files can include other macro map files using the `%include`
     812directive. The macro map to build _binutils_, _gcc_, _newlib_, _gdb_ and
     813_RTEMS_ from version control heads is:
     814
     815-------------------------------------------------------------
     816# <1>
     817# Build all tool parts from version control head.
     818#
     819%include %{_configdir}/snapshots/binutils-head.mc
     820%include %{_configdir}/snapshots/gcc-head.mc
     821%include %{_configdir}/snapshots/newlib-head.mc
     822%include %{_configdir}/snapshots/gdb-head.mc
     823-------------------------------------------------------------
     824<1> The file is `config/snapshots/binutils-gcc-newlib-gdb-head.mc`.
     825
     826The macro map defaults to `global` at the start of each included file and the
     827map setting of the macro file including the other macro files does not change.
    808828
    809829Build Set Files
     
    16391659To build snapshots for testing purposes you use the available macro maps
    16401660passing them on the command line using the `--macros` option. For RTEMS these
    1641 are held in `config/snapshots` directory. The following build _newlib_ from
     1661are held in `config/snapshots` directory. The following builds _newlib_ from
    16421662CVS:
    16431663
    16441664-------------------------------------------------------------
    16451665$ ../source-builder/sb-set-builder --log=l-4.11-sparc.txt \
    1646    --prefix=$HOME/development/rtems/4.11 --macros=snapshots/newlib-head.mc
     1666   --prefix=$HOME/development/rtems/4.11 \
     1667   --macros=snapshots/newlib-head.mc \
     1668   4.11/rtems-sparc
     1669-------------------------------------------------------------
     1670
     1671and the following uses the version control heads for _binutils_, _gcc_,
     1672_newlib_, _gdb_ and _RTEMS_:
     1673
     1674-------------------------------------------------------------
     1675$ ../source-builder/sb-set-builder --log=l-heads-sparc.txt \
     1676   --prefix=$HOME/development/rtems/4.11-head \
     1677   --macros=snapshots/binutils-gcc-newlib-gdb-head.mc \
    16471678   4.11/rtems-sparc
    16481679-------------------------------------------------------------
  • source-builder/config/snapshots/gdb-head.mc

    r8f30997 r624954b  
    11[gdb-snapshot]
    22GDB_Version: none, override, 'cvs-head'
    3 Source0:     none, override, 'cvs://pserver:anoncvs@sourceware.org/cvs/src?module=gdb?src-prefix=src'
     3Source0:     none, override, 'cvs://pserver:anoncvs@sourceware.org/cvs/src?module=gdb?src-prefix=src?update'
    44Patch0:      none, undefine, ''
    55Patch1:      none, undefine, ''
  • source-builder/sb/macros.py

    r8f30997 r624954b  
    187187
    188188    def parse(self, lines):
     189
     190        def _clean(l):
     191            if '#' in l:
     192                l = l[:l.index('#')]
     193            if '\r' in l:
     194                l = l[:l.index('r')]
     195            if '\n' in l:
     196                l = l[:l.index('\n')]
     197            return l.strip()
     198
     199        trace_me = False
     200        if trace_me:
     201            print '[[[[]]]] parsing macros'
    189202        macros = { 'global': {} }
    190203        map = 'global'
     
    198211            if len(l) == 0:
    199212                continue
     213            l_remaining = l
    200214            for c in l:
    201                 #print ']]]]]]]] c:%s(%d) s:%s t:"%s" m:%r M:%s' % (c, ord(c), state, token, macro, map)
     215                if trace_me:
     216                    print ']]]]]]]] c:%s(%d) s:%s t:"%s" m:%r M:%s' % \
     217                        (c, ord(c), state, token, macro, map)
     218                l_remaining = l_remaining[1:]
    202219                if c is '#' and not state.startswith('value'):
    203220                    break
     
    210227                        if c is '[':
    211228                            state = 'map'
     229                        elif c is '%':
     230                            state = 'directive'
    212231                        elif c is ':':
    213232                            macro += [token]
     
    229248                    else:
    230249                        raise error.general('invalid macro map:%d: %s' % (lc, l))
     250                elif state is 'directive':
     251                    if c in string.whitespace:
     252                        if token == 'include':
     253                            self.load(_clean(l_remaining))
     254                            token = ''
     255                            state = 'key'
     256                            break
     257                    elif c in string.printable and c not in string.whitespace:
     258                        token += c
     259                    else:
     260                        raise error.general('invalid macro directive:%d: %s' % (lc, l))
     261                elif state is 'include':
     262                    if c is string.whitespace:
     263                        if token == 'include':
     264                            state = 'include'
     265                    elif c in string.printable and c not in string.whitespace:
     266                        token += c
     267                    else:
     268                        raise error.general('invalid macro directive:%d: %s' % (lc, l))
    231269                elif state is 'attribs':
    232270                    if c not in string.whitespace:
     
    291329
    292330    def load(self, name):
    293         try:
    294             name = self.expand(name)
    295             mc = open(name, 'r')
    296         except IOError, err:
    297             raise error.general('opening macro file: %s' % (path.host(name)))
    298         macros = self.parse(mc)
    299         mc.close()
    300         self.files += [name]
     331        names = self.expand(name).split(':')
     332        for n in names:
     333            if path.exists(n):
     334                try:
     335                    mc = open(n, 'r')
     336                    macros = self.parse(mc)
     337                    mc.close()
     338                    self.files += [n]
     339                    return
     340                except IOError, err:
     341                    pass
     342        raise error.general('opening macro file: %s' % (path.host(name)))
    301343
    302344    def get(self, key):
Note: See TracChangeset for help on using the changeset viewer.