Create installation tasks directly

Task generators created from other task generators may be
skipped during partial builds. This change re-enables
install_task as a task attribute and provides a task
object with input and output nodes which can be re-used
by other tasks.
This commit is contained in:
Thomas Nagy 2016-05-06 15:51:21 +02:00
parent 5511593318
commit b1f5c0f814
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
20 changed files with 96 additions and 71 deletions

View File

@ -814,8 +814,8 @@ class BuildContext(Context.Context):
:type postpone: bool
"""
assert(dest)
tg = self(features='install_it', install_path=dest, install_source=files, **kw)
tg.dest = tg.install_path
tg = self(features='install_it', install_to=dest, install_from=files, **kw)
tg.dest = tg.install_to
tg.type = 'install_files'
# TODO if add: self.add_to_group(tsk)
if not kw.get('postpone', True):
@ -843,8 +843,8 @@ class BuildContext(Context.Context):
:type postpone: bool
"""
assert(dest)
tg = self(features='install_it', install_path=dest, install_source=srcfile, **kw)
tg.dest = tg.install_path
tg = self(features='install_it', install_to=dest, install_from=srcfile, **kw)
tg.dest = tg.install_to
tg.type = 'install_as'
# TODO if add: self.add_to_group(tsk)
if not kw.get('postpone', True):
@ -872,8 +872,8 @@ class BuildContext(Context.Context):
:type relative_trick: bool
"""
assert(dest)
tg = self(features='install_it', install_path=dest, install_source=src, **kw)
tg.dest = tg.install_path
tg = self(features='install_it', install_to=dest, install_from=src, **kw)
tg.dest = tg.install_to
tg.type = 'symlink_as'
tg.link = src
# TODO if add: self.add_to_group(tsk)
@ -884,27 +884,48 @@ class BuildContext(Context.Context):
@TaskGen.feature('install_it')
@TaskGen.before_method('process_rule', 'process_source')
def add_install_tasks(self):
# the problem is that we want to re-use
self.add_install_task(**self.__dict__)
@TaskGen.taskgen_method
def add_install_task(self, **kw):
if not self.bld.is_install:
return
if not self.install_path:
if not kw['install_to']:
return
if self.type == 'symlink_as' and Utils.is_win32:
if getattr(self, 'win32_install'):
self.type = 'install_as'
if kw['type'] == 'symlink_as' and Utils.is_win32:
if kw.get('win32_install'):
kw['type'] = 'install_as'
else:
# just exit
return
tsk = self.install_task = self.create_task('inst')
tsk.chmod = getattr(self, 'chmod', Utils.O644)
tsk.link = getattr(self, 'link', '')
tsk.relative_trick = getattr(self, 'relative_trick', False)
tsk.type = self.type
tsk.install_source = self.install_source
tsk.chmod = kw.get('chmod', Utils.O644)
tsk.link = kw.get('link', '')
tsk.relative_trick = kw.get('relative_trick', False)
tsk.type = kw['type']
tsk.install_from = kw['install_from']
tsk.init_files()
if not getattr(self, 'postpone', True):
if not kw.get('postpone', True):
tsk.run_now()
return tsk
@TaskGen.taskgen_method
def add_install_files(self, **kw):
kw['type'] = 'install_files'
return self.add_install_task(**kw)
@TaskGen.taskgen_method
def add_install_as(self, **kw):
kw['type'] = 'install_as'
return self.add_install_task(**kw)
@TaskGen.taskgen_method
def add_symlink_as(self, **kw):
kw['type'] = 'symlink_as'
return self.add_install_task(**kw)
class inst(Task.Task):
color = 'CYAN'
@ -921,7 +942,7 @@ class inst(Task.Task):
if self.type == 'symlink_as':
inputs = []
else:
inputs = self.generator.to_nodes(self.install_source)
inputs = self.generator.to_nodes(self.install_from)
if self.type == 'install_as':
assert len(inputs) == 1
self.set_inputs(inputs)
@ -956,7 +977,7 @@ class inst(Task.Task):
pass
def get_install_path(self, destdir=True):
dest = Utils.subst_vars(self.generator.install_path, self.env)
dest = Utils.subst_vars(self.generator.install_to, self.env)
if destdir and Options.options.destdir:
dest = os.path.join(Options.options.destdir, os.path.splitdrive(dest)[1].lstrip(os.sep))
return dest

View File

@ -352,7 +352,7 @@ def declare_chain(name='', rule=None, reentrant=None, color='BLUE',
cnt += 1
if install_path:
self.install_tg = self.bld.install_files(install_path, tsk.outputs)
self.install_task = self.add_install_files(install_to=install_path, install_from=tsk.outputs)
return tsk
for x in cls.ext_in:
@ -613,7 +613,8 @@ def process_rule(self):
x.parent.mkdir() # if a node was given, create the required folders
tsk.outputs.append(x)
if getattr(self, 'install_path', None):
self.install_tg = self.bld.install_files(self.install_path, tsk.outputs, chmod=getattr(self, 'chmod', Utils.O644))
self.install_task = self.add_install_files(install_to=self.install_path,
install_from=tsk.outputs, chmod=getattr(self, 'chmod', Utils.O644))
if getattr(self, 'source', None):
tsk.inputs = self.to_nodes(self.source)
@ -767,7 +768,8 @@ def add_pcfile(self, node):
bld(source='foo.pc.in', install_path='${LIBDIR}/pkgconfig/')
"""
tsk = self.create_task('subst_pc', node, node.change_ext('.pc', '.pc.in'))
self.install_tg = self.bld.install_files(getattr(self, 'install_path', '${LIBDIR}/pkgconfig/'), tsk.outputs)
self.install_task = self.add_install_files(
install_to=getattr(self, 'install_path', '${LIBDIR}/pkgconfig/'), install_from=tsk.outputs)
class subst(subst_pc):
pass
@ -843,7 +845,8 @@ def process_subst(self):
inst_to = getattr(self, 'install_path', None)
if inst_to:
self.install_tg = self.bld.install_files(inst_to, b, chmod=getattr(self, 'chmod', Utils.O644))
self.install_task = self.add_install_files(install_to=inst_to,
install_from=b, chmod=getattr(self, 'chmod', Utils.O644))
self.source = []

View File

@ -88,7 +88,7 @@ def create_task_macapp(self):
self.apptask = self.create_task('macapp', self.link_task.outputs, n1)
inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Contents/MacOS/' % name
self.bld.install_files(inst_to, n1, chmod=Utils.O755)
self.add_install_files(install_to=inst_to, install_from=n1, chmod=Utils.O755)
if getattr(self, 'mac_files', None):
# this only accepts files; they will be installed as seen from mac_files_root
@ -102,11 +102,11 @@ def create_task_macapp(self):
for node in self.to_nodes(self.mac_files):
relpath = node.path_from(mac_files_root or node.parent)
self.create_task('macapp', node, res_dir.make_node(relpath))
self.bld.install_as(os.path.join(inst_to, relpath), node)
self.add_install_as(install_to=os.path.join(inst_to, relpath), install_source=node)
if getattr(self.bld, 'is_install', None):
# disable normal binary installation
self.install_tg.posted = True
# disable regular binary installation
self.install_task.hasrun = Task.SKIP_ME
@feature('cprogram', 'cxxprogram')
@after_method('apply_link')
@ -141,7 +141,7 @@ def create_task_macplist(self):
plisttask.code = app_info
inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Contents/' % name
self.bld.install_files(inst_to, n1)
self.add_install_files(install_to=inst_to, install_from=n1)
@feature('cshlib', 'cxxshlib')
@before_method('apply_link', 'propagate_uselib_vars')

View File

@ -229,7 +229,9 @@ def apply_link(self):
inst_to = self.link_task.__class__.inst_to
if inst_to:
# install a copy of the node list we have at this moment (implib not added)
self.install_tg = self.bld.install_files(inst_to, self.link_task.outputs[:], env=self.env, chmod=self.link_task.chmod, task=self.link_task)
self.install_task = self.add_install_files(
install_to=inst_to, install_from=self.link_task.outputs[:],
chmod=self.link_task.chmod, task=self.link_task)
@taskgen_method
def use_rec(self, name, **kw):
@ -485,7 +487,8 @@ def apply_implib(self):
self.install_task.dest = '${BINDIR}'
if not self.env.IMPLIBDIR:
self.env.IMPLIBDIR = self.env.LIBDIR
self.implib_install_tg = self.bld.install_files(inst_to, implib, env=self.env, chmod=self.link_task.chmod, task=self.link_task)
self.implib_install_task = self.add_install_files(install_to=inst_to, install_from=implib,
chmod=self.link_task.chmod, task=self.link_task)
# ============ the code above must not know anything about vnum processing on unix platforms =========
@ -553,16 +556,16 @@ def apply_vnum(self):
path = self.install_task.dest
if self.env.DEST_OS == 'openbsd':
libname = self.link_task.outputs[0].name
t1 = bld.install_as('%s%s%s' % (path, os.sep, libname), node, env=self.env, chmod=self.link_task.chmod)
self.vnum_install_tg = (t1,)
t1 = self.add_install_as(install_to='%s/%s' % (path, libname), install_from=node, chmod=self.link_task.chmod)
self.vnum_install_task = (t1,)
else:
t1 = bld.install_as(path + os.sep + name3, node, env=self.env, chmod=self.link_task.chmod)
t3 = bld.symlink_as(path + os.sep + libname, name3)
t1 = self.add_install_as(install_to=path + os.sep + name3, install_from=node, chmod=self.link_task.chmod)
t3 = self.add_symlink_as(install_to=path + os.sep + libname, install_from=name3)
if name2 != name3:
t2 = bld.symlink_as(path + os.sep + name2, name3)
self.vnum_install_tg = (t1, t2, t3)
t2 = self.add_symlink_as(install_to=path + os.sep + name2, install_from=name3)
self.vnum_install_task = (t1, t2, t3)
else:
self.vnum_install_tg = (t1, t3)
self.vnum_install_task = (t1, t3)
if '-dynamiclib' in self.env['LINKFLAGS']:
# this requires after(propagate_uselib_vars)

View File

@ -55,7 +55,7 @@ def apply_cs(self):
if inst_to:
# note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically
mod = getattr(self, 'chmod', bintype=='exe' and Utils.O755 or Utils.O644)
self.install_task = self.bld.install_files(inst_to, self.cs_task.outputs[:], env=self.env, chmod=mod)
self.install_task = self.add_install_files(install_to=inst_to, install_from=self.cs_task.outputs[:], chmod=mod)
@feature('cs')
@after_method('apply_cs')

View File

@ -276,7 +276,7 @@ def process_settings(self):
enums_task.env['GLIB_MKENUMS_TARGET'] = tgt_node.abspath()
enums_tgt_node = [tgt_node]
install_files.append (tgt_node)
install_files.append(tgt_node)
options = '--comments "<!-- @comment@ -->" --fhead "<schemalist>" --vhead " <@type@ id=\\"%s.@EnumName@\\">" --vprod " <value nick=\\"@valuenick@\\" value=\\"@valuenum@\\"/>" --vtail " </@type@>" --ftail "</schemalist>" ' % (self.settings_enum_namespace)
enums_task.env['GLIB_MKENUMS_OPTIONS'] = options
@ -311,8 +311,7 @@ def process_settings(self):
raise Errors.WafError ('GSETTINGSSCHEMADIR not defined (should have been set up automatically during configure)')
if install_files:
self.bld.install_files (self.env['GSETTINGSSCHEMADIR'], install_files)
self.add_install_files(install_to=self.env['GSETTINGSSCHEMADIR'], install_from=install_files)
if not hasattr(self.bld, '_compile_schemas_registered'):
self.bld.add_post_fun(compile_schemas_callback)
self.bld._compile_schemas_registered = True
@ -365,7 +364,7 @@ def process_gresource_bundle(self):
task = self.create_task('glib_gresource_bundle', node, node.change_ext(''))
inst_to = getattr(self, 'install_path', None)
if inst_to:
self.bld.install_files(inst_to, task.outputs)
self.add_install_files(install_to=inst_to, install_from=task.outputs)
class glib_gresource_base(Task.Task):
"""

View File

@ -442,7 +442,7 @@ def apply_flags_ifort(self):
self.link_task.outputs.append(pdbnode)
if getattr(self, 'install_task', None):
self.pdb_install_task = self.bld.install_files(self.install_task.dest, pdbnode, env=self.env)
self.pdb_install_task = self.add_install_files(install_to=self.install_task.dest, install_from=pdbnode)
break

View File

@ -120,7 +120,7 @@ def apply_intltool_in_f(self):
task = self.create_task('intltool', node, node.change_ext(''))
inst = getattr(self, 'install_path', None)
if inst:
self.bld.install_files(inst, task.outputs)
self.add_install_files(install_to=inst, install_from=task.outputs)
@feature('intltool_po')
def apply_intltool_po(self):
@ -171,7 +171,8 @@ def apply_intltool_po(self):
filename = task.outputs[0].name
(langname, ext) = os.path.splitext(filename)
inst_file = inst + os.sep + langname + os.sep + 'LC_MESSAGES' + os.sep + appname + '.mo'
self.bld.install_as(inst_file, task.outputs[0], chmod=getattr(self, 'chmod', Utils.O644), env=task.env)
self.add_install_as(install_to=inst_file, install_from=task.outputs[0],
chmod=getattr(self, 'chmod', Utils.O644))
else:
Logs.pprint('RED', "Error no LINGUAS file found in po directory")

View File

@ -23,7 +23,7 @@ def add_lua(self, node):
tsk = self.create_task('luac', node, node.change_ext('.luac'))
inst_to = getattr(self, 'install_path', self.env.LUADIR and '${LUADIR}' or None)
if inst_to:
self.bld.install_files(inst_to, tsk.outputs)
self.add_install_files(install_to=inst_to, install_from=tsk.outputs)
return tsk
class luac(Task.Task):

View File

@ -982,8 +982,8 @@ def apply_flags_msvc(self):
self.link_task.outputs.append(pdbnode)
if getattr(self, 'install_task', None):
self.pdb_install_task = self.bld.install_files(self.install_task.dest, pdbnode, env=self.env)
self.pdb_install_task = self.add_install_files(
install_to=self.install_task.dest, install_from=pdbnode)
break
# split the manifest file processing from the link task, like for the rc processing

View File

@ -84,9 +84,9 @@ def process_py(self, node):
# where to install the python file
if self.install_path:
if self.install_from:
self.bld.install_files(self.install_path, [node], cwd=self.install_from, relative_trick=True)
self.add_install_files(install_to=self.install_path, install_from=node, cwd=self.install_from, relative_trick=True)
else:
self.bld.install_files(self.install_path, [node], relative_trick=True)
self.add_install_files(install_to=self.install_path, install_from=node, relative_trick=True)
lst = []
if self.env.PYC:
@ -115,7 +115,7 @@ def process_py(self, node):
tsk.pyd = pyd
if self.install_path:
self.bld.install_files(os.path.dirname(pyd), pyobj, cwd=node.parent.get_bld(), relative_trick=True)
self.add_install_files(install_to=os.path.dirname(pyd), install_from=pyobj, cwd=node.parent.get_bld(), relative_trick=True)
class pyc(Task.Task):
"""

View File

@ -186,19 +186,20 @@ def init_vala_task(self):
try:
self.install_vheader.source = headers_list
except AttributeError:
self.install_vheader = self.bld.install_files(valatask.header_path, headers_list, env=self.env)
self.install_vheader = self.add_install_files(install_to=valatask.header_path, install_from=headers_list)
vapi_list = [o for o in valatask.outputs if (o.suffix() in (".vapi", ".deps"))]
try:
self.install_vapi.source = vapi_list
except AttributeError:
self.install_vapi = self.bld.install_files(valatask.vapi_path, vapi_list, env=self.env)
self.install_vapi = self.add_install_files(install_to=valatask.vapi_path, install_from=vapi_list)
gir_list = [o for o in valatask.outputs if o.suffix() == '.gir']
try:
self.install_gir.source = gir_list
except AttributeError:
self.install_gir = self.bld.install_files(getattr(self, 'gir_path', '${DATAROOTDIR}/gir-1.0'), gir_list, env=self.env)
self.install_gir = self.add_install_files(
install_to=getattr(self, 'gir_path', '${DATAROOTDIR}/gir-1.0'), install_from=gir_list)
if hasattr(self, 'vala_resources'):
nodes = self.to_nodes(self.vala_resources)

View File

@ -104,7 +104,5 @@ def blender(self):
# Two ways to install a blender extension: as a module or just .py files
dest_dir = os.path.join(self.env.BLENDER_ADDONS_DIR, self.get_name())
Utils.check_dir(dest_dir)
self.bld.install_files(
dest_dir,
getattr(self, 'files', '.')
)
self.add_install_files(install_to=dest_dir, install_from=getattr(self, 'files', '.'))

View File

@ -445,7 +445,8 @@ def install_boost(self):
for lib in self.env.LIB_BOOST:
try:
file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
self.bld.install_files(inst_to, self.bld.root.find_node(file))
self.add_install_files(install_to=inst_to, install_from=self.bld.root.find_node(file))
except:
continue
install_boost.done = False

View File

@ -157,8 +157,8 @@ class doxygen(Task.Task):
self.outputs += nodes
if getattr(self.generator, 'install_path', None):
if not getattr(self.generator, 'doxy_tar', None):
self.generator.bld.install_files(self.generator.install_path,
self.outputs,
self.generator.add_install_files(install_to=self.generator.install_path,
install_from=self.outputs,
postpone=False,
cwd=self.output_dir,
relative_trick=True)
@ -211,7 +211,7 @@ def process_doxy(self):
else:
tsk.env['TAROPTS'] = ['cf']
if getattr(self, 'install_path', None):
self.bld.install_files(self.install_path, tsk.outputs)
self.add_install_files(install_to=self.install_path, install_from=tsk.outputs)
def configure(conf):
'''

View File

@ -35,7 +35,7 @@ def apply_fsc(self):
if inst_to:
# note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically
mod = getattr(self, 'chmod', bintype=='exe' and Utils.O755 or Utils.O644)
self.install_task = self.bld.install_files(inst_to, self.cs_task.outputs[:], env=self.env, chmod=mod)
self.install_task = self.add_install_files(install_to=inst_to, install_from=self.cs_task.outputs[:], chmod=mod)
feature('fs')(cs.use_cs)
after_method('apply_fsc')(cs.use_cs)

View File

@ -127,8 +127,8 @@ include $(GOROOT)/src/Make.pkg
install_dir = '${LIBDIR}'
#print('===> %s (%s)' % (tgt.abspath(), install_dir))
self.generator.bld.install_files(
install_dir,
tgt.abspath(),
install_to=install_dir,
install_from=tgt.abspath(),
relative_trick=False,
postpone=False,
)

View File

@ -27,9 +27,9 @@ def apply_msgfmt(self):
inst = getattr(self, 'install_path', '${KDE4_LOCALE_INSTALL_DIR}')
self.bld.install_as(
inst + os.sep + langname + os.sep + 'LC_MESSAGES' + os.sep + getattr(self, 'appname', 'set_your_appname') + '.mo',
task.outputs[0],
self.add_install_as(
inst_to = inst + os.sep + langname + os.sep + 'LC_MESSAGES' + os.sep + getattr(self, 'appname', 'set_your_appname') + '.mo',
inst_from = task.outputs[0],
chmod = getattr(self, 'chmod', Utils.O644))
class msgfmt(Task.Task):

View File

@ -43,9 +43,7 @@ def map_objcopy(self):
pass
if self.objcopy_install_path:
self.bld.install_files(self.objcopy_install_path,
task.outputs[0],
env=task.env.derive())
self.add_install_files(install_to=self.objcopy_install_path, install_from=task.outputs[0])
def configure(ctx):
ctx.find_program('objcopy', var='OBJCOPY', mandatory=True)

View File

@ -243,7 +243,7 @@ def apply_rst(self):
inst_to = getattr(self, 'install_path', None)
if inst_to:
self.install_task = self.bld.install_files(inst_to, task.outputs[:], env=self.env)
self.install_task = self.add_install_files(install_to=inst_to, install_from=task.outputs[:])
self.source = []