upgrade clap to 4.x

pull/456/head
Dmitry Savintsev 2 years ago
parent 52b9ffed60
commit 22340764a3

@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
bindgen = "0.63" bindgen = "0.63"
clap = { version = "3", features = ["derive"] } clap = { version = "4", features = ["derive"] }
anyhow = "1" anyhow = "1"
thiserror = "1" thiserror = "1"
tempfile = "3" tempfile = "3"

@ -7,7 +7,7 @@ publish = false
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
aya = { path = "../../aya" } aya = { path = "../../aya" }
clap = { version = "3", features = ["derive"] } clap = { version = "4", features = ["derive"] }
env_logger = "0.10" env_logger = "0.10"
inventory = "0.2" inventory = "0.2"
integration-test-macros = { path = "../integration-test-macros" } integration-test-macros = { path = "../integration-test-macros" }

@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
aya-tool = { path = "../aya-tool" } aya-tool = { path = "../aya-tool" }
clap = { version = "3", features = ["derive"] } clap = { version = "4", features = ["derive"] }
anyhow = "1" anyhow = "1"
syn = "1" syn = "1"
quote = "1" quote = "1"

@ -37,7 +37,7 @@ impl std::fmt::Display for Architecture {
} }
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
pub struct Options { pub struct BuildEbpfOptions {
/// Set the endianness of the BPF target /// Set the endianness of the BPF target
#[clap(default_value = "bpfel-unknown-none", long)] #[clap(default_value = "bpfel-unknown-none", long)]
pub target: Architecture, pub target: Architecture,
@ -49,12 +49,12 @@ pub struct Options {
pub libbpf_dir: PathBuf, pub libbpf_dir: PathBuf,
} }
pub fn build_ebpf(opts: Options) -> anyhow::Result<()> { pub fn build_ebpf(opts: BuildEbpfOptions) -> anyhow::Result<()> {
build_rust_ebpf(&opts)?; build_rust_ebpf(&opts)?;
build_c_ebpf(&opts) build_c_ebpf(&opts)
} }
fn build_rust_ebpf(opts: &Options) -> anyhow::Result<()> { fn build_rust_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> {
let mut dir = PathBuf::from(WORKSPACE_ROOT.to_string()); let mut dir = PathBuf::from(WORKSPACE_ROOT.to_string());
dir.push("test/integration-ebpf"); dir.push("test/integration-ebpf");
@ -92,7 +92,7 @@ fn get_libbpf_headers<P: AsRef<Path>>(libbpf_dir: P, include_path: P) -> anyhow:
Ok(()) Ok(())
} }
fn build_c_ebpf(opts: &Options) -> anyhow::Result<()> { fn build_c_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> {
let mut src = PathBuf::from(WORKSPACE_ROOT.to_string()); let mut src = PathBuf::from(WORKSPACE_ROOT.to_string());
src.push("test/integration-ebpf/src/bpf"); src.push("test/integration-ebpf/src/bpf");

@ -10,7 +10,7 @@ pub struct Options {
pub musl: bool, pub musl: bool,
#[clap(flatten)] #[clap(flatten)]
pub ebpf_options: build_ebpf::Options, pub ebpf_options: build_ebpf::BuildEbpfOptions,
} }
pub fn build_test(opts: Options) -> anyhow::Result<()> { pub fn build_test(opts: Options) -> anyhow::Result<()> {

@ -54,32 +54,32 @@ impl std::fmt::Display for Architecture {
#[derive(Parser)] #[derive(Parser)]
pub struct Options { pub struct Options {
#[clap(long, action)] #[arg(long, action)]
libbpf_dir: PathBuf, libbpf_dir: PathBuf,
// sysroot options. Default to ubuntu headers installed by the // sysroot options. Default to ubuntu headers installed by the
// libc6-dev-{arm64,armel}-cross packages. // libc6-dev-{arm64,armel}-cross packages.
#[clap(long, default_value = "/usr/include/x86_64-linux-gnu", action)] #[arg(long, default_value = "/usr/include/x86_64-linux-gnu", action)]
x86_64_sysroot: PathBuf, x86_64_sysroot: PathBuf,
#[clap(long, default_value = "/usr/aarch64-linux-gnu/include", action)] #[arg(long, default_value = "/usr/aarch64-linux-gnu/include", action)]
aarch64_sysroot: PathBuf, aarch64_sysroot: PathBuf,
#[clap(long, default_value = "/usr/arm-linux-gnueabi/include", action)] #[arg(long, default_value = "/usr/arm-linux-gnueabi/include", action)]
armv7_sysroot: PathBuf, armv7_sysroot: PathBuf,
#[clap(long, default_value = "/usr/riscv64-linux-gnu/include", action)] #[arg(long, default_value = "/usr/riscv64-linux-gnu/include", action)]
riscv64_sysroot: PathBuf, riscv64_sysroot: PathBuf,
#[clap(subcommand)] #[command(subcommand)]
command: Option<Command>, command: Option<Command>,
} }
#[derive(Parser)] #[derive(clap::Subcommand)]
enum Command { enum Command {
#[clap(name = "aya")] #[command(name = "aya")]
Aya, Aya,
#[clap(name = "aya-bpf-bindings")] #[command(name = "aya-bpf-bindings")]
AyaBpfBindings, AyaBpfBindings,
} }

@ -9,7 +9,7 @@ use std::process::exit;
use clap::Parser; use clap::Parser;
#[derive(Parser)] #[derive(Parser)]
pub struct Options { pub struct XtaskOptions {
#[clap(subcommand)] #[clap(subcommand)]
command: Command, command: Command,
} }
@ -19,12 +19,12 @@ enum Command {
Codegen(codegen::Options), Codegen(codegen::Options),
Docs, Docs,
BuildIntegrationTest(build_test::Options), BuildIntegrationTest(build_test::Options),
BuildIntegrationTestEbpf(build_ebpf::Options), BuildIntegrationTestEbpf(build_ebpf::BuildEbpfOptions),
IntegrationTest(run::Options), IntegrationTest(run::Options),
} }
fn main() { fn main() {
let opts = Options::parse(); let opts = XtaskOptions::parse();
use Command::*; use Command::*;
let ret = match opts.command { let ret = match opts.command {

@ -3,7 +3,7 @@ use std::{os::unix::process::CommandExt, path::PathBuf, process::Command};
use anyhow::Context as _; use anyhow::Context as _;
use clap::Parser; use clap::Parser;
use crate::build_ebpf::{build_ebpf, Architecture, Options as BuildOptions}; use crate::build_ebpf::{build_ebpf, Architecture, BuildEbpfOptions as BuildOptions};
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
pub struct Options { pub struct Options {

Loading…
Cancel
Save