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

Header path handling on Windows #285

Open
michaelsbradleyjr opened this issue Dec 7, 2021 · 3 comments
Open

Header path handling on Windows #285

michaelsbradleyjr opened this issue Dec 7, 2021 · 3 comments

Comments

@michaelsbradleyjr
Copy link
Contributor

michaelsbradleyjr commented Dec 7, 2021

This issue is possibly related to #284, but it seemed to me like a distinct issue and I was still poking at the problem, so I waited to raise it.

To be more precise, I ran into this problem after I put a workaround in place for #284.

I'm using nimterop to work with a library that provides alternative header files, the choice of one or another header depending on which lib features you plan to use.

So I have this kind of thing in my wrapper:

const thelibHeaderRelPath {.strdefine.} =
  "include" / "thelib" / "some.h"

And I pass thelibHeaderRelPath as the first argument to nimterop's getHeader, along with other appropriate arguments.

On Linux and macOS, this approach works as I expected. But it does not work on Windows, where my build environment is an MSYS2 Bash shell in MSYS2's UCRT64 environment.

After poking around in nimterop, I hit on a solution that involves a change in my code instead of nimterop's:

const thelibHeaderRelPath {.strdefine.} =
  when defined(windows):
    "include\\\\thelib\\\\some.h"
  else:
    "include" / "thelib" / "some.h"

Given that it works, it's suggestive that somewhere in nimterop's getHeader macro, and/or a helper function, path handling is having an issue with the \ path separator on Windows (or maybe just Windows when the Nim compiler is invoked from MSYS2 Bash, I'm not sure).

I've tried to figure out a change/fix to the nimterop code, but have so far been unsuccessful.

@genotrance
Copy link
Collaborator

Some log output might help to figure out where this is happening. There might be a missing quoteShelll in some shell call.

@michaelsbradleyjr
Copy link
Contributor Author

michaelsbradleyjr commented Dec 7, 2021

I stuck echos all over the place, turned up verbosity, etc. I couldn't figure out where exactly it's happening. But I'm pretty confident it's happening in proc findFiles because in the case I described on Windows+MSYS2, when the relative path is "include" / "thelib" / "some.h", that proc returns an empty seq, but finds the file when the relative path is "include\\\\thelib\\\\some.h".

@genotrance
Copy link
Collaborator

Maybe print out the loaf cmd and the actual output? Might give some ideas what's being passed in for the passing and failing cases.

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