softprops / lambda-rust

🐳 🦀 a dockerized lambda build env for rust applications
MIT License
162 stars 76 forks source link

Compile only the specified $BIN binary if it is passed #68

Closed Veetaha closed 4 years ago

Veetaha commented 4 years ago

In my case I have a huge cargo workspace, some of its crates use platform-specific build scripts and dependencies and that are (A) very long to compile and (B) are impossible to compile using raw lambci image due to the lack of some C libraries.

My solution is to pass --bin $BIN flag to cargo build to prevent it from building the entire workspace and just compile only the crate with the lambda if $BIN is not an empty string.

As my current temporary workaround for this, I use to pass both options BIN=<lambda_binary_name> CARGO_FLAGS=--bin <lambda_binary_name>, which is not horrible, but a bit inconvenient in terms of violating DRY. Anyway, I'd like to upstream the behaviour I proposed

softprops commented 4 years ago

Oh good call. In hindsight, this probably should have been implemented this way when BIN was introduced. Thanks!

Veetaha commented 4 years ago

@softprops

Hmm, that's strange, but my travis build of this PR has timed out https://travis-ci.com/github/Veetaha/lambda-rust/builds/173146646 And indeed it seems to hang when running locally, it's hard to tell what's going on....

Veetaha commented 4 years ago

I may be mistaken, but rm command in tests might be waiting for stdin (are you sure you want to remove write-protected file or something)

softprops commented 4 years ago

I'm take a closer look but I may not have time this weekend