rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.79k stars 434 forks source link

Add ability to have include_directories before CFLAGS #1020

Open WesleyRosenblum opened 4 months ago

WesleyRosenblum commented 4 months ago

Currently , the contents of any CFLAGS or CXXFLAGS environment variables are added to the build cmd prior to include_directories that had been added using fn include:

https://github.com/rust-lang/cc-rs/blob/be62f4a9027a30ccbfffa494ce8ee3487de8cb9b/src/lib.rs#L1766-L1770

This can result in conflicts if the specified includes need to come prior to the CFLAGS includes.

We've worked around this by manually prepending includes to CFLAGS (see https://github.com/aws/s2n-tls/pull/4338), but it would be preferable for this to be configurable in cc.

Thanks!

NobodyXu commented 4 months ago

That's definitely doable.

I would accept any PR for this.