diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml new file mode 100644 index 0000000..f10d3e5 --- /dev/null +++ b/.github/workflows/check-and-lint.yaml @@ -0,0 +1,90 @@ +name: Check and Lint + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: Cargo check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Get toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: cargo check + - run: cargo check --all-features + + clippy: + name: Lint with Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Get toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: clippy + override: true + - run: cargo clippy --all-features -- -D warnings + + format: + name: Check formatting + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Get toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - run: cargo fmt --all -- --check + + doc: + name: Lint Documentation + runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: -D warnings + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Get toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Check documentation + run: cargo doc --no-deps --all-features --document-private-items + + cargo-deny: + runs-on: ubuntu-latest + strategy: + matrix: + checks: + - advisories + - bans licenses sources + + # Prevent sudden announcement of a new advisory from failing ci: + continue-on-error: ${{ matrix.checks == 'advisories' }} + + steps: + - uses: actions/checkout@v3 + - uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check ${{ matrix.checks }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..b7cffbb --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,38 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Get toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Cache dependencies + uses: actions/cache@v2 + env: + cache-name: cache-dependencies + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/bin + ~/.cargo/registry/index + ~/.cargo/registry/cache + target + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} + - run: cargo test --verbose --all -- --nocapture diff --git a/src/lib.rs b/src/lib.rs index 0e95b9c..cda58ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,7 @@ //! - Support [tracing](#tracing) of register accesses and additionally mocking of registers on non-embedded devices through //! external libraries. This allows the execution unit tests for code that uses the generated libraries on non-embedded devices. //! - PAC shall have ideally 0 dependencies to any other crates. -//! +//! //! # chiptool features implemented by `svd2pac` //! //! - No owned data structure -> unsafe api that can be used from any interrupts or thread. @@ -33,10 +33,10 @@ //! - Support also for 8,16,64 bit size registers. //! - Avoid long type and bitfield names (chiptool concatenates identifiers) by generating modules for registers and svd clusters. //! - No support for SVD transformation. -//! +//! //! # Limitations //! -//! * Inheritance via `derivedFrom` attribute is supported only in `cluster` declaration and requires +//! * Inheritance via `derivedFrom` attribute is supported only in `cluster` declaration and requires //! that child is not overriding anything except `name`, `description` and `offset` //! * `headerStructName` tag is considered only in `cluster`` tag //! * `resetMask` tag is ignored diff --git a/src/rust_gen/xml2ir.rs b/src/rust_gen/xml2ir.rs index 9634075..217a2e6 100644 --- a/src/rust_gen/xml2ir.rs +++ b/src/rust_gen/xml2ir.rs @@ -267,7 +267,7 @@ fn get_cluster( if !registers.is_empty() || !clusters.is_empty() { error!("Cluster with derivedFrom attributes are supported only if they doesn't contains registers and/or clusters. Included registers and clusters are ignored") } - get_parent_struct_name_cluster(device, container, &derived_path) + get_parent_struct_name_cluster(device, container, derived_path) } else { let mut struct_name = cluster.struct_name().to_sanitized_struct_ident(); struct_name.insert_str(0, "self::"); @@ -367,7 +367,7 @@ fn get_peripherals_types( /// # Result /// /// Device containing all information of svd file -fn parse_xml(xml: &mut String, svd_validation_level: SvdValidationLevel) -> Result { +fn parse_xml(xml: &mut str, svd_validation_level: SvdValidationLevel) -> Result { let mut parser_config = svd_parser::Config::default(); parser_config.expand_properties = true; parser_config.ignore_enums = false; @@ -412,7 +412,7 @@ fn get_interrupt_table( } pub(super) fn parse_xml2ir( - xml: &mut String, + xml: &mut str, svd_validation_level: SvdValidationLevel, custom_license_text: &Option, ) -> Result {