Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implicit dependencies for python scripts used by rules in ninja build snippet templates #336

Open
KeenanRileyFaulkner opened this issue Nov 7, 2023 · 6 comments

Comments

@KeenanRileyFaulkner
Copy link
Contributor

KeenanRileyFaulkner commented Nov 7, 2023

If a ninja build snippet will cause a python script to be invoked (for example, one in ninja_utils or anything in third_party), the script file path should be an implicit dependency of the rule as seen here.

To do so, review the ninja rule templates found in the ninja_tools subdirectory. For any rules that invoke Python, make sure that all associated ninja build template files have implicit dependencies declared, as in the above link.

@KeenanRileyFaulkner KeenanRileyFaulkner changed the title Add implicit dependencies for python snippets used by rules in ninja build snippet templates Add implicit dependencies for python scripts used by rules in ninja build snippet templates Nov 16, 2023
@jgoeders
Copy link
Member

@KeenanRileyFaulkner When should a python be script be placed as a dependency in the ninja rule versus being added by add_ninja_deps? Should it be in both places? Or just one of them?

@KeenanRileyFaulkner
Copy link
Contributor Author

The ninja deps have to do with rebuilding the build.ninja file when they change. The implicit dependencies will cause other snippets to be rerun. So if a Python script should cause the build file to be recreated (which I think is almost always true), it should be included in the add ninja deps method. But I also think that a Python script should almost always be an implicit dependency of the build snippet that calls it so that the snippet reruns if it changes.

@jgoeders
Copy link
Member

... cause the build file to be recreated (which I think is almost always true)...but I also think that a Python script should almost always be an implicit dependency of the build snippet that calls it so that the snippet reruns if it changes.

Does recreating the build file invalidate all output products and cause everything to be re-run? (in which case the latter wouldn't be required)

@KeenanRileyFaulkner
Copy link
Contributor Author

No, it doesn't invalidate outputs unless the build snippet that created the output has dependencies that change. This gets checked when the build file is redone and executed. If none of the dependencies for rules other than the configure rule change, there is still no work to do.

@KeenanRileyFaulkner
Copy link
Contributor Author

KeenanRileyFaulkner commented Nov 26, 2023

Part of the reason we need that is so that not everything needs to be rebuilt just because the build file changes. For example, the phys netlist tool already has its Python script as an implicit dependency for that build snippet and added as a "ninja dep". That means that if it is changed, the build file will be recreated and the phys netlist will be regenerated but the synthesis and implementation outputs will still be valid since those files didn't change.

@jgoeders
Copy link
Member

So it sounds like in almost all cases you would want the python files listed in both places.

In that case, perhaps we should standardize on a process for this to remove some code duplication, perhaps having a standard variable name in the mustache file where add_ninja_deps are placed.

@KeenanRileyFaulkner KeenanRileyFaulkner self-assigned this Dec 8, 2023
@KeenanRileyFaulkner KeenanRileyFaulkner removed their assignment Dec 19, 2023
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

No branches or pull requests

2 participants