Skip to content

Commit f061de6

Browse files
authored
Add import command to import files from non-bender repositories (#99)
* Add vendor config to Manifest * Change git linking to not require session * Add `import` command
1 parent be30c90 commit f061de6

File tree

11 files changed

+655
-17
lines changed

11 files changed

+655
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
88

99
### Added
1010
- Add clippy to github CI and fix noted issues
11+
- Add `import` command to import files from non-bender repositories
1112

1213
### Changed
1314
- Update `tokio` dependency, update to `futures=0.3`, rewrite for `async/await`. Bumps minimum rust to 1.57

Cargo.lock

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ itertools = "0.10"
2828
atty = "0.2"
2929
tabwriter = "1.2.1"
3030
indexmap = "1.8.1"
31+
tempdir = "0.3.7"
32+
glob = "0.3"

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ workspace:
175175
# Optional. Only available in dependent packages.
176176
plugins:
177177
hello: scripts/hello.sh
178+
179+
# List of imported files from external repositories not supporting bender. Optional
180+
external_import:
181+
# package name
182+
- name: lowrisc_opentitan
183+
# target directory
184+
target_dir: vendor/lowrisc_opentitan
185+
# upstream dependency (i.e. git repository similar to dependencies)
186+
upstream: { git: "https://github.com/lowRISC/opentitan.git", rev: "47a0f4798febd9e53dd131ef8c8c2b0255d8c139" }
187+
# paths to exclude from upstream dependency
188+
exclude_from_upstream:
189+
- "ci/*"
190+
# directory containing patch files
191+
patch_dir: "vendor/patches"
192+
# file mapping from remote repository to local repository, with optional patch_dir containing patches
193+
mapping:
194+
- {from: 'hw/ip/prim/rtl/prim_subreg.sv', to: 'src/prim_subreg.sv' }
195+
- {from: 'hw/ip/prim/rtl/prim_subreg_arb.sv', to: 'src/prim_subreg_arb.sv' }
196+
- {from: 'hw/ip/prim/rtl/prim_subreg_ext.sv', to: 'src/prim_subreg_ext.sv', patch_dir: 'lowrisc_opentitan' }
197+
- {from: 'hw/ip/prim/rtl/prim_subreg_shadow.sv', to: 'src/prim_subreg_shadow.sv' }
178198
```
179199
180200
[Relevant code](https://github.com/pulp-platform/bender/blob/master/src/config.rs)
@@ -291,6 +311,11 @@ Additionally, we suggest to use the following targets to identify source code an
291311

292312
[Relevant code](https://github.com/pulp-platform/bender/blob/master/src/target.rs)
293313

314+
### Vendor
315+
316+
Section to list files and directories copied and patched within this repository from external repositories not supporting bender.
317+
To update, see below `vendor` command.
318+
294319

295320
## Configuration Format (`bender.yml`, `Bender.local`)
296321

@@ -429,6 +454,16 @@ The `bender parents <PKG>` command lists all packages calling the `PKG` package.
429454

430455
This command will ensure all dependencies are downloaded from remote repositories. This is usually automatically executed by other commands, such as `sources` and `script`.
431456

457+
### `import` --- Copy files from dependencies that do not support bender
458+
459+
This command will update the dependencies listed in the `external_import` section of the `Bender.yml` file, fetching the files from the remote repositories and applying the necessary patch files.
460+
This command will print a diff to the patched remote repository.
461+
If the `--refetch` argument is passed, it will refetch the upstream and apply patched.
462+
If the `--gen_patch` argument is passed, it will generate additional new patches from the current diff.
463+
If the `-n/--no_patch` argument is passed, any application of current patches will be suppressed, with `--gen_patch` any existing patch files will be deleted and a new patch created.
464+
Please make sure you manage the includes and sources required for these files separately, as this command only fetches the files and patches them.
465+
This is in part based on [lowRISC's `vendor.py` script](https://github.com/lowRISC/opentitan/blob/master/util/vendor.py).
466+
432467
[aur-bender]: https://aur.archlinux.org/packages/bender
433468
[releases]: https://github.com/pulp-platform/bender/releases
434469
[rust-installation]: https://doc.rust-lang.org/book/ch01-01-installation.html

src/cli.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ pub fn main() -> Result<()> {
5454
.subcommand(cmd::sources::new())
5555
.subcommand(cmd::config::new())
5656
.subcommand(cmd::script::new())
57-
.subcommand(cmd::checkout::new());
57+
.subcommand(cmd::checkout::new())
58+
.subcommand(cmd::import::new());
5859

5960
// Add the `--debug` option in debug builds.
6061
let app = if cfg!(debug_assertions) {
@@ -234,6 +235,7 @@ pub fn main() -> Result<()> {
234235
Some(("script", matches)) => cmd::script::run(&sess, matches),
235236
Some(("checkout", matches)) => cmd::checkout::run(&sess, matches),
236237
Some(("update", _)) => Ok(()),
238+
Some(("import", matches)) => cmd::import::run(&sess, matches),
237239
Some((plugin, matches)) => execute_plugin(&sess, plugin, matches.values_of_os("")),
238240
_ => Ok(()),
239241
}

0 commit comments

Comments
 (0)