Skip to content

Commit

Permalink
AdaCore#93: gprproject/__init__.py, gprproject/gprbuild.py: python bu…
Browse files Browse the repository at this point in the history
…ilder: implementation of --gpr-opts
  • Loading branch information
dsauvage committed Dec 10, 2024
1 parent e327ec6 commit a3fe15a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions gprproject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions gprproject/gprbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"],
)


Expand Down

0 comments on commit a3fe15a

Please sign in to comment.