mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
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.
This commit is contained in:
@@ -34,10 +34,10 @@ import urlparse
|
||||
try:
|
||||
import check
|
||||
import config
|
||||
import defaults
|
||||
import error
|
||||
import execute
|
||||
import log
|
||||
import options
|
||||
import path
|
||||
import version
|
||||
except KeyboardInterrupt:
|
||||
@@ -99,11 +99,15 @@ class script:
|
||||
class build:
|
||||
"""Build a package given a config file."""
|
||||
|
||||
def __init__(self, name, create_tar_files, _defaults, opts):
|
||||
def __init__(self, name, create_tar_files, opts, macros = None):
|
||||
self.opts = opts
|
||||
if macros is None:
|
||||
self.macros = opts.defaults
|
||||
else:
|
||||
self.macros = macros
|
||||
self.create_tar_files = create_tar_files
|
||||
_notice(opts, 'config: ' + name)
|
||||
self.config = config.file(name, _defaults = _defaults, opts = opts)
|
||||
self.config = config.file(name, opts, self.macros)
|
||||
self.script = script(quiet = opts.quiet(), trace = opts.trace())
|
||||
|
||||
def _output(self, text):
|
||||
@@ -481,7 +485,7 @@ class build:
|
||||
package = packages['main']
|
||||
return package.name()
|
||||
|
||||
def get_configs(opts, _defaults):
|
||||
def get_configs(opts):
|
||||
|
||||
def _scan(_path, ext):
|
||||
configs = []
|
||||
@@ -494,7 +498,7 @@ def get_configs(opts, _defaults):
|
||||
return configs
|
||||
|
||||
configs = { 'paths': [], 'files': [] }
|
||||
for cp in opts.expand('%{_configdir}', _defaults).split(':'):
|
||||
for cp in opts.defaults.expand('%{_configdir}').split(':'):
|
||||
hcp = path.host(path.abspath(cp))
|
||||
configs['paths'] += [hcp]
|
||||
configs['files'] += _scan(hcp, ['.cfg', '.bset'])
|
||||
@@ -516,16 +520,16 @@ def find_config(config, configs):
|
||||
def run(args):
|
||||
try:
|
||||
optargs = { '--list-configs': 'List available configurations' }
|
||||
opts, _defaults = defaults.load(args, optargs)
|
||||
opts = options.load(args, optargs)
|
||||
log.default = log.log(opts.logfiles())
|
||||
_notice(opts, 'RTEMS Source Builder, Package Builder v%s' % (version.str()))
|
||||
if not check.host_setup(opts, _defaults):
|
||||
if not check.host_setup(opts):
|
||||
if not opts.force():
|
||||
raise error.general('host build environment is not set up' +
|
||||
' correctly (use --force to proceed)')
|
||||
_notice(opts, 'warning: forcing build with known host setup problems')
|
||||
if opts.get_arg('--list-configs'):
|
||||
configs = get_configs(opts, _defaults)
|
||||
configs = get_configs(opts)
|
||||
for p in configs['paths']:
|
||||
print 'Examining: %s' % (os.path.relpath(p))
|
||||
for c in configs['files']:
|
||||
@@ -533,7 +537,7 @@ def run(args):
|
||||
print ' %s' % (c)
|
||||
else:
|
||||
for config_file in opts.config_files():
|
||||
b = build(config_file, True, _defaults = _defaults, opts = opts)
|
||||
b = build(config_file, True, opts)
|
||||
b.make()
|
||||
del b
|
||||
except error.general, gerr:
|
||||
|
Reference in New Issue
Block a user