clippy lint corrections
This commit is contained in:
parent
ba574d53e1
commit
ba48d09072
4 changed files with 15 additions and 16 deletions
|
@ -21,7 +21,7 @@ pub fn create_compile_commands_content(
|
||||||
let pwd = pwd.canonicalize().unwrap();
|
let pwd = pwd.canonicalize().unwrap();
|
||||||
let pwd = pwd.to_str().unwrap();
|
let pwd = pwd.to_str().unwrap();
|
||||||
|
|
||||||
if target.sources.len() == 0 {
|
if target.sources.is_empty() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::NoSources,
|
kind: ErrorKind::NoSources,
|
||||||
message: format!(
|
message: format!(
|
||||||
|
@ -32,7 +32,7 @@ pub fn create_compile_commands_content(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, source) in target.sources.iter().enumerate() {
|
for (i, source) in target.sources.iter().enumerate() {
|
||||||
let new_file = source.replace("/", "-");
|
let new_file = source.replace('/', "-");
|
||||||
let obj_name = format!("{}/{}/obj/{}.o", config.build_dir, name, new_file);
|
let obj_name = format!("{}/{}/obj/{}.o", config.build_dir, name, new_file);
|
||||||
|
|
||||||
ret.push_str(&format!(
|
ret.push_str(&format!(
|
||||||
|
@ -62,6 +62,6 @@ pub fn write_compile_commands(filename: &str, content: &[u8]) -> std::io::Result
|
||||||
.open(filename)?;
|
.open(filename)?;
|
||||||
|
|
||||||
let mut writer = BufWriter::new(file);
|
let mut writer = BufWriter::new(file);
|
||||||
writer.write(content)?;
|
writer.write_all(content)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ build {0}: regen_ninjafile {1} || $builddir/compile_commands.json
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_ninja_target(name: &str, target: &Target) -> Result<String> {
|
fn gen_ninja_target(name: &str, target: &Target) -> Result<String> {
|
||||||
if target.sources.len() == 0 {
|
if target.sources.is_empty() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::NoSources,
|
kind: ErrorKind::NoSources,
|
||||||
message: format!("target `{}` has no sources", name),
|
message: format!("target `{}` has no sources", name),
|
||||||
|
@ -124,7 +124,7 @@ build $builddir/{name}/dep: mkdir
|
||||||
let mut object_list: Vec<String> = Vec::new();
|
let mut object_list: Vec<String> = Vec::new();
|
||||||
|
|
||||||
for source in &target.sources {
|
for source in &target.sources {
|
||||||
let new_file = source.replace("/", "-");
|
let new_file = source.replace('/', "-");
|
||||||
let obj_name = format!("$builddir/{}/obj/{}.o", name, new_file);
|
let obj_name = format!("$builddir/{}/obj/{}.o", name, new_file);
|
||||||
let dep_name = format!("$builddir/{}/dep/{}.o.d", name, new_file);
|
let dep_name = format!("$builddir/{}/dep/{}.o.d", name, new_file);
|
||||||
ret.push_str(&format!(
|
ret.push_str(&format!(
|
||||||
|
@ -157,7 +157,7 @@ pub fn create_ninja_file_content(
|
||||||
args: &Args,
|
args: &Args,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
ret.push_str(&gen_ninja_header(&config, &args)?);
|
ret.push_str(&gen_ninja_header(config, args)?);
|
||||||
for (name, target) in &target_list.0 {
|
for (name, target) in &target_list.0 {
|
||||||
let content = gen_ninja_target(name, target);
|
let content = gen_ninja_target(name, target);
|
||||||
match content {
|
match content {
|
||||||
|
@ -182,6 +182,6 @@ pub fn write_ninja_file(filename: &str, content: &[u8]) -> std::io::Result<()> {
|
||||||
.open(filename)?;
|
.open(filename)?;
|
||||||
|
|
||||||
let mut writer = BufWriter::new(file);
|
let mut writer = BufWriter::new(file);
|
||||||
writer.write(content)?;
|
writer.write_all(content)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -55,19 +55,18 @@ fn main() {
|
||||||
|
|
||||||
let mut target_list: TargetList = TargetList(HashMap::new());
|
let mut target_list: TargetList = TargetList(HashMap::new());
|
||||||
for order in &inheritance_order {
|
for order in &inheritance_order {
|
||||||
for name in order.into_iter().rev() {
|
for name in order.iter().rev() {
|
||||||
if let Some(_) = target_list.0.get(name as &str) {
|
if target_list.0.get(name as &str).is_some() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let opts = target_option_list.0.get(name as &str).unwrap();
|
let opts = target_option_list.0.get(name as &str).unwrap();
|
||||||
let deser = deser_target_list.get(name as &str).unwrap();
|
let deser = deser_target_list.get(name as &str).unwrap();
|
||||||
|
|
||||||
let parent: Option<&Target>;
|
let parent: Option<&Target> = if opts.inherit && (name != opts.inherit_from) {
|
||||||
if opts.inherit && (name != opts.inherit_from) {
|
Some(target_list.0.get(opts.inherit_from as &str).unwrap())
|
||||||
parent = Some(target_list.0.get(opts.inherit_from as &str).unwrap());
|
|
||||||
} else {
|
} else {
|
||||||
parent = None;
|
None
|
||||||
}
|
};
|
||||||
|
|
||||||
target_list.0.insert(name, Target::new(opts, deser, parent));
|
target_list.0.insert(name, Target::new(opts, deser, parent));
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl<'a> TargetOptionList<'a> {
|
||||||
match self.0.get(dep) {
|
match self.0.get(dep) {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
dep_chain.insert(name, dep);
|
dep_chain.insert(name, dep);
|
||||||
if let Some(_) = dep_chain.get(dep) {
|
if dep_chain.get(dep).is_some() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::DependencyCycle,
|
kind: ErrorKind::DependencyCycle,
|
||||||
message: format!(
|
message: format!(
|
||||||
|
@ -122,7 +122,7 @@ impl<'a> TargetOptionList<'a> {
|
||||||
match self.0.get(inherit) {
|
match self.0.get(inherit) {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
dep_chain.insert(name, inherit);
|
dep_chain.insert(name, inherit);
|
||||||
if let Some(_) = dep_chain.get(inherit) {
|
if dep_chain.get(inherit).is_some() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::InheritanceCycle,
|
kind: ErrorKind::InheritanceCycle,
|
||||||
message: format!(
|
message: format!(
|
||||||
|
|
Loading…
Reference in a new issue