From 8022c268bbcaedd3159941b82fb4f2e3d628f15a Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Sat, 12 Jan 2019 17:26:56 -0500 Subject: [PATCH 1/3] exclude __pycache__ from recipe dirs --- toolchain.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toolchain.py b/toolchain.py index 7b51445..03e1307 100755 --- a/toolchain.py +++ b/toolchain.py @@ -916,11 +916,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 From 545d24e010d70c25d079f45ed929159ab3791042 Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Sat, 12 Jan 2019 17:26:09 -0500 Subject: [PATCH 2/3] remove __pycache__ from the recipe list, and fix the hostlibffi recipe so it displays correctly in ./toolchain status --- recipes/hostlibffi/__init__.py | 3 +++ toolchain.py | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/recipes/hostlibffi/__init__.py b/recipes/hostlibffi/__init__.py index a9cfda8..0cad444 100644 --- a/recipes/hostlibffi/__init__.py +++ b/recipes/hostlibffi/__init__.py @@ -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 diff --git a/toolchain.py b/toolchain.py index 03e1307..0ae71bb 100755 --- a/toolchain.py +++ b/toolchain.py @@ -61,8 +61,7 @@ def cache_execution(f): 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 +778,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 +840,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: From eeb237c00abb09c8b700e7eae1fe331e1832a5e9 Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Sat, 12 Jan 2019 17:41:05 -0500 Subject: [PATCH 3/3] remove line - no longer needed --- toolchain.py | 1 - 1 file changed, 1 deletion(-) diff --git a/toolchain.py b/toolchain.py index 0ae71bb..121e20b 100755 --- a/toolchain.py +++ b/toolchain.py @@ -55,7 +55,6 @@ 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