I was recently updating an older OpenCPI project to the current style that ocpidev
would generate, a lot of which is just moving and renaming various files.
So I wrote a script to help with the most common things I ended up doing:
https://pypi.org/project/ocpiupdate/
This will:
- Move all Worker Description XML Files (OWDs) to use the newer
<worker>-<model>.xml
naming structure. - Move all
specs/*[-_]spec.xml
files to*.comp/*-comp.xml
. - Inspect all OWD files for usage of these moved specs in the
spec
attribute and correct it appropriately.
I may add more to this over time as I need to do more updates, and I’ll comment if I do.
If you encounter any issues in using this, please ask for help.
Compatibility
I recommend Python 3.8 or newer (I wrote it for Ubuntu 20.04, and only used it on Python 3.8.10).
Usage
You can install this from PyPi:
pip install ocpiupdate
Or you can clone the repository, and build it with Hatch. This is currently left as an exercise for the reader, but I recommend using Astral’s uv
.
You call it like this:
ocpiupdate --library <library> --project <project>
--library
specifies a library to conduct the “Move” steps in. This can be specified more than once to operate over multiple libraries. The XML file / Makefile in this directory is ignored.
--project
specifies a project to conduct the “Inspect” step in. This can be specified more than once to inspect multiple projects. This means that you can select a different project than the one you did the moves in, in case you have a second project that implements components from a first project. The XML file / Makefile in this directory is ignored.
Ignore any other flags at the moment.
Yes, I probably could have made these arguments more generic and useful, but this worked for me
The script will print everything it does to the terminal, including:
- The file moves
- The directory creations
- Which files it scans to do the find and replace
- The exact string that was replaced, what it was replaced with, what line of the file it was from, and which file
Disclaimers
- This is an unofficial script. I am not a core maintainer of OpenCPI.
- This has only been run on one project.
- Save your work to your version control system before attempting to use this.
- The script has very little understanding of OpenCPI Project structure.
- It only “parses” XML in very limited circumstances.
Known Issues
If this script renames the OWD of an RCC Worker that is a proxy of a HDL Worker, this will cause an error when attempting to build on v2.4.7 or earlier.See this forum post.Current workaround for this is to manually revert the name change that the script makes to these OWDs.
Potential Roadmap of future additions
- Convert
*_protocol.xml
to*-prot.xml
. Have the script avoid the known issue documented above.