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

Allow overriding system root via environment #82

Merged
merged 2 commits into from
Sep 4, 2020

Conversation

danielverkamp
Copy link
Contributor

Use the PKG_CONFIG_SYSROOT_DIR (preferred) or SYSROOT (fallback)
environment variables to override the default path used to determine
whether a library is a system library or not (/usr).

This enables cross-compilation scenarios where the system root is not a
subdirectory of /usr. Specifically, when building Rust packages in the
Chomium OS SDK, each board's sysroot is located in /build/$BOARD rather
than a subdirectory of /usr. Additionally, cros_sdk only specifies
SYSROOT (PKG_CONFIG_SYSROOT_DIR is set by the pkg-config-$BOARD cross
compilation helpers, but that isn't available in pkg-config-rs).

This has only been tested on Linux, as I don't have a macOS machine
handy, but I believe the macOS path should work as before (it does not
consider the new sysroot variables).

Signed-off-by: Daniel Verkamp dverkamp@chromium.org

src/lib.rs Outdated Show resolved Hide resolved
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Including Path will fix the compiler error.
I tested that and rebasing master with a macOS machine and things look great!:

[nix-shell:~/development/rust/pkg-config-rs]$ cargo test --quiet

running 1 test
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


running 25 tests
.........................
test result: ok. 25 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


running 3 tests
test src/lib.rs -  (line 46) ... ok
test src/lib.rs -  (line 56) ... ok
test src/lib.rs -  (line 35) ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

@ghost
Copy link

ghost commented Aug 20, 2019

@danielverkamp
Copy link
Contributor Author

Your changes look good to me - thanks!

What's the next step for getting this merged? Should I update this PR with your changes or can you apply it directly somehow?

@ghost
Copy link

ghost commented Sep 5, 2019

sure thing @danielverkamp !
I don't have write access so if you could apply your changes, rebase, and push up that would be great. We ran cargo fmt on everything in #89 so that is probably the conflict.
@sdroege anything else we should be aware of?

@sdroege
Copy link
Collaborator

sdroege commented Sep 5, 2019

@sdroege anything else we should be aware of?

No that sounds correct. This is only blocked by me (or someone else) finding time to actually review this and consider all the effects this actually has.

src/lib.rs Outdated Show resolved Hide resolved
@sdroege
Copy link
Collaborator

sdroege commented Sep 4, 2020

Looks good to me apart from that. Needs to be fixed and then rebased on master so it can be merged :)

danielverkamp and others added 2 commits September 4, 2020 11:02
Use the PKG_CONFIG_SYSROOT_DIR (preferred) or SYSROOT (fallback)
environment variables to override the default path used to determine
whether a library is a system library or not (/usr).

This enables cross-compilation scenarios where the system root is not a
subdirectory of /usr. Specifically, when building Rust packages in the
Chomium OS SDK, each board's sysroot is located in /build/$BOARD rather
than a subdirectory of /usr. Additionally, cros_sdk only specifies
SYSROOT (PKG_CONFIG_SYSROOT_DIR is set by the pkg-config-$BOARD cross
compilation helpers, but that isn't available in pkg-config-rs).

This has only been tested on Linux, as I don't have a macOS machine
handy, but I believe the macOS path should work as before (it does not
consider the new sysroot variables).

Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
@sdroege sdroege merged commit 7a442be into rust-lang:master Sep 4, 2020
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.

None yet

2 participants