uhd/host/cmake/Modules/create_newmod.yml
Martin Braun 8684d3c15a rfnoc oot: Move fpga/ subdir into rfnoc/
During redesign of the OOT module directory layout, the block YAMLs and
dts files were moved under `rfnoc/`, but the gateware was not. This
causes an inconsistency in the directory layout before and after
installation, making it hard to switch between installed and
not-installed versions of RFNoC modules.

For example, block YAMLs are in `./rfnoc/blocks/*.yml`, and gateware is
in `fpga/gain/rfnoc_block_gain/*`. After installation, block YAMLs are
in `$PREFIX/share/uhd/rfnoc/blocks/*.yml`, and gateware is in
`$PREFIX/share/uhd/rfnoc/fpga/gain/rfnoc_block_gain/*` -- note the
discrepancy.

This fixes two immediate issues:

- When building the X410 example in-tree, the DTS file was not being
  found because it used the same finding logic as the gateware source files.
- When building any image core file post-installation, none of the
  gateware could be found because it used the same logic for finding
  gateware inside the OOT, which is in a different location relative to
  the block YAMLs.

By removing the inconsistencies, both these use cases work.

A note on backward compatibility:

- Existing OOT modules already have the issue that building bitfiles
  post-install does not work, and that will continue to not work.
  However, otherwise, they will keep working as before.
- Because people may have gotten accustomed to specifying the RFNoC OOT
  module as the include directory (e.g., `rfnoc_image_builder -I
  /path/to/rfnoc-gain`), we allow for this use case, and auto-correct
  the include path in this case with some backward compatibility code.
- Building the rfnoc-gain/icores/x410_XG_200_rfnoc_image_core.yml
  example image core file now also works, even with older versions of
  rfnoc-gain.
2025-04-15 09:43:04 +02:00

110 lines
3.0 KiB
YAML

steps:
- rmtree:
dir: "${ DEST_DIR }"
- chdir:
dir: "${ SOURCE_DIR }"
- copy_dir:
src: "${ SOURCE_DIR }"
dst: "${ DEST_DIR }"
ignore_globs:
- "*.hpp"
- "apps/*.cpp"
- "build"
- "examples/*.py"
- "rfnoc/fpga/gain/ip"
- "rfnoc/fpga/gain/rfnoc_block_gain"
- "icores/*.yml"
- "lib/*.cpp"
- "gr-*"
- "rfnoc/**/*.yml"
- "rfnoc/dts"
- "xsim_proj"
- "modelsim_proj"
- chdir:
dir: "${ DEST_DIR }"
- multi_rename:
glob: "**/*gain*"
pattern: gain
repl: newmod
- comment_out:
file: apps/CMakeLists.txt
range: [7, -1]
character: "#"
- insert_after:
file: apps/CMakeLists.txt
pattern: "or-later..."
text: "\n# Edit this to add your own apps!\n"
- search_and_replace:
file: examples/CMakeLists.txt
pattern: "^ .+py$"
repl: " # Insert your example sources here if you want them to be installed"
- comment_out:
file: rfnoc/fpga/newmod/CMakeLists.txt
range: [9, 13]
- search_and_replace:
file: rfnoc/fpga/newmod/CMakeLists.txt
pattern: "add_subdirectory\\(([a-z0-9_]+)\\)"
repl: "#add_subdirectory(rfnoc_block_myblock)"
- insert_before:
file: rfnoc/fpga/newmod/CMakeLists.txt
pattern: "# IP gets"
text: "# Uncomment the following lines to add your own IP:\n"
- search_and_replace:
file: icores/CMakeLists.txt
pattern: "RFNOC_REGISTER.*$"
repl: "# Add one line for every image core here:\n#RFNOC_REGISTER_IMAGE_CORE(SRC my_image_core)"
- search_and_replace:
file: include/rfnoc/newmod/CMakeLists.txt
pattern: "gain_block_control.hpp"
repl: "#my_block_control.hpp"
- search_and_replace:
file: lib/CMakeLists.txt
pattern: "gain_block_control.cpp"
repl: "#my_block_control.cpp"
- search_and_replace:
file: python/rfnoc_newmod/__init__.py
pattern: "GainBlockControl.*$"
repl: "#MyBlockControl = lib.my_block_control"
- search_and_replace:
file: python/pyrfnoc-newmod.cpp
pattern: '#include "gain_block_control_python.hpp"\n'
repl: ""
- search_and_replace:
file: python/pyrfnoc-newmod.cpp
pattern: "export_gain_block_control\\(m\\);\n"
repl: ""
- search_and_replace:
file: README.md
pattern: ".*(?=## Directory Structure)"
repl: |
# RFNoC Out-of-Tree Module
This is a template for creating an RFNoC out-of-tree module. It is based on the
rfnoc-gain example that ships with UHD.
We recommend sticking to this directory structure and file layout.\n
count: 1
- search_and_replace:
file: rfnoc/CMakeLists.txt
pattern: "add_subdirectory\\(dts\\)"
repl: "#add_subdirectory(dts)"
- search_and_replace:
files:
- CMakeLists.txt
- apps/CMakeLists.txt
- examples/CMakeLists.txt
- python/rfnoc_newmod/__init__.py
- python/CMakeLists.txt
pattern: r"rfnoc(.)gain"
repl: r"rfnoc\1newmod"
- search_and_replace:
files:
- CMakeLists.txt
- include/rfnoc/newmod/CMakeLists.txt
- lib/CMakeLists.txt
- python/pyrfnoc-newmod.cpp
- python/setup.py.in
- README.md
pattern: "gain"
repl: "newmod"