Skip to content
Snippets Groups Projects
Commit 08fa245d authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Fix some names following crate rename

parent f3b06a87
No related branches found
No related tags found
No related merge requests found
...@@ -12,22 +12,21 @@ use clap::{Parser, Subcommand}; ...@@ -12,22 +12,21 @@ use clap::{Parser, Subcommand};
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
pub struct Opts { pub struct Opts {
#[command(subcommand)] #[command(subcommand)]
command: PipToolSubcommand, command: TrollSubcommand,
} }
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
pub enum PipToolSubcommand { pub enum TrollSubcommand {
/// Generate a new pip partition project /// Generate a new project
New(new::Opts), New(new::Opts),
/// Link elf files together and generate a binary blob ready to be /// Link elf files together and generate a Troll binary blob ready to be flashed/loaded
/// flashed/loaded
Link(link::Opts), Link(link::Opts),
} }
pub fn execute(opts: Opts) -> Result<()> { pub fn execute(opts: Opts) -> Result<()> {
match opts.command { match opts.command {
PipToolSubcommand::New(opts) => new::generate(opts)?, TrollSubcommand::New(opts) => new::generate(opts)?,
PipToolSubcommand::Link(opts) => link::link(opts)?, TrollSubcommand::Link(opts) => link::link(opts)?,
} }
Ok(()) Ok(())
} }
...@@ -62,7 +62,7 @@ pub struct Opts { ...@@ -62,7 +62,7 @@ pub struct Opts {
/// Dump the binary content of the given sections to the output file. /// Dump the binary content of the given sections to the output file.
/// ///
/// It returns the number of bytes writen /// It returns the number of bytes writen
fn dump_sections<'s, T: Write>( fn dump_sections<T: Write>(
elf: &elf::ElfBytes<AnyEndian>, elf: &elf::ElfBytes<AnyEndian>,
section_names: &[&str], section_names: &[&str],
output: &mut T, output: &mut T,
......
...@@ -8,23 +8,22 @@ use std::path::PathBuf; ...@@ -8,23 +8,22 @@ use std::path::PathBuf;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
pub struct Opts { pub struct Opts {
/// The path where to generate your crate /// The path where to generate your project
crate_path: PathBuf, project_path: PathBuf,
/// The name of the generated project. If omitted, deduced from /// The name of the generated project. If omitted, deduced from
/// the crate_path parameter /// the PROJECT_PATH parameter
#[arg(long, short)] #[arg(long, short)]
crate_name: Option<String>, project_name: Option<String>,
} }
const PIP_MPU_TEMPLATE_PATH: &str = const PIP_MPU_TEMPLATE_PATH: &str = "https://gitlab.univ-lille.fr/2xs/pip/troll-template.git";
"https://gitlab.univ-lille.fr/2xs/pip/troll-template.git";
pub fn generate(opts: Opts) -> Result<()> { pub fn generate(opts: Opts) -> Result<()> {
let crate_name = match opts.crate_name { let project_name = match opts.project_name {
Some(name) => name, Some(name) => name,
None => opts None => opts
.crate_path .project_path
.file_name() .file_name()
.unwrap() .unwrap()
.to_os_string() .to_os_string()
...@@ -33,10 +32,10 @@ pub fn generate(opts: Opts) -> Result<()> { ...@@ -33,10 +32,10 @@ pub fn generate(opts: Opts) -> Result<()> {
}; };
let scaffold_opts = cargo_scaffold::Opts::builder(PIP_MPU_TEMPLATE_PATH) let scaffold_opts = cargo_scaffold::Opts::builder(PIP_MPU_TEMPLATE_PATH)
.parameters(vec![format!("crate_name={}", crate_name)]) .parameters(vec![format!("project_name={}", project_name)])
.force(true) .force(true)
.project_name(crate_name) .project_name(project_name)
.target_dir(opts.crate_path); .target_dir(opts.project_path);
cargo_scaffold::ScaffoldDescription::new(scaffold_opts)?.scaffold() cargo_scaffold::ScaffoldDescription::new(scaffold_opts)?.scaffold()
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment