Skip to content

Replace GNU Make Codegen with Python - #2241

Open
ni-jfitzger wants to merge 22 commits into
ni:masterfrom
ni-jfitzger:replace-gnu-make-with-python
Open

ni-jfitzger wants to merge 22 commits into
ni:masterfrom
ni-jfitzger:replace-gnu-make-with-python

Conversation

@ni-jfitzger

@ni-jfitzger ni-jfitzger commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator
  • This contribution adheres to CONTRIBUTING.md.
  • [ ] I've updated CHANGELOG.md if applicable.
  • I've added tests applicable for this pull request

What does this Pull Request accomplish?

The GNU Make code used for code generation was a barrier to entry for anyone not familar with GNU Make and, frankly, even for those who are familiar with it. Some of the code was very difficult to read. Variables and recipes were also scattered across the repo, making it more difficult to read.

This PR replaces those files and some of their Python code with a consolidated build/codegen.py, which implements the codegen, clean and installers steps.

It also eliminates our reliance on WSL for Windows development.

Performance: This seems to be faster than the old codegen, though how much faster may vary depending on your machine and your environment. Why is it faster? Because we don't launch Python every time we need to render a template. We use the active Python process, instead.
Additionally, eliminating WSL makes it even faster, still. I can run codegen in less than 20 seconds, if the env already exists.

List issues fixed by this Pull Request below, if any.

What testing has been done?

Ran tox -e clean, tox -e codegen, tox -e installers, tox -e codegen -- -driver nidmm. No difference seen in the generated files.

Ran newly generated unit tests. These don't cover all of codegen.py, but it's more than we had for the MAKEFILE code. Our primary method of catching issues remains ensure_codegen_up_to_date.py, diffs and code review of PRs.

@codecov-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.67078% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.90%. Comparing base (89108d2) to head (79f685f).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
build/codegen.py 58.99% 98 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2241      +/-   ##
==========================================
- Coverage   88.12%   87.90%   -0.22%     
==========================================
  Files          88       89       +1     
  Lines       22830    23106     +276     
==========================================
+ Hits        20118    20312     +194     
- Misses       2712     2794      +82     
Flag Coverage Δ
codegenunittests 82.60% <59.67%> (-2.18%) ⬇️
nidcpowersystemtests 94.40% <ø> (+0.04%) ⬆️
nidcpowerunittests 89.53% <ø> (ø)
nidigitalsystemtests 92.04% <ø> (ø)
nidigitalunittests 68.43% <ø> (ø)
nidmmsystemtests 92.33% <ø> (ø)
nifakeunittests 86.14% <ø> (+0.05%) ⬆️
nifgensystemtests 94.34% <ø> (ø)
nimodinstsystemtests 73.85% <ø> (ø)
nimodinstunittests 94.20% <ø> (ø)
nirfsasystemtests 82.71% <ø> (ø)
nirfsaunittests 63.37% <ø> (ø)
nirfsgsystemtests 81.22% <ø> (ø)
niscopesystemtests 89.99% <ø> (ø)
niscopeunittests 43.20% <ø> (ø)
nisesystemtests 91.50% <ø> (ø)
niswitchsystemtests 81.66% <ø> (ø)
nitclksystemtests 94.87% <ø> (ø)
nitclkunittests 98.26% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ni-jfitzger

Copy link
Copy Markdown
Collaborator Author

Something seems off about the reported code coverage for build/helper.

@ni-jfitzger

Copy link
Copy Markdown
Collaborator Author

Something seems off about the reported code coverage for build/helper.

Apparently --source is supposed to be a comma-separated list. You can't pass it twice in the same command.

@marcoskirsch

Copy link
Copy Markdown
Member

Using GitHub Copilot

This is (or should be) irrelevant.

@marcoskirsch

Copy link
Copy Markdown
Member

Included but unrleated: I've capped the pytest version used for system tests, because the latest release breaks our testing.

Please ensure there is an open issue for this.

@ni-jfitzger

Copy link
Copy Markdown
Collaborator Author

Included but unrleated: I've capped the pytest version used for system tests, because the latest release breaks our testing.

Please ensure there is an open issue for this.

Yes, I created one last week and we fixed and closed it.

Comment thread CONTRIBUTING.md Resolved
Comment thread CONTRIBUTING.md Resolved
Comment thread CONTRIBUTING.md Resolved
Comment thread build/codegen.py Resolved
Comment thread build/codegen.py Resolved
Comment thread build/codegen.py Outdated


@dataclass(frozen=True)
class Driver:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's consistently call these things driver API or driver bindings
Please check the repo to see which one we use more, including the main README.md.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use a mix of "driver APIs" and "Python bindings", but most frequently refer to "Python bindings" in the README, CONTRIBUTING doc and CHANGELOG.

@ni-jfitzger ni-jfitzger Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm updating the class name to PythonBindingConfig and updating most of the variables, constants and comments in this module to no longer say "driver".

Unchanged:

  • I didn't rename the mako templates that use driver in the name.
  • I didn't change the --driver command line argument (so far).

Comment thread build/codegen.py Resolved
Comment thread build/codegen.py Resolved
Comment thread build/codegen.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eliminate need for WSL Replace GNU Make Code with Python

3 participants