source: rtems-source-builder/source-builder/sb/darwin.py @ cb12e48

4.104.114.95
Last change on this file since cb12e48 was cb12e48, checked in by Chris Johns <chrisj@…>, on 04/09/13 at 03:51:43

Refactor defaults, macros and options.

To support building snapshots and pre-release source the defaults
has been refactored. The defaults have been moved to a stand alone
file and a macros.py module added. This modile abstracts the
old default dictionary turning it into a class. The macros
class can load macros from a file therefore the defaults have
been moved to a stand alone file.

The use of defaults has been removed from the project. The only
case where it is used in the options where the defaults are read
from a file. Macros are used everywhere now.

The defaults.py has been moved to the option.py and the separate
options and defaults values has been moved to a new pattern. When
constructing an object that needs macros and options if the macros
passed in is None the defaults from the options are used. This makes
it clear when the defaults are being used or when a modified set of
macros is being used.

The macros class support maps. The default is 'global' and where all
the defaults reside and where configuratiion file changes end up.
Maps allow macros to be read from a file and override the values
being maintained in the 'global' map. Reading a macro first checks
the map and if not present checks the 'global' map.

The addition of maps to the macros provides the base to support
snapshots and pre-release testing with standard configurations.
This functionality needs to be added. It works by letting to
specify a snapshot with:

source0: none, override, 'my-dist.tar.bz2'

and it will be used rather the value from the standard configuration.
With a build set you need to also specify the package these macros
are for. The maps provide this.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# This code is based on what ever doco about spec files I could find and
22# RTEMS project's spec files.
23#
24
25import os
26
27import execute
28
29def load():
30    uname = os.uname()
31    sysctl = '/usr/sbin/sysctl '
32    e = execute.capture_execution()
33    exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
34    if exit_code == 0:
35        ncpus = output.split(' ')[1].strip()
36    else:
37        ncpus = '1'
38    defines = {
39        '_ncpus':       ('none',    'none',     ncpus),
40        '_os':          ('none',    'none',     'darwin'),
41        '_host':        ('triplet', 'required', uname[4] + '-apple-darwin' + uname[2]),
42        '_host_vendor': ('none',    'none',     'apple'),
43        '_host_os':     ('none',    'none',     'darwin'),
44        '_host_cpu':    ('none',    'none',     uname[4]),
45        '_host_alias':  ('none',    'none',     '%{nil}'),
46        '_host_arch':   ('none',    'none',     uname[4]),
47        '_usr':         ('dir',     'optional', '/usr/local'),
48        '_var':         ('dir',     'optional', '/usr/local/var'),
49        '_prefix':      ('dir',     'optional', '%{_usr}'),
50        'optflags':     ('none',    'none',     '-O2'),
51        '__ldconfig':   ('exe',     'none',     ''),
52        '__xz':         ('exe',     'required', '%{_usr}/bin/xz'),
53        'with_zlib':    ('none',    'none',     '--with-zlib=no')
54        }
55    return defines
56
57if __name__ == '__main__':
58    import pprint
59    pprint.pprint(load())
Note: See TracBrowser for help on using the repository browser.