mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
5/llvm: Add LLVM as a package for RTEMS.
- Add '%source download <source>' to only download the source and do not unpack and prep. This can used when a package internally needs another source package. - Install the staging root only if it is present. A package may internally build another package that is not staged as it is not suitable for installing. Updates #3250 Updatew #3797
This commit is contained in:
@@ -203,7 +203,7 @@ class build:
|
||||
not _disable_installing and \
|
||||
not _canadian_cross
|
||||
|
||||
def source(self, name, strip_components):
|
||||
def source(self, name, strip_components, download_only):
|
||||
#
|
||||
# Return the list of sources. Merge in any macro defined sources as
|
||||
# these may be overridden by user loaded macros.
|
||||
@@ -238,31 +238,37 @@ class build:
|
||||
if o.startswith('--rsb-file'):
|
||||
os_ = o.split('=')
|
||||
if len(os_) != 2:
|
||||
raise error.general('invalid --rsb-file option: %s' % (' '.join(args)))
|
||||
raise error.general('invalid --rsb-file option: %s' % \
|
||||
(' '.join(args)))
|
||||
if os_[0] != '--rsb-file':
|
||||
raise error.general('invalid --rsb-file option: %s' % (' '.join(args)))
|
||||
raise error.general('invalid --rsb-file option: %s' % \
|
||||
(' '.join(args)))
|
||||
file_override = os_[1]
|
||||
opts = [o for o in opts if not o.startswith('--rsb-')]
|
||||
url = self.config.expand(' '.join(url))
|
||||
src = download.parse_url(url, '_sourcedir', self.config, self.opts, file_override)
|
||||
src = download.parse_url(url, '_sourcedir',
|
||||
self.config, self.opts, file_override)
|
||||
download.get_file(src['url'], src['local'], self.opts, self.config)
|
||||
if strip_components > 0:
|
||||
tar_extract = '%%{__tar_extract} --strip-components %d' % (strip_components)
|
||||
else:
|
||||
tar_extract = '%{__tar_extract}'
|
||||
if 'symlink' in src:
|
||||
sname = name.replace('-', '_')
|
||||
src['script'] = '%%{__ln_s} %s ${source_dir_%s}' % (src['symlink'], sname)
|
||||
elif 'compressed' in src:
|
||||
#
|
||||
# Zip files unpack as well so do not use tar.
|
||||
#
|
||||
src['script'] = '%s %s' % (src['compressed'], src['local'])
|
||||
if src['compressed-type'] != 'zip':
|
||||
src['script'] += ' | %s -f -' % (tar_extract)
|
||||
else:
|
||||
src['script'] = '%s -f %s' % (tar_extract, src['local'])
|
||||
srcs += [src]
|
||||
if not download_only:
|
||||
if strip_components > 0:
|
||||
tar_extract = '%%{__tar_extract} --strip-components %d' % \
|
||||
(strip_components)
|
||||
else:
|
||||
tar_extract = '%{__tar_extract}'
|
||||
if 'symlink' in src:
|
||||
sname = name.replace('-', '_')
|
||||
src['script'] = '%%{__ln_s} %s ${source_dir_%s}' % \
|
||||
(src['symlink'], sname)
|
||||
elif 'compressed' in src:
|
||||
#
|
||||
# Zip files unpack as well so do not use tar.
|
||||
#
|
||||
src['script'] = '%s %s' % (src['compressed'], src['local'])
|
||||
if src['compressed-type'] != 'zip':
|
||||
src['script'] += ' | %s -f -' % (tar_extract)
|
||||
else:
|
||||
src['script'] = '%s -f %s' % (tar_extract, src['local'])
|
||||
srcs += [src]
|
||||
return srcs
|
||||
|
||||
def source_setup(self, package, args):
|
||||
@@ -270,7 +276,7 @@ class build:
|
||||
setup_name = args[1]
|
||||
args = args[1:]
|
||||
try:
|
||||
opts, args = getopt.getopt(args[1:], 'qDcn:bas:')
|
||||
opts, args = getopt.getopt(args[1:], 'qDcn:bas:g')
|
||||
except getopt.GetoptError as ge:
|
||||
raise error.general('source setup error: %s' % str(ge))
|
||||
quiet = False
|
||||
@@ -282,6 +288,7 @@ class build:
|
||||
changed_dir = False
|
||||
strip_components = 0
|
||||
opt_name = None
|
||||
download_only = False
|
||||
for o in opts:
|
||||
if o[0] == '-q':
|
||||
quiet = True
|
||||
@@ -297,30 +304,37 @@ class build:
|
||||
unpack_before_chdir = False
|
||||
elif o[0] == '-s':
|
||||
if not o[1].isdigit():
|
||||
raise error.general('source setup error: invalid strip count: %s' % (o[1]))
|
||||
raise error.general('source setup error: invalid strip count: %s' % \
|
||||
(o[1]))
|
||||
strip_components = int(o[1])
|
||||
elif o[0] == '-g':
|
||||
download_only = True
|
||||
name = None
|
||||
for source in self.source(setup_name, strip_components):
|
||||
for source in self.source(setup_name, strip_components, download_only):
|
||||
if name is None:
|
||||
if opt_name is None:
|
||||
if source:
|
||||
opt_name = source['name']
|
||||
else:
|
||||
raise error.general('setup source tag not found: %d' % (source_tag))
|
||||
raise error.general('setup source tag not found: %d' % \
|
||||
(source_tag))
|
||||
else:
|
||||
name = opt_name
|
||||
self.script_build.append(self.config.expand('cd %{_builddir}'))
|
||||
if not deleted_dir and delete_before_unpack:
|
||||
self.script_build.append(self.config.expand('%{__rm} -rf ' + name))
|
||||
deleted_dir = True
|
||||
if not created_dir and create_dir:
|
||||
self.script_build.append(self.config.expand('%{__mkdir_p} ' + name))
|
||||
created_dir = True
|
||||
if not changed_dir and (not unpack_before_chdir or create_dir):
|
||||
self.script_build.append(self.config.expand('cd ' + name))
|
||||
changed_dir = True
|
||||
self.script_build.append(self.config.expand(source['script']))
|
||||
if not changed_dir and (unpack_before_chdir and not create_dir):
|
||||
if not download_only:
|
||||
self.script_build.append(self.config.expand('cd %{_builddir}'))
|
||||
if not deleted_dir and delete_before_unpack and name is not None:
|
||||
self.script_build.append(self.config.expand('%{__rm} -rf ' + name))
|
||||
deleted_dir = True
|
||||
if not created_dir and create_dir and name is not None:
|
||||
self.script_build.append(self.config.expand('%{__mkdir_p} ' + name))
|
||||
created_dir = True
|
||||
if not changed_dir and (not unpack_before_chdir or create_dir) and \
|
||||
name is not None:
|
||||
self.script_build.append(self.config.expand('cd ' + name))
|
||||
changed_dir = True
|
||||
self.script_build.append(self.config.expand(source['script']))
|
||||
if not changed_dir and (unpack_before_chdir and not create_dir) and \
|
||||
name is not None and not download_only:
|
||||
self.script_build.append(self.config.expand('cd ' + name))
|
||||
changed_dir = True
|
||||
self.script_build.append(self.config.expand('%{__setup_post}'))
|
||||
@@ -345,7 +359,7 @@ class build:
|
||||
else:
|
||||
url += [pp]
|
||||
if len(url) == 0:
|
||||
raise error.general('patch URL not found: %s' % (' '.join(args)))
|
||||
raise error.general('patch URL not found: %s' % (' '.join(opts)))
|
||||
#
|
||||
# Look for --rsb-file as an option we use as a local file name.
|
||||
# This can be used if a URL has no reasonable file name the
|
||||
@@ -357,9 +371,11 @@ class build:
|
||||
if o.startswith('--rsb-file'):
|
||||
os_ = o.split('=')
|
||||
if len(os_) != 2:
|
||||
raise error.general('invalid --rsb-file option: %s' % (' '.join(args)))
|
||||
raise error.general('invalid --rsb-file option: %s' % \
|
||||
(' '.join(opts)))
|
||||
if os_[0] != '--rsb-file':
|
||||
raise error.general('invalid --rsb-file option: %s' % (' '.join(args)))
|
||||
raise error.general('invalid --rsb-file option: %s' % \
|
||||
(' '.join(opts)))
|
||||
file_override = os_[1]
|
||||
opts = [o for o in opts if not o.startswith('--rsb-')]
|
||||
if len(opts) == 0:
|
||||
@@ -371,7 +387,8 @@ class build:
|
||||
#
|
||||
# Parse the URL first in the source builder's patch directory.
|
||||
#
|
||||
patch = download.parse_url(url, '_patchdir', self.config, self.opts, file_override)
|
||||
patch = download.parse_url(url, '_patchdir', self.config,
|
||||
self.opts, file_override)
|
||||
#
|
||||
# Download the patch
|
||||
#
|
||||
|
@@ -52,6 +52,7 @@ def load():
|
||||
'_var': ('dir', 'optional', '/usr/local/var'),
|
||||
'_prefix': ('dir', 'optional', '%{_usr}'),
|
||||
'__ldconfig': ('exe', 'none', ''),
|
||||
'__cmake': ('exe', 'optional', 'cmake'),
|
||||
'__cvs': ('exe', 'optional', 'cvs'),
|
||||
'__xz': ('exe', 'required', 'xz'),
|
||||
'with_zlib': ('none', 'none', '--with-zlib=no'),
|
||||
|
@@ -63,6 +63,7 @@ def load():
|
||||
'_var': ('dir', 'optional', '/usr/local/var'),
|
||||
'__bash': ('exe', 'optional', '/usr/local/bin/bash'),
|
||||
'__bison': ('exe', 'required', '/usr/local/bin/bison'),
|
||||
'__cmake': ('exe', 'optional', '/usr/local/bin/cmake'),
|
||||
'__git': ('exe', 'required', '/usr/local/bin/git'),
|
||||
'__svn': ('exe', 'optional', '/usr/local/bin/svn'),
|
||||
'__unzip': ('exe', 'optional', '/usr/local/bin/unzip'),
|
||||
|
@@ -293,6 +293,8 @@ class command_line:
|
||||
'--without-log',
|
||||
'--without-error-report',
|
||||
'--without-release-url']
|
||||
if a == '--dry-run':
|
||||
self.args += ['--without-error-report']
|
||||
arg += 1
|
||||
|
||||
def post_process(self, logfile = True):
|
||||
|
@@ -405,18 +405,6 @@ class buildset:
|
||||
if nesting_count != 1:
|
||||
if self.installing():
|
||||
self.macros['install_mode'] = 'staging'
|
||||
#
|
||||
# Prepend staging areas, bin directory tothe
|
||||
# path. Lets the later package depend on the eailier
|
||||
# ones.
|
||||
#
|
||||
pathprepend = ['%{stagingroot}/bin'] + \
|
||||
macro_expand(self.macros, '%{_pathprepend}').split(':')
|
||||
pathprepend = [pp for pp in pathprepend if len(pp)]
|
||||
if len(pathprepend) == 1:
|
||||
self.macros['_pathprepend'] = pathprepend[0]
|
||||
else:
|
||||
self.macros['_pathprepend'] = ':'.join(pathprepend)
|
||||
|
||||
#
|
||||
# Only the outter build set can have staging to install. Get the staging
|
||||
@@ -430,6 +418,20 @@ class buildset:
|
||||
log.trace('_bset: %2d: %s: configs: %s' % (nesting_count,
|
||||
self.bset, ', '.join(configs)))
|
||||
|
||||
if nesting_count == 1 and len(configs) > 1:
|
||||
#
|
||||
# Prepend staging areas, bin directory to the
|
||||
# path. Lets the later package depend on the earlier
|
||||
# ones.
|
||||
#
|
||||
pathprepend = ['%{stagingroot}/bin'] + \
|
||||
macro_expand(self.macros, '%{_pathprepend}').split(':')
|
||||
pathprepend = [pp for pp in pathprepend if len(pp)]
|
||||
if len(pathprepend) == 1:
|
||||
self.macros['_pathprepend'] = pathprepend[0]
|
||||
else:
|
||||
self.macros['_pathprepend'] = ':'.join(pathprepend)
|
||||
|
||||
sizes_valid = False
|
||||
builds = []
|
||||
for s in range(0, len(configs)):
|
||||
@@ -519,7 +521,7 @@ class buildset:
|
||||
log.trace('_bset: %2d: %s: builds: %s' % \
|
||||
(nesting_count, self.install_mode(),
|
||||
', '.join([b.name() for b in builds])))
|
||||
if deps is None and not have_errors:
|
||||
if deps is None and not self.opts.no_install() and not have_errors:
|
||||
for b in builds:
|
||||
log.trace('_bset: : %s: %r' % (self.install_mode(),
|
||||
b.installable()))
|
||||
@@ -586,18 +588,22 @@ class buildset:
|
||||
# If builds have been staged install into the finaly prefix.
|
||||
#
|
||||
if have_staging and not self.opts.no_install() and not have_errors:
|
||||
log.trace('_bset: %2d: install staging' % (nesting_count))
|
||||
stagingroot = macro_expand(self.macros, '%{stagingroot}')
|
||||
prefix = macro_expand(self.macros, '%{_prefix}')
|
||||
self.install(self.install_mode(), self.bset, stagingroot, prefix)
|
||||
staging_size = path.get_size(stagingroot)
|
||||
if not self.opts.no_clean() or self.opts.always_clean():
|
||||
log.notice('clean staging: %s' % (self.bset))
|
||||
log.trace('removing: %s' % (stagingroot))
|
||||
if not self.opts.dry_run():
|
||||
if path.exists(stagingroot):
|
||||
path.removeall(stagingroot)
|
||||
log.notice('Staging Size: %s' % (build.humanize_number(staging_size, 'B')))
|
||||
have_stagingroot = path.exists(stagingroot)
|
||||
log.trace('_bset: %2d: install staging, present: %s' % \
|
||||
(nesting_count, have_stagingroot))
|
||||
if have_stagingroot:
|
||||
prefix = macro_expand(self.macros, '%{_prefix}')
|
||||
self.install(self.install_mode(), self.bset, stagingroot, prefix)
|
||||
staging_size = path.get_size(stagingroot)
|
||||
if not self.opts.no_clean() or self.opts.always_clean():
|
||||
log.notice('clean staging: %s' % (self.bset))
|
||||
log.trace('removing: %s' % (stagingroot))
|
||||
if not self.opts.dry_run():
|
||||
if path.exists(stagingroot):
|
||||
path.removeall(stagingroot)
|
||||
log.notice('Staging Size: %s' % \
|
||||
(build.humanize_number(staging_size, 'B')))
|
||||
except error.general as gerr:
|
||||
if not build_error:
|
||||
log.stderr(str(gerr))
|
||||
|
@@ -49,8 +49,8 @@ def add(label, args, macros, error):
|
||||
def set(label, args, macros, error):
|
||||
args = _args(args)
|
||||
if len(args) < 2:
|
||||
error('%%%s requires at least 2 arguments' % (label))
|
||||
return
|
||||
error('%%%s set requires at least 2 arguments' % (label))
|
||||
return []
|
||||
_map = '%s-%s' % (label, args[0])
|
||||
macros.create_map(_map)
|
||||
key = _make_key(label, 0)
|
||||
@@ -63,12 +63,26 @@ def set(label, args, macros, error):
|
||||
def setup(label, args, macros, error):
|
||||
args = _args(args)
|
||||
if len(args) < 2:
|
||||
error('%%%s requires at least 2 arguments: %s' % (label, ' '.join(args)))
|
||||
error('%%%s setup requires at least 2 arguments: %s' % (label, ' '.join(args)))
|
||||
ss = '%%setup %s %s' % (label, ' '.join(args))
|
||||
_map = '%s-%s' % (label, args[0])
|
||||
if 'setup' in macros.map_keys(_map):
|
||||
error('%%%s already setup source: %s' % (label, ' '.join(args)))
|
||||
return
|
||||
return []
|
||||
macros.set_write_map(_map)
|
||||
macros.define('setup', ss)
|
||||
macros.unset_write_map()
|
||||
return [ss]
|
||||
|
||||
def download(label, args, macros, error):
|
||||
args = _args(args)
|
||||
if len(args) != 1:
|
||||
error('%%%s download requires 1 argument: %s' % (label, ' '.join(args)))
|
||||
ss = '%%setup %s %s -g' % (label, ' '.join(args))
|
||||
_map = '%s-%s' % (label, args[0])
|
||||
if 'setup' in macros.map_keys(_map):
|
||||
error('%%%s already setup source: %s' % (label, ' '.join(args)))
|
||||
return []
|
||||
macros.set_write_map(_map)
|
||||
macros.define('setup', ss)
|
||||
macros.unset_write_map()
|
||||
@@ -79,15 +93,14 @@ def process(label, args, macros, error):
|
||||
error('invalid source type: %s' % (label))
|
||||
args = _args(args)
|
||||
log.trace('sources: %s' % (' '.join(args)))
|
||||
if len(args) < 3:
|
||||
error('%%%s requires at least 3 arguments: %s' % (label, ' '.join(args)))
|
||||
return
|
||||
if args[0] == 'set':
|
||||
return set(label, args[1:], macros, error)
|
||||
elif args[0] == 'add':
|
||||
return add(label, args[1:], macros, error)
|
||||
elif args[0] == 'setup':
|
||||
return setup(label, args[1:], macros, error)
|
||||
elif args[0] == 'download':
|
||||
return download(label, args[1:], macros, error)
|
||||
error('invalid %%%s command: %s' % (label, args[0]))
|
||||
|
||||
def hash(args, macros, error):
|
||||
|
Reference in New Issue
Block a user