mirror of
https://github.com/supleed2/sv-filelist-parser.git
synced 2024-11-10 01:35:49 +00:00
Better support path and str. Incr version v0.1.1
This commit is contained in:
commit
b6c346b61c
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.1] - 2020-02-07
|
||||||
|
### Changed
|
||||||
|
- Argument to `parse_file` is changed to `AsRef<Path>`
|
||||||
|
|
||||||
## [0.1.0] - 2020-02-02
|
## [0.1.0] - 2020-02-02
|
||||||
### Added
|
### Added
|
||||||
- Achieved Feature parity with parser implementation in [dalance/svlint](https://github.com/dalance/svlint/)
|
- Achieved Feature parity with parser implementation in [dalance/svlint](https://github.com/dalance/svlint/)
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -44,7 +44,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "verilog-filelist-parser"
|
name = "verilog-filelist-parser"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "verilog-filelist-parser"
|
name = "verilog-filelist-parser"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Raamakrishnan <raamakrishnan1997@gmail.com>"]
|
authors = ["Raamakrishnan <raamakrishnan1997@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -4,7 +4,7 @@ A library in Rust to parse a Verilog Filelist and return
|
||||||
a list of files, include directories and defines.
|
a list of files, include directories and defines.
|
||||||
|
|
||||||
Environment variables represented with paranthesis or
|
Environment variables represented with paranthesis or
|
||||||
curly braces (i.e. $() or ${}) will be automatically
|
curly braces (i.e. `$()` or `${}`) will be automatically
|
||||||
substituted.
|
substituted.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
|
@ -2,7 +2,7 @@ use regex::Regex;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::line_parser;
|
use crate::line_parser;
|
||||||
use crate::line_parser::LineType;
|
use crate::line_parser::LineType;
|
||||||
|
@ -49,15 +49,16 @@ impl Filelist {
|
||||||
/// Environment variables represented with paranthesis or
|
/// Environment variables represented with paranthesis or
|
||||||
/// curly braces (i.e. `$()` or `${}`) will be automatically
|
/// curly braces (i.e. `$()` or `${}`) will be automatically
|
||||||
/// substituted.
|
/// substituted.
|
||||||
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `path` - A string slice that is the path to the filelist
|
/// * `path` - The path to the filelist
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Returns an error if the filelist in `path` cannot be read. Also returns
|
/// Returns an error if the filelist in `path` cannot be read. Also returns
|
||||||
/// error if any of the nested filelists cannot be read.
|
/// error if any of the nested filelists cannot be read.
|
||||||
pub fn parse_file(path: &str) -> Result<Filelist, Box<dyn Error>> {
|
pub fn parse_file(path: impl AsRef<Path>) -> Result<Filelist, Box<dyn Error>> {
|
||||||
let contents = fs::read_to_string(path)?;
|
let contents = fs::read_to_string(path)?;
|
||||||
|
|
||||||
let mut filelist = Filelist::new();
|
let mut filelist = Filelist::new();
|
||||||
|
|
Loading…
Reference in a new issue