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 POSIX-style paths in #includes #168
Use POSIX-style paths in #includes #168
Conversation
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.
Thanks, @edwinbalani! It looks good but please bump the patch version number in version.py
to let our CI/CD setup release the new version automatically after merge.
Thanks - I'll do so. I think CONTRIBUTING.md could be clearer on this, since it currently only says to do this when "committing to master". In one interpretation, I'm only committing to my branch at the moment :) Do you think there are any situations where a PR shouldn't bump the version number, and are they rarer than the ones where a contributor should? If so, then perhaps the guidance could be reworded to say you normally should bump as part of your PR changes, and outline situations where it shouldn't be done. I ought to test this change informally on Windows to check that the behaviour's actually changed; should be able to do this today too. |
I don't think there is a sensible scenario where you shouldn't but we should wait for @thirtytwobits to confirm.
Speaking of which, there's #60 |
It seems the changes haven't quite done the trick. Where we used to get this:
we now get
This is in the generated header for uavcan.register.Access.1.0, using So I think there are more potential instances of |
Adding a test that ensures that there are no |
...just one bad I've since learnt more about nnvg, and changed how I invoke it. With // reg.drone.phy.acoustics.Note.0.1
#include <nunavut/support/serialization.h>
#include <uavcan/si/unit/duration/Scalar_1_0.h>
#include <uavcan/si/unit/frequency/Scalar_1_0.h>
#include <uavcan/si/unit/power/Scalar_1_0.h>
#include <stdlib.h> |
This should be straightforward, right? (Famous last words...) We probably just need to check that lines starting with '#include' don't have a |
That's one way to handle it, yes. Maybe you can narrow the scope of the test such that it only involves the IncludeGenerator itself without having to generate the whole file, but ultimately it doesn't matter much, I think. |
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.
Thanks!
I think So whenever CI on Windows happens, this should hopefully be one existing test that doesn't start failing out of the blue 😅 |
My change is blocked behind this one. @pavel-kirienko , is there more you need here? |
Sorry, I didn't realize that you were waiting for my review. |
The
__str__()
method of apathlib.Path
is platform-dependent. We were using this when generating#include
directives, but to produce host-independent C/C++ code we probably shouldn't (e.g. so that code generated on Windows can compile on a Linux system without Windows-style).The current behaviour ultimately stems from the fact that the implementation presented at
pathlib.Path
depends on the interpreter host platform. These are individually available as thePosixPath
andWindowsPath
classes.An alternative to this PR would be to use
pathlib.PosixPath
(orPurePosixPath
) around the code explicitly, rather than relying on platform-dependent behaviour. However, it would probably be a much bigger diff than this tiny change. I think keeping things as platform-nativePath
objects would be better, for instance so that the same path variable can be used to query the real filesystem without surprises.Closes #129.