Skip to content

Commit

Permalink
include _globals in ibek support generate-links
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 8, 2023
1 parent 5743a39 commit 2e7a0a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/ibek/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
IBEK_DEFS = EPICS_ROOT / "ibek-defs"
PVI_DEFS = EPICS_ROOT / "pvi-defs"

# Paths for ibek-support
IBEK_SUPPORT = Path("ibek-support")
IBEK_GLOBALS = Path("_global")
SUPPORT_YAML_PATTERN = "*ibek.support.yaml"
PVI_YAML_PATTERN = "*pvi.device.yaml"

# UIs and templates generated at runtime
OPI_OUTPUT_PATH = EPICS_ROOT / "opi"
PVI_OUTPUT_PATH = EPICS_ROOT / "pvi"
Expand Down
12 changes: 9 additions & 3 deletions src/ibek/support_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@

from ibek.globals import (
IBEK_DEFS,
IBEK_GLOBALS,
IBEK_SUPPORT,
IOC_DBDS,
IOC_LIBS,
PVI_DEFS,
PVI_YAML_PATTERN,
RELEASE,
RUNTIME_DEBS,
SUPPORT,
SUPPORT_YAML_PATTERN,
NaturalOrderGroup,
)
from ibek.support import Support
Expand Down Expand Up @@ -254,10 +258,12 @@ def generate_links(
ibek_support: Root of ibek support to find support module directory in
"""
support_defs = (ibek_support or get_ioc_source() / "ibek-support") / support_module
support_defs = (ibek_support or get_ioc_source() / IBEK_SUPPORT) / support_module
support_globals = (ibek_support or get_ioc_source() / IBEK_SUPPORT) / IBEK_GLOBALS

symlink_files(support_defs, "*ibek.support.yaml", IBEK_DEFS)
symlink_files(support_defs, "*pvi.device.yaml", PVI_DEFS)
symlink_files(support_defs, SUPPORT_YAML_PATTERN, IBEK_DEFS)
symlink_files(support_globals, SUPPORT_YAML_PATTERN, IBEK_DEFS)
symlink_files(support_defs, PVI_YAML_PATTERN, PVI_DEFS)


@support_cli.command()
Expand Down
4 changes: 3 additions & 1 deletion src/ibek/support_cmds/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def symlink_files(source_directory: Path, file_pattern: str, target_directory: P
target_directory: Directory to create symlinks in
"""
typer.echo(f"Symlinking {file_pattern} files:")
typer.echo(
f"Symlinking {file_pattern} from {source_directory} to {target_directory}:"
)
target_directory.mkdir(parents=True, exist_ok=True)
for yaml in source_directory.glob(file_pattern):
typer.echo(f" {target_directory / yaml.name} -> {yaml}")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pytest_mock import MockerFixture

from ibek import __version__
from ibek.globals import IBEK_DEFS, PVI_DEFS
from ibek.globals import IBEK_DEFS, PVI_DEFS, PVI_YAML_PATTERN, SUPPORT_YAML_PATTERN
from ibek.ioc import clear_entity_model_ids
from ibek.support_cmds.commands import generate_links
from tests.conftest import PviDefs, run_cli
Expand Down Expand Up @@ -176,5 +176,5 @@ def test_generate_links_ibek(samples: Path, mocker: MockerFixture):

generate_links(Path("yaml"), samples)

symlink_mock.assert_any_call(samples / "yaml", "*pvi.device.yaml", PVI_DEFS)
symlink_mock.assert_any_call(samples / "yaml", "*ibek.support.yaml", IBEK_DEFS)
symlink_mock.assert_any_call(samples / "yaml", PVI_YAML_PATTERN, PVI_DEFS)
symlink_mock.assert_any_call(samples / "yaml", SUPPORT_YAML_PATTERN, IBEK_DEFS)

0 comments on commit 2e7a0a9

Please # to comment.