Merge pull request #336 from learnleapfly/fix_status_list

Fix status list
This commit is contained in:
Mathieu Virbel 2019-01-13 23:27:27 +01:00 committed by GitHub
commit 0db47936f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 5 deletions

View file

@ -19,6 +19,9 @@ class LibffiRecipe(Recipe):
for arch in self.filtered_archs:
self.build(arch)
# since we don't run cache_execution, call this here for `status`
self.update_state("{}.build_all".format(self.name), True)
def prebuild_arch(self, arch):
if self.has_marker("patched"):
return

View file

@ -55,14 +55,12 @@ def cache_execution(f):
if args:
for arg in args:
key += ".{}".format(arg)
key_time = "{}.at".format(key)
if key in state and not force:
print("# (ignored) {} {}".format(f.__name__.capitalize(), self.name))
return
print("{} {}".format(f.__name__.capitalize(), self.name))
f(self, *args, **kwargs)
state[key] = True
state[key_time] = str(datetime.utcnow())
self.update_state(key, True)
return _cache_execution
@ -779,6 +777,19 @@ class Recipe(object):
self.delete_marker("building")
self.set_marker("build_done")
def update_state(self, key, value):
"""Update entry in state database
This is usually done in the @cache_execution decorator
to log an action and its time of occurrence,
but it needs to be done manually in recipes.
sets key = value, and key.at = current_datetime
"""
key_time = "{}.at".format(key)
self.ctx.state[key] = value
self.ctx.state[key_time] = str(datetime.utcnow())
@cache_execution
def build_all(self):
filtered_archs = self.filtered_archs
@ -828,6 +839,15 @@ class Recipe(object):
if hasattr(self, postbuild):
getattr(self, postbuild)()
def update_state(self, key, value):
"""Update entry in state database
Also adds the time of update
"""
key_time = "{}.at".format(key)
self.ctx.state[key] = value
self.ctx.state[key_time] = str(datetime.utcnow())
@cache_execution
def make_lipo(self, filename, library=None):
if library is None:
@ -916,11 +936,12 @@ class Recipe(object):
pass
@classmethod
def list_recipes(cls):
def list_recipes(cls, **kwargs):
skip_list = kwargs.pop("skip_list", ['__pycache__'])
recipes_dir = join(dirname(__file__), "recipes")
for name in sorted(listdir(recipes_dir)):
fn = join(recipes_dir, name)
if isdir(fn):
if isdir(fn) and name not in skip_list:
yield name
@classmethod