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 and coverage. The names of cargo profiles are
prefixed by "rust-" because cargo does not allow separate "dev"
and "debug" profiles.
  • Loading branch information
wmitros committed Aug 1, 2022
1 parent c6a6337 commit b07eb82
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 3 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,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 @@ -1942,7 +1942,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 @@ -2058,7 +2058,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)
librs_to_toml = lambda rs: rs.replace('src/lib.rs', 'Cargo.toml')
rustsrcs = [ 'rust/src/lib.rs', 'rust/Cargo.toml' ] + list(rust_headers.values()) + list(map(librs_to_toml, rust_headers.values()))
f.write('build {}: rust_lib.{} {}\n'.format(librust, mode, str.join(' ', rustsrcs)))
Expand Down
28 changes: 28 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,31 @@ inc = { path = "inc", version = "0.1.0" }

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

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

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

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

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

[profile.rust-coverage]
inherits = "dev"
opt-level = 1
overflow-checks = false
incremental = false

0 comments on commit b07eb82

Please sign in to comment.