-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Use consistent include paths when buiding in an external repository #178
Conversation
doc = "List of import `-J` flags to be passed to the `jsonnet` compiler.", | ||
doc = """List of import `-J` flags to be passed to the `jsonnet` compiler. | ||
|
||
The workspace_root, the genfiles_dir, and bin_dir are always included.""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already true. The generated documentation is not updated due to #177.
0af6a6c
to
3697af1
Compare
Right now you see that jsonnet_to_json() and jsonnet_to_json_test() implicitly call jsonnet with "-J .". This means that if these rules are used in combination with libraries that are declared in the root module, everything works as expected. But as soon as libraries are used from other modules, importing them becomes more tedious. The goal of this change is to ensure that if a Jsonnet project can be built within the root module, that module can also safely be used as a child module. We solve this by automatically adding the workspace root to the set of import paths for which one or more source files exist. Furthermore, by considering the root of every source file, we no longer need to use bin_dir and genfiles_dir. Fixes: bazel-contrib#44 Fixes: bazel-contrib#86 Fixed: bazel-contrib#139 Fixes: bazel-contrib#154 Fixes: bazel-contrib#178
Right now you see that jsonnet_to_json() and jsonnet_to_json_test() implicitly call jsonnet with "-J .". This means that if these rules are used in combination with libraries that are declared in the root module, everything works as expected. But as soon as libraries are used from other modules, importing them becomes more tedious. The goal of this change is to ensure that if a Jsonnet project can be built within the root module, that module can also safely be used as a child module. We solve this by automatically adding the workspace root to the set of import paths for which one or more source files exist. Furthermore, by considering the root of every source file, we no longer need to use bin_dir and genfiles_dir. Fixes: bazel-contrib#44 Fixes: bazel-contrib#86 Fixed: bazel-contrib#139 Fixes: bazel-contrib#154 Fixes: bazel-contrib#178
Thanks for the PR, @agotsis! I just merged a somewhat different change in #182 that should also address this issue. The reason I deviated from your change is because I think that we should simply make sure that the |
Thank you very much @EdSchouten - I have tested your changes in a large repo with complex dependencies on jsonnet and found that the issue that motivated me to open the PR has been fixed <3 |
Currently, the include paths passed to the jsonnet compiler are not all adjusted for when used in an external repository - only explicitly included imports.
This results in inconsistent include behavior when rules from rules_jsonnet are depended upon in an external repository.
Adding the workspace_root as appropriate makes this behavior consistent between builds in a local workspace and in an external one.
All existing tests pass
bazel build @examples//...
with bazel 6.4.0.