From f6b3c185b937ac61a3be4d80fc8e69ed2bef8918 Mon Sep 17 00:00:00 2001 From: Ahmad Nawab Date: Mon, 4 Nov 2024 14:08:24 +0100 Subject: [PATCH] FileWrite: rename builddir to output_dir --- loki/batch/scheduler.py | 6 +++--- loki/batch/tests/test_transformation.py | 6 +++--- loki/transformations/build_system/file_write.py | 5 +++-- scripts/loki_transform.py | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/loki/batch/scheduler.py b/loki/batch/scheduler.py index 973731cf4..a6d3fef98 100644 --- a/loki/batch/scheduler.py +++ b/loki/batch/scheduler.py @@ -120,7 +120,7 @@ class Scheduler: By default a full parse is executed, use this flag to suppress. frontend : :any:`Frontend`, optional Frontend to use for full parse of source files (default :any:`FP`). - builddir : str or path + output_dir : str or path Directory for the output to be written to """ @@ -129,7 +129,7 @@ class Scheduler: def __init__(self, paths, config=None, seed_routines=None, preprocess=False, includes=None, defines=None, definitions=None, xmods=None, - omni_includes=None, full_parse=True, frontend=FP, builddir=None): + omni_includes=None, full_parse=True, frontend=FP, output_dir=None): # Derive config from file or dict if isinstance(config, SchedulerConfig): self.config = config @@ -156,7 +156,7 @@ def __init__(self, paths, config=None, seed_routines=None, preprocess=False, 'xmods': xmods, 'omni_includes': omni_includes, 'frontend': frontend, - 'builddir': builddir + 'output_dir': output_dir } # Internal data structures to store the callgraph diff --git a/loki/batch/tests/test_transformation.py b/loki/batch/tests/test_transformation.py index c397b5da0..c41f1b843 100644 --- a/loki/batch/tests/test_transformation.py +++ b/loki/batch/tests/test_transformation.py @@ -420,7 +420,7 @@ def test_transformation_file_write(tmp_path): ricks_path = tmp_path/'rick.loki.F90' if ricks_path.exists(): ricks_path.unlink() - FileWriteTransformation().apply(source=source, item=item, build_args={'builddir': tmp_path}) + FileWriteTransformation().apply(source=source, item=item, build_args={'output_dir': tmp_path}) assert ricks_path.exists() ricks_path.unlink() @@ -429,7 +429,7 @@ def test_transformation_file_write(tmp_path): if ricks_path.exists(): ricks_path.unlink() FileWriteTransformation(mode='roll', suffix='.java').apply(source=source, item=item, - build_args={'builddir': tmp_path}) + build_args={'output_dir': tmp_path}) assert ricks_path.exists() ricks_path.unlink() @@ -437,7 +437,7 @@ def test_transformation_file_write(tmp_path): ricks_path = tmp_path/'rick.loki.F90' if ricks_path.exists(): ricks_path.unlink() - FileWriteTransformation().apply(source=source, items=(item,), build_args={'builddir': tmp_path}) + FileWriteTransformation().apply(source=source, items=(item,), build_args={'output_dir': tmp_path}) assert ricks_path.exists() ricks_path.unlink() diff --git a/loki/transformations/build_system/file_write.py b/loki/transformations/build_system/file_write.py index a97c65747..506e172d9 100644 --- a/loki/transformations/build_system/file_write.py +++ b/loki/transformations/build_system/file_write.py @@ -69,6 +69,7 @@ def transform_file(self, sourcefile, **kwargs): path = Path(item.path) suffix = self.suffix if self.suffix else path.suffix sourcepath = Path(item.path).with_suffix(f'.{self.mode}{suffix}') - if (builddir := kwargs.get('build_args', {}).get('builddir', None)) is not None: - sourcepath = Path(builddir)/sourcepath.name + build_args = kwargs.get('build_args', {}) + if build_args and (output_dir := build_args.get('output_dir', None)) is not None: + sourcepath = Path(output_dir)/sourcepath.name sourcefile.write(path=sourcepath, cuf=self.cuf) diff --git a/scripts/loki_transform.py b/scripts/loki_transform.py index d728a8e7d..f39005bc2 100644 --- a/scripts/loki_transform.py +++ b/scripts/loki_transform.py @@ -169,7 +169,7 @@ def convert( paths = [Path(p).resolve() for p in as_tuple(source)] paths += [Path(h).resolve().parent for h in as_tuple(header)] scheduler = Scheduler( - paths=paths, config=config, frontend=frontend, definitions=definitions, builddir=build, **build_args + paths=paths, config=config, frontend=frontend, definitions=definitions, output_dir=build, **build_args ) # If requested, apply a custom pipeline from the scheduler config