Skip to content

Commit

Permalink
rust: add build profiles more aligned with ninja profiles
Browse files Browse the repository at this point in the history
A cargo profile is created for each of build modes: dev, debug,
sanitize, realease. The names of cargo profiles are prefixed by
"rust-" because cargo does not allow separate "dev" and "debug"
profiles.
  • Loading branch information
wmitros committed Jul 21, 2022
1 parent 5252c13 commit bc13c07
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ def configure_abseil(build_dir, mode, mode_config):
pool = console
description = TEST {mode}
rule rust_lib.{mode}
command = CARGO_HOME=build/{mode}/rust/.cargo cargo build --release --manifest-path=rust/Cargo.toml --target-dir=build/{mode}/rust
command = CARGO_HOME=build/{mode}/.cargo cargo build --manifest-path=rust/Cargo.toml --target-dir=build/{mode} --profile=rust-{mode}
description = RUST_LIB $out
''').format(mode=mode, antlr3_exec=antlr3_exec, fmt_lib=fmt_lib, test_repeat=test_repeat, test_timeout=test_timeout, **modeval))
f.write(
Expand Down Expand Up @@ -1936,7 +1936,7 @@ def configure_abseil(build_dir, mode, mode_config):
]])
objs.append('$builddir/' + mode + '/gen/utils/gz/crc_combine_table.o')
if has_rust:
objs.append('$builddir/' + mode +'/rust/release/librust_combined.a')
objs.append('$builddir/' + mode +'/rust-' + mode + '/librust_combined.a')
if binary in tests:
local_libs = '$seastar_libs_{} $libs'.format(mode)
if binary in pure_boost_tests:
Expand Down Expand Up @@ -2052,7 +2052,7 @@ def configure_abseil(build_dir, mode, mode_config):
obj = cc.replace('.cc', '.o')
f.write('build {}: cxx.{} {}\n'.format(obj, mode, cc))
f.write('build {}: cxxbridge_header\n'.format('$builddir/{}/gen/rust/cxx.hh'.format(mode)))
librust = '$builddir/{}/rust/release/librust_combined.a'.format(mode)
librust = '$builddir/{}/rust-{}/librust_combined.a'.format(mode, mode)
rustsrc = 'rust/src/lib.rs'
f.write('build {}: rust_lib.{} {} {}\n'.format(librust, mode, rustsrc, str.join(' ', rust_headers.values())))
for thrift in thrifts:
Expand Down
20 changes: 20 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ inc = { path = "inc", version = "0.1.0" }

[lib]
crate-type = ["staticlib"]

[profile.rust-dev]
opt-level = 2
inherits = "dev"
debug = false
overflow-checks = false
debug-assertions = false
strip = "symbols"

[profile.rust-debug]
inherits = "dev"
overflow-checks = false
incremental = false

[profile.rust-sanitize]
inherits = "dev"
incremental = false

[profile.rust-release]
inherits = "release"

0 comments on commit bc13c07

Please sign in to comment.