{"id":16118572,"url":"https://github.com/duskmoon314/pac-xtask","last_synced_at":"2025-03-17T18:30:41.766Z","repository":{"id":104179899,"uuid":"555633513","full_name":"duskmoon314/pac-xtask","owner":"duskmoon314","description":"xtask for pac","archived":false,"fork":false,"pushed_at":"2025-03-10T18:12:09.000Z","size":3077,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T19:27:34.642Z","etag":null,"topics":["embedded","rust","xtask"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duskmoon314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-22T01:13:47.000Z","updated_at":"2023-02-02T11:51:54.000Z","dependencies_parsed_at":"2024-03-31T12:24:12.299Z","dependency_job_id":"0773551d-86b9-4b42-9b03-515a60371ce5","html_url":"https://github.com/duskmoon314/pac-xtask","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duskmoon314%2Fpac-xtask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duskmoon314%2Fpac-xtask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duskmoon314%2Fpac-xtask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duskmoon314%2Fpac-xtask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duskmoon314","download_url":"https://codeload.github.com/duskmoon314/pac-xtask/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878439,"owners_count":20362432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded","rust","xtask"],"created_at":"2024-10-09T20:49:57.245Z","updated_at":"2025-03-17T18:30:41.482Z","avatar_url":"https://github.com/duskmoon314.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pac-xtask\n\nA very simple xtask crate for pac crates, with a few useful commands.\n\n\u003e This crate may not fit your needs, please modify it to your needs.\n\n## Add to your pac crate\n\nI suggest reading [`matklad/cargo-xtask`](https://github.com/matklad/cargo-xtask) first to understand what xtask is and how it works.\n\n### Prerequisites\n\n#### Make the xtask crate a workspace member\n\nFirst, you need to make the xtask crate a workspace member.\n\nSee [below](#add-xtask) for adding the xtask crate to your workspace.\n\n##### Single pac crate\n\nIf you only have a single pac crate, you can just add the xtask crate to the workspace members in the root `Cargo.toml`:\n\n```toml\n# Your pac's Cargo.toml\n\n[package]\nname = \"\u003cyour soc\u003e-pac\"\n...\n\n[workspace]\nmembers = [\"xtask\"]\n```\n\n##### Multiple pac crates\n\nIf you have multiple pac crates in one workspace already, you can simply add the xtask crate to the workspace members in the root `Cargo.toml`:\n\n```toml\n[workspace]\nmembers = [\"soc1-pac\", \"soc2-pac\", \"xtask\"]\n```\n\n#### Add workspace configuration\n\nYou need to add the following configuration to the `.cargo/config.toml` file in the root of your workspace:\n\n```toml\n[alias]\nxtask = \"run --package xtask --release --\"\n\n[env]\nCARGO_WORKSPACE_DIR = { value = \"\", relative = true }\n```\n\nThe `alias` part does the trick of making `cargo xtask` work, and the `env` part is needed to pass the workspace directory to the `xtask` crate.\n\n#### Add xtask configuration\n\n`xtask` needs to get metadata of pac crates in the workspace, so you need to add the following configuration to the `.xtask.toml` in the root of your workspace:\n\n```toml\n[[pacs]]\nchip_name = [\"soc1\", \"SOC1\"]    # A list of an soc's names\ncrate_name = \"soc1-pac\"         # The name (dir) of the pac crate\nsvd_name = \"soc1\"               # The name of the svd file\ntarget = \"riscv\"                # The target of the pac crate\npatch = false                   # Whether to patch the svd (Not impl yet)\n\n[[pacs]]\n...                             # other pac crates\n```\n\n\u003e This configuration is currently designed for [`duskmoon314/aw-pac`](https://github.com/duskmoon314/aw-pac). Thus, the `crate_name` is actually the directory name of the pac crate and `xtask` assume that the svd file is at `svd/\u003csvd_name\u003e.svd`. If you have a different structure, you need to modify the `xtask` crate.\n\u003e\n\u003e Need to refactor this part.\n\n### Add xtask\n\nYou can just download the source code, using `git subtree` or anything you like. I have tested the `git subtree` and it seems working well.\n\n```shell\n# First, you can add this repo as a remote\n# HTTPS way\ngit remote add -f xtask https://github.com/duskmoon314/pac-xtask.git\n# SSH way\ngit remote add -f xtask git@github.com:duskmoon314/pac-xtask.git\n\n# Then, you can add the xtask crate to your workspace\n# Strongly suggest to use the `--squash` option and modify the message\ngit subtree add --prefix xtask xtask main --squash -m \"build: add pac-xtask as subtree\"\n\n# You can check the history after adding the xtask crate in the above way\ngit log --oneline --graph\n\n*   659efd5 (HEAD -\u003e main) build: add pac-xtask as subtree\n|\\\n| * e324fb7 Squashed 'xtask/' content from commit af40bdd\n#### Previous commits\n```\n\n## Usage\n\nYou can use `cargo xtask` to run the xtask crate. A Brief usage is shown below:\n\n```shell\n\u003e cargo xtask --help\n    Finished release [optimized] target(s) in 0.13s\n     Running `target/release/xtask --help`\nUsage: xtask [CHIPS]... \u003cCOMMAND\u003e\n\nCommands:\n  codegen  Generate code from svd files\n  svd-fmt  Format svd files\n  help     Print this message or the help of the given subcommand(s)\n\nArguments:\n  [CHIPS]...  Names of chips to do xtask on\n\nOptions:\n  -h, --help  Print help information\n```\n\n### Codegen\n\nThis command will use `svd2rust` to generate code and `form` to format the code.\n\n```shell\ncargo xtask codegen \u003ca name in soc's chip_name\u003e\n\n# Example\ncargo xtask codegen soc1\n```\n\n### SVD format\n\nThis command will use `svdtools` to format the svd file.\n\n```shell\ncargo xtask svd-fmt \u003ca name in soc's chip_name\u003e\n\n# Example\ncargo xtask svd-fmt soc1\n```\n\nTo use this command, currently you need to have an `.svdfmt.yaml` file at `\u003cworkspace root\u003e/svd/.svdfmt.yaml`. You can modify the path in the `xtask` crate if you want.\n\nThe content of the `.svdfmt.yaml` file is like this:\n\n```yaml\n# An experimental config file for svdtools fmt feature.\nperipheral_name: Constant\nperipheral_base_address: UpperHex16\naddress_block_offset: UpperHex\naddress_block_size: UpperHex\ninterrupt_name: Constant\ncluster_name: Snake\ncluster_address_offset: UpperHex\nregister_name: Snake\nregister_address_offset: UpperHex\nregister_size: Dec\nregister_reset_value: UpperHex16\nregister_reset_mask: UpperHex16\nfield_name: Snake\nfield_bit_range: BitRange\nenumerated_values_name: Pascal\nenumerated_value_name: Constant\nenumerated_value_value: UpperHex\ndim_dim: Dec\ndim_increment: UpperHex\n```\n\nTo see all the options, you can view the [`svd-encoder`'s source code](https://github.com/rust-embedded/svd/blob/master/svd-encoder/src/config.rs)\n\n## License\n\nThis project is licensed under\n\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduskmoon314%2Fpac-xtask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduskmoon314%2Fpac-xtask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduskmoon314%2Fpac-xtask/lists"}