Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nrf52_src/templates/alire.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ First edit your `alire.toml` file and add the following elements:
Then edit your project file to add the following elements:
- "with" the run-time project file. With this, gprbuild will compile the run-time before your application
```ada
with "$(runtime_proj_prefix)_build.gpr";
$(project_file_withs)
```
- Specify the `Target` and `Runtime` attributes:
```ada
for Target use $(runtime_proj_prefix)_build'Target;
for Runtime ("Ada") use $(runtime_proj_prefix)_build'Runtime ("Ada");
for Target use Runtime_Build'Target;
for Runtime ("Ada") use Runtime_Build'Runtime ("Ada");
```
"""

Expand Down
25 changes: 23 additions & 2 deletions patch-runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import argparse
import pathlib
import re
import shutil
import sys
import tomllib
from typing import Dict

Expand Down Expand Up @@ -77,6 +79,25 @@ def gen_from_template(
for key, value in template_values.items():
content = content.replace(f"$({key})", value)

# Check for any unrecognised template variables
m = re.search(r"\$\([^\)]+\)", content)
if m:
print(
f"Error: unrecognised template variable '{m.group(0)}'"
f" in file {str(template_file)}",
file=sys.stderr,
)
sys.exit(1)

m = re.search(r"\$\(\w*", content)
if m:
print(
f"Error: malformed template variable '{m.group(0)}'"
f" in file {str(template_file)}",
file=sys.stderr,
)
sys.exit(1)

with open(out_file, "w", newline="\n") as f:
f.write(content)

Expand All @@ -101,10 +122,10 @@ def gen_templates_from_manifest(
src = template_info["src"]
dst = template_info["dst"]

for k,v in template_values.items():
for k, v in template_values.items():
src = src.replace(f"$({k})", v)

for k,v in template_values.items():
for k, v in template_values.items():
dst = dst.replace(f"$({k})", v)

gen_from_template(
Expand Down
Loading