Skip to content

Commit df7bee9

Browse files
authored
Merge pull request #4361 from anoma/mergify/bp/maint-libs-0.47/pr-4355
move version detection build script from apps_lib into apps (backport #4355)
2 parents 5c21614 + c374ccd commit df7bee9

File tree

13 files changed

+82
-59
lines changed

13 files changed

+82
-59
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apps/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ winapi.workspace = true
7979
[dev-dependencies]
8080

8181
[build-dependencies]
82+
cargo_metadata.workspace = true
8283
git2.workspace = true

crates/apps_lib/build.rs renamed to crates/apps/build.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
use std::env;
12
use std::fs::File;
23
use std::io::Write;
34
use std::path::PathBuf;
4-
use std::{env, str};
55

66
use cargo_metadata::MetadataCommand;
77
use git2::{DescribeFormatOptions, DescribeOptions, Repository};
88

9-
/// Path to the .proto source files, relative to `apps_lib` directory
10-
const PROTO_SRC: &str = "./proto";
11-
129
fn main() {
1310
// Discover the repository version, if it exists
1411
println!("cargo:rerun-if-changed=../../.git");
@@ -50,7 +47,7 @@ fn main() {
5047
"--locked".to_string(),
5148
"--offline".to_string(),
5249
])
53-
.manifest_path("../apps/Cargo.toml")
50+
.manifest_path("./Cargo.toml")
5451
.exec()
5552
.ok()
5653
.and_then(|metadata| {
@@ -72,7 +69,4 @@ fn main() {
7269
.expect("cannot write version");
7370
}
7471
};
75-
76-
// Tell Cargo that if the given file changes, to rerun this build script.
77-
println!("cargo:rerun-if-changed={}", PROTO_SRC);
7872
}

crates/apps/src/bin/namada-client/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn main() -> Result<()> {
1515
// run the CLI
1616
CliApi::handle_client_command::<HttpClient, _>(
1717
None,
18-
cli::namada_client_cli()?,
18+
cli::namada_client_cli(namada_apps::namada_version())?,
1919
CliIo,
2020
)
2121
.await

crates/apps/src/bin/namada-node/cli.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use namada_apps_lib::time::{DateTimeUtc, Utc};
1111
use namada_node as node;
1212

1313
pub fn main() -> Result<()> {
14-
let cmd = cli::namada_node_cli()?;
14+
let cmd = cli::namada_node_cli(namada_apps::namada_version())?;
1515
match cmd {
1616
cli::NamadaNode::Ledger(cmd, ctx) => match cmd {
1717
cmds::Ledger::Run(cmds::LedgerRun(args)) => {
@@ -28,15 +28,25 @@ pub fn main() -> Result<()> {
2828
);
2929
ScheduledMigration::from_path(p, hash, height).unwrap()
3030
});
31-
node::run(chain_ctx.config, wasm_dir, scheduled_migration);
31+
node::run(
32+
chain_ctx.config,
33+
wasm_dir,
34+
scheduled_migration,
35+
namada_apps::namada_version(),
36+
);
3237
}
3338
cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => {
3439
let mut chain_ctx = ctx.take_chain_or_exit();
3540
let wasm_dir = chain_ctx.wasm_dir();
3641
sleep_until(args.time);
3742
chain_ctx.config.ledger.shell.action_at_height =
3843
Some(args.action_at_height);
39-
node::run(chain_ctx.config, wasm_dir, None);
44+
node::run(
45+
chain_ctx.config,
46+
wasm_dir,
47+
None,
48+
namada_apps::namada_version(),
49+
);
4050
}
4151
cmds::Ledger::Reset(_) => {
4252
let chain_ctx = ctx.take_chain_or_exit();

crates/apps/src/bin/namada-relayer/_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async fn main() -> Result<()> {
1212
// init logging
1313
logging::init_from_env_or(LevelFilter::INFO)?;
1414

15-
let cmd = cli::namada_relayer_cli()?;
15+
let cmd = cli::namada_relayer_cli(namada_apps::namada_version())?;
1616
// run the CLI
1717
CliApi::handle_relayer_command::<HttpClient>(None, cmd, CliIo).await
1818
}

crates/apps/src/bin/namada-wallet/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use namada_apps_lib::cli::api::{CliApi, CliIo};
55
#[tokio::main]
66
pub async fn main() -> Result<()> {
77
color_eyre::install()?;
8-
let (cmd, ctx) = cli::namada_wallet_cli()?;
8+
let (cmd, ctx) = cli::namada_wallet_cli(namada_apps::namada_version())?;
99
// run the CLI
1010
CliApi::handle_wallet_command(cmd, ctx, &CliIo).await
1111
}

crates/apps/src/bin/namada/cli.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use eyre::Result;
1212
use namada_apps_lib::cli;
1313

1414
pub fn main() -> Result<()> {
15-
let (cmd, raw_sub_cmd) = cli::namada_cli();
15+
let (cmd, raw_sub_cmd) = cli::namada_cli(namada_apps::namada_version());
1616
handle_command(cmd, raw_sub_cmd)
1717
}
1818

@@ -69,12 +69,13 @@ fn handle_command(cmd: cli::cmds::Namada, raw_sub_cmd: String) -> Result<()> {
6969
use clap_complete::{generate, shells};
7070
use clap_complete_nushell::Nushell;
7171

72+
let version = namada_apps::namada_version();
7273
for (mut app, name) in [
73-
(cli::namada_app(), "namada"),
74-
(cli::namada_node_app(), "namadan"),
75-
(cli::namada_client_app(), "namadac"),
76-
(cli::namada_wallet_app(), "namadaw"),
77-
(cli::namada_relayer_app(), "namadar"),
74+
(cli::namada_app(version), "namada"),
75+
(cli::namada_node_app(version), "namadan"),
76+
(cli::namada_client_app(version), "namadac"),
77+
(cli::namada_wallet_app(version), "namadaw"),
78+
(cli::namada_relayer_app(version), "namadar"),
7879
] {
7980
match shell {
8081
cli::args::Shell::Bash => {

crates/apps/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Imports `pub fn namada_version() -> &'static str` made by build script
2+
include!(concat!(env!("OUT_DIR"), "/version.rs"));

crates/apps_lib/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,3 @@ bit-set.workspace = true
9292
proptest.workspace = true
9393
lazy_static.workspace = true
9494
pretty_assertions.workspace = true
95-
96-
[build-dependencies]
97-
cargo_metadata.workspace = true
98-
git2.workspace = true

0 commit comments

Comments
 (0)