mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 09:57:15 +01:00
Added global file installation pointcut
This commit is contained in:
parent
ab82dd8b8b
commit
f4185e7a26
@ -11,7 +11,23 @@ By using::
|
||||
|
||||
@TaskGen.feature('cprogram', 'cxxprogram', 'fcprogram')
|
||||
|
||||
It is possible to have all the C, C++ and Fortran programs stripped automatically
|
||||
|
||||
If stripping at installation time is preferred, use the following::
|
||||
|
||||
import shutil, os
|
||||
from waflib import Build
|
||||
from waflib.Tools import ccroot
|
||||
def copy_fun(self, src, tgt, **kw):
|
||||
shutil.copy2(src, tgt)
|
||||
os.chmod(tgt, kw.get('chmod', Utils.O644))
|
||||
try:
|
||||
tsk = kw['tsk']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if isinstance(tsk.task, ccroot.link_task):
|
||||
self.cmd_and_log('strip %s' % tgt)
|
||||
Build.InstallContext.copy_fun = copy_fun
|
||||
"""
|
||||
|
||||
def configure(conf):
|
||||
|
@ -877,14 +877,14 @@ class inst(Task.Task):
|
||||
destfile = os.path.join(destpath, y.path_from(self.path))
|
||||
else:
|
||||
destfile = os.path.join(destpath, y.name)
|
||||
self.generator.bld.do_install(y.abspath(), destfile, self.chmod)
|
||||
self.generator.bld.do_install(y.abspath(), destfile, chmod=self.chmod, tsk=self)
|
||||
|
||||
def exec_install_as(self):
|
||||
"""
|
||||
Predefined method for installing one file with a given name
|
||||
"""
|
||||
destfile = self.get_install_path()
|
||||
self.generator.bld.do_install(self.inputs[0].abspath(), destfile, self.chmod)
|
||||
self.generator.bld.do_install(self.inputs[0].abspath(), destfile, chmod=self.chmod, tsk=self)
|
||||
|
||||
def exec_symlink_as(self):
|
||||
"""
|
||||
@ -894,7 +894,7 @@ class inst(Task.Task):
|
||||
src = self.link
|
||||
if self.relative_trick:
|
||||
src = os.path.relpath(src, os.path.dirname(destfile))
|
||||
self.generator.bld.do_link(src, destfile)
|
||||
self.generator.bld.do_link(src, destfile, tsk=self)
|
||||
|
||||
class InstallContext(BuildContext):
|
||||
'''installs the targets on the system'''
|
||||
@ -907,7 +907,13 @@ class InstallContext(BuildContext):
|
||||
self.uninstall = []
|
||||
self.is_install = INSTALL
|
||||
|
||||
def do_install(self, src, tgt, chmod=Utils.O644):
|
||||
def copy_fun(self, src, tgt, **kw):
|
||||
# override this if you want to strip executables
|
||||
# kw['tsk'].source is the task that created the files in the build
|
||||
shutil.copy2(src, tgt)
|
||||
os.chmod(tgt, kw.get('chmod', Utils.O644))
|
||||
|
||||
def do_install(self, src, tgt, **kw):
|
||||
"""
|
||||
Copy a file from src to tgt with given file permissions. The actual copy is not performed
|
||||
if the source and target file have the same size and the same timestamps. When the copy occurs,
|
||||
@ -952,8 +958,7 @@ class InstallContext(BuildContext):
|
||||
pass
|
||||
|
||||
try:
|
||||
shutil.copy2(src, tgt)
|
||||
os.chmod(tgt, chmod)
|
||||
self.copy_fun(src, tgt, **kw)
|
||||
except IOError:
|
||||
try:
|
||||
os.stat(src)
|
||||
@ -961,7 +966,7 @@ class InstallContext(BuildContext):
|
||||
Logs.error('File %r does not exist' % src)
|
||||
raise Errors.WafError('Could not install the file %r' % tgt)
|
||||
|
||||
def do_link(self, src, tgt):
|
||||
def do_link(self, src, tgt, **kw):
|
||||
"""
|
||||
Create a symlink from tgt to src.
|
||||
|
||||
@ -1004,7 +1009,7 @@ class InstallContext(BuildContext):
|
||||
raise self.WafError('cannot post the task %r' % tsk)
|
||||
tsk.run()
|
||||
|
||||
def install_files(self, dest, files, env=None, chmod=Utils.O644, relative_trick=False, cwd=None, add=True, postpone=True):
|
||||
def install_files(self, dest, files, env=None, chmod=Utils.O644, relative_trick=False, cwd=None, add=True, postpone=True, task=None):
|
||||
"""
|
||||
Create a task to install files on the system::
|
||||
|
||||
@ -1030,6 +1035,7 @@ class InstallContext(BuildContext):
|
||||
tsk.bld = self
|
||||
tsk.path = cwd or self.path
|
||||
tsk.chmod = chmod
|
||||
tsk.task = task
|
||||
if isinstance(files, waflib.Node.Node):
|
||||
tsk.source = [files]
|
||||
else:
|
||||
@ -1041,7 +1047,7 @@ class InstallContext(BuildContext):
|
||||
self.run_task_now(tsk, postpone)
|
||||
return tsk
|
||||
|
||||
def install_as(self, dest, srcfile, env=None, chmod=Utils.O644, cwd=None, add=True, postpone=True):
|
||||
def install_as(self, dest, srcfile, env=None, chmod=Utils.O644, cwd=None, add=True, postpone=True, task=None):
|
||||
"""
|
||||
Create a task to install a file on the system with a different name::
|
||||
|
||||
@ -1066,13 +1072,14 @@ class InstallContext(BuildContext):
|
||||
tsk.path = cwd or self.path
|
||||
tsk.chmod = chmod
|
||||
tsk.source = [srcfile]
|
||||
tsk.task = task
|
||||
tsk.dest = dest
|
||||
tsk.exec_task = tsk.exec_install_as
|
||||
if add: self.add_to_group(tsk)
|
||||
self.run_task_now(tsk, postpone)
|
||||
return tsk
|
||||
|
||||
def symlink_as(self, dest, src, env=None, cwd=None, add=True, postpone=True, relative_trick=False):
|
||||
def symlink_as(self, dest, src, env=None, cwd=None, add=True, postpone=True, relative_trick=False, task=None):
|
||||
"""
|
||||
Create a task to install a symlink::
|
||||
|
||||
@ -1102,6 +1109,7 @@ class InstallContext(BuildContext):
|
||||
tsk.dest = dest
|
||||
tsk.path = cwd or self.path
|
||||
tsk.source = []
|
||||
tsk.task = task
|
||||
tsk.link = src
|
||||
tsk.relative_trick = relative_trick
|
||||
tsk.exec_task = tsk.exec_symlink_as
|
||||
@ -1125,7 +1133,7 @@ class UninstallContext(InstallContext):
|
||||
except OSError:
|
||||
break
|
||||
|
||||
def do_install(self, src, tgt, chmod=Utils.O644):
|
||||
def do_install(self, src, tgt, **kw):
|
||||
"""See :py:meth:`waflib.Build.InstallContext.do_install`"""
|
||||
if not self.progress_bar:
|
||||
Logs.info('- remove %s' % tgt)
|
||||
|
@ -213,7 +213,7 @@ 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_task = self.bld.install_files(inst_to, self.link_task.outputs[:], env=self.env, chmod=self.link_task.chmod)
|
||||
self.install_task = self.bld.install_files(inst_to, self.link_task.outputs[:], env=self.env, chmod=self.link_task.chmod, task=self.link_task)
|
||||
|
||||
@taskgen_method
|
||||
def use_rec(self, name, **kw):
|
||||
|
Loading…
Reference in New Issue
Block a user