Improve the definition of static link tasks

This commit is contained in:
Thomas Nagy 2020-07-20 22:51:24 +02:00
parent 260f6065b9
commit b41b1741d1
1 changed files with 12 additions and 3 deletions

View File

@ -224,14 +224,24 @@ class link_task(Task.Task):
class stlink_task(link_task):
"""
Base for static link tasks, which use *ar* most of the time.
The target is always removed before being written.
"""
run_str = '${AR} ${ARFLAGS} ${AR_TGT_F}${TGT} ${AR_SRC_F}${SRC}'
run_str = [
lambda task: task.remove_before_build(),
'${AR} ${ARFLAGS} ${AR_TGT_F}${TGT} ${AR_SRC_F}${SRC}'
]
chmod = Utils.O644
"""Default installation mode for the static libraries"""
def remove_before_build(self):
"Remove the library before building it"
try:
os.remove(self.outputs[0].abspath())
except OSError:
pass
def rm_tgt(cls):
# TODO obsolete code, remove in waf 2.2
old = cls.run
def wrap(self):
try:
@ -240,7 +250,6 @@ def rm_tgt(cls):
pass
return old(self)
setattr(cls, 'run', wrap)
rm_tgt(stlink_task)
@feature('skip_stlib_link_deps')
@before_method('process_use')