From e2e1696b7e4bdc9874895ea9f8de741af7bda816 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sun, 29 Jan 2023 19:18:19 -0800 Subject: [PATCH] [zstd] Move zstd.module to external/ It felt clunky to have zstd.module in src/libraries/zstd by itself, and doesn't make much sense in src/libraries as it's an external library anyway. Now the ./configure script will pick up .module files in the top-level external directory as well. --- configure | 49 +++++++++++--------- {src/libraries/zstd => external}/zstd.module | 4 +- 2 files changed, 28 insertions(+), 25 deletions(-) rename {src/libraries/zstd => external}/zstd.module (94%) diff --git a/configure b/configure index b1af219..a428a6c 100755 --- a/configure +++ b/configure @@ -1,7 +1,8 @@ #!/usr/bin/env python3 def generate(output, config, manifest): - from os import makedirs, walk + from os import makedirs + from glob import iglob from pathlib import Path from bonnibel.module import Module from bonnibel.project import Project @@ -10,33 +11,35 @@ def generate(output, config, manifest): project = Project(root) output = root / output - sources = root / "src" manifest = root / manifest + sources = [ + str(root / "src/**/*.module"), + str(root / "external/*.module"), + ] + modules = {} - for base, dirs, files in walk(sources): - path = Path(base) - for f in files: - if f.endswith(".module"): - fullpath = path / f - - def module_init(name, **kwargs): - if not "root" in kwargs: - kwargs["root"] = path - m = Module(name, fullpath, **kwargs) - modules[m.name] = m - return m + for source in sources: + for modfile in iglob(source, recursive=True): + path = Path(modfile).parent - glo = { - "module": module_init, - "source_root": root, - "built_root": output, - "module_root": path, - } - code = compile(open(fullpath, 'r').read(), fullpath, "exec") + def module_init(name, **kwargs): + if not "root" in kwargs: + kwargs["root"] = path + m = Module(name, modfile, **kwargs) + modules[m.name] = m + return m - loc = {} - exec(code, glo, loc) + glo = { + "module": module_init, + "source_root": root, + "build_root": output, + "module_root": path, + } + code = compile(open(modfile, 'r').read(), modfile, "exec") + + loc = {} + exec(code, glo, loc) Module.update(modules) diff --git a/src/libraries/zstd/zstd.module b/external/zstd.module similarity index 94% rename from src/libraries/zstd/zstd.module rename to external/zstd.module index f87afa2..27b9fe8 100644 --- a/src/libraries/zstd/zstd.module +++ b/external/zstd.module @@ -3,7 +3,7 @@ zstd = module("zstd", root = "${source_root}/external/zstd", kind = "lib", - deps = [ "libc" ], + deps = [ ], output = "libzstd.a", sources = [ "decompress/zstd_decompress.c", @@ -26,7 +26,7 @@ zstd = module("zstd", ]) zstd.variables['ccflags'] = [ - "${ccflags}", + "${ccflags}", "-DXXH_NAMESPACE=ZSTD_", "-DDEBUGLEVEL=0", "-DZSTD_DISABLE_ASM",