Skip to content

Commit cfa0f06

Browse files
authored
Merge pull request #41 from yageek/features/custom_build
Add option in `RustConfig` to customize the build.
2 parents 74e5815 + cfa7351 commit cfa0f06

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ But if you only need Rust to build a particular Ruby gem, and you have no top-le
9898
RUST_SKIP_BUILD=1
9999
```
100100

101+
## Customizing build flags
102+
103+
If you want to change the cargo build command, you can set the `RUST_CARGO_BUILD_FLAGS` variable inside the `RustConfig` file.
104+
105+
```sh
106+
RUST_CARGO_BUILD_FLAGS="--release -p some_package --bin some_exe --bin some_bin_2"
107+
```
108+
109+
The default value of `RUST_CARGO_BUILD_FLAGS` is `--release`.
110+
If the variable is not set in `RustConfig`, the default value will be used to build the project.
111+
101112
## Using the edge version of the buildpack
102113

103114
The `emk/rust` buildpack from the [Heroku Registry](https://devcenter.heroku.com/articles/buildpack-registry) contains the latest stable version of the buildpack. If you'd like to use the latest buildpack code from this Github repository, you can set your buildpack to the Github URL:

bin/compile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ BUILD_PATH=""
3232
RUST_INSTALL_DIESEL=0
3333
# These flags are passed to `cargo install diesel`, e.g. '--no-default-features --features postgres'
3434
DIESEL_FLAGS=""
35+
# Default build flags to pass to `cargo build`.
36+
RUST_CARGO_BUILD_FLAGS="--release"
3537

3638
# Load our toolchain configuration, if any was specified.
3739
if [ -f "$BUILD_DIR/rust-toolchain" ]; then
@@ -135,7 +137,7 @@ if [ $RUST_SKIP_BUILD -ne 1 ]; then
135137
echo "-----> Building application using Cargo"
136138
cd "$BUILD_DIR/$BUILD_PATH"
137139
rm -rf target/
138-
cargo build --release
140+
cargo build $RUST_CARGO_BUILD_FLAGS
139141
mkdir -p target/release
140142
find "$CARGO_TARGET_DIR/release" -maxdepth 1 -type f -executable -exec cp -a -t target/release {} \;
141143
else

0 commit comments

Comments
 (0)