From a3fe15a97296762eefbc14c2e0e4e248151209fa Mon Sep 17 00:00:00 2001 From: David SAUVAGE - AdaLabs Ltd Date: Tue, 10 Dec 2024 23:35:57 +0400 Subject: [PATCH] #93: gprproject/__init__.py, gprproject/gprbuild.py: python builder: implementation of --gpr-opts --- gprproject/__init__.py | 1 + gprproject/gprbuild.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/gprproject/__init__.py b/gprproject/__init__.py index d46a144a..6e2f32eb 100644 --- a/gprproject/__init__.py +++ b/gprproject/__init__.py @@ -162,6 +162,7 @@ def build(self, args): prefix=args.prefix, gpr_paths=args.add_gpr_path, add_prefix_to_gpr_paths=args.prefix is not None, + gpr_opts=args.gpr_opts, ) self.adjust_config(gpr, args) diff --git a/gprproject/gprbuild.py b/gprproject/gprbuild.py index cea729b7..c8b6f4c5 100644 --- a/gprproject/gprbuild.py +++ b/gprproject/gprbuild.py @@ -59,6 +59,7 @@ def __init__( prefix: str | None = None, gpr_paths: list[str] | None = None, add_prefix_to_gpr_paths: bool = False, + gpr_opts: list[str] | None = None, ) -> None: """Instantiate gpr tools instance. @@ -70,6 +71,7 @@ def __init__( :param jobs: level of parallelism for gpr tools that support it :param gnatcov: if True add gnatcov instrumentation :param symcc: if True add symcc instrumentation + :param gpr_opts: arguments passed to gprbuild """ project_full_path = os.path.abspath(project_file) self.project_file = os.path.basename(project_full_path) @@ -83,6 +85,11 @@ def __init__( else: self.variables = {} + if gpr_opts: + self.gpr_opts = gpr_opts + else: + self.gpr_opts = None + # Compute the canonical target self.original_target = target @@ -194,6 +201,10 @@ def run(self, args: list[str], **kwargs) -> int: for key, value in self.variables.items(): cmd.append(f"-X{key}={value}") + if self.gpr_opts is not None: + for option in self.gpr_opts: + cmd.append(option) + if cmd_name == "gprinstall": if self.integrated: final_prefix = os.path.join(self.prefix, self.target) @@ -277,6 +288,7 @@ def save(self): "symcc": self.symcc, "prefix": self.prefix, "gpr_paths": self.gpr_paths, + "gpr_opts": self.gpr_opts, } with open(json_file, "w") as fd: json.dump(data, fd, indent=2) @@ -305,6 +317,7 @@ def load(cls, project_file: str, object_dir: str | None = None) -> GPRTool: symcc=data["symcc"], prefix=data["prefix"], gpr_paths=data["gpr_paths"], + gpr_opts=data["gpr_opts"], )