Skip to content

Commit 767bdfe

Browse files
bors[bot]phil-opp
andcommitted
Merge #34
34: Rewrite for new bootloader build system r=phil-opp a=phil-opp This PR rewrites the `bootimage` crate to work with the new bootloader build system proposed in rust-osdev/bootloader#51. It also removes support for some old configuration options and for the `bootloader_precompiled` crate. See the changelog updates for more information. Note that this new version will only work with bootloader `0.5.0` or later. Todo: - [x] Add a `cargo-bootimage` executable - [x] Create a `bootimage runner` subcommand - [x] Create a `bootimage tester` subcommand - [x] Blocked on rust-osdev/bootloader#51 - [x] Rustdoc - [x] Mention new runner ~/tester~ in the Readme - [x] Command line help for new commands - [x] Error message for older bootloader versions (with old build system) - [x] Update changelog Co-authored-by: Philipp Oppermann <[email protected]>
2 parents beb9541 + bfd3858 commit 767bdfe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2161
-934
lines changed

.travis.yml

-46
This file was deleted.

Cargo.lock

+23-89
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ license = "MIT/Apache-2.0"
55
name = "bootimage"
66
version = "0.6.6"
77
repository = "https://github.com/rust-osdev/bootimage"
8+
edition = "2018"
89

910
[dependencies]
10-
byteorder = "1.3.1"
1111
rayon = "1.0"
1212
toml = "0.5.0"
1313
wait-timeout = "0.2"
14-
xmas-elf = "0.6.2"
14+
llvm-tools = "0.1.1"
15+
locate-cargo-manifest = "0.1.0"
16+
json = "0.11.13"
1517

1618
[dependencies.cargo_metadata]
1719
version = "0.7.4"
1820
default-features = false
19-
20-
[dependencies.failure]
21-
version = "0.1.5"
22-
default-features = false
23-
features = ["std"]

Changelog.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
2+
## Breaking
3+
4+
- Rewrite for new bootloader build system
5+
- Compatible with bootloader 0.5.0+
6+
- Remove the following config options: `output`, `bootloader.*`, `minimum_image_size`, and `package_filepath`
7+
- The bootloader is now fully controlled through cargo dependencies.
8+
- For using a bootloader crate with name different than `bootloader` use [cargo's rename feature](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml).
9+
- Remove support for `bootloader_precompiled`
10+
- The `bootloader` crate compiles fine on all architectures for some time and should be prefered
11+
- Require the `llvm-tools-preview` rustup component
12+
- Pass the QEMU exit code in `bootimage run`
13+
14+
## Other
15+
16+
- Add support for default targets declared in `.cargo/config` files
17+
- Add a `cargo-bootimage` executable that is equivalent to `bootimage build` and can be used as cargo subcommand (`cargo bootimage`)
18+
- Add a new `bootimage runner` subcommand that can be used as `target.[…].runner` in `.cargo/config` files
19+
- Make test timeout configurable and increase default to 5 minutes
20+
- Move crate to 2018 edition
21+
- Refactor and cleanup the code
22+
- Remove the dependency on `failure`
23+
- Use a custom `ErrorMessage` type instead
24+
- Add a new `run-args` config key
25+
- Add a new `--quiet` argument to suppress output
26+
127
# 0.6.6
228

329
- Update dependencies

Readme.md

+56-13
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,83 @@ Creates a bootable disk image from a Rust OS kernel.
1010

1111
## Usage
1212

13-
First you need to add a dependency on the `bootloader` crate:
13+
First you need to add a dependency on the [`bootloader`](https://github.com/rust-osdev/bootloader) crate:
1414

1515
```toml
1616
# in your Cargo.toml
1717

1818
[dependencies]
19-
bootloader = "0.2.0-alpha"
19+
bootloader = "0.5.0"
2020
```
2121

22+
**Note**: At least bootloader version `0.5.0` is required.
23+
24+
If you want to use a custom bootloader with a different name, you can use Cargo's [rename functionality](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml).
25+
26+
### Building
27+
2228
Now you can build the kernel project and create a bootable disk image from it by running:
2329

2430
```
25-
> bootimage build --target your_custom_target.json [other_args]
31+
bootimage build --target your_custom_target.json [other_args]
32+
```
33+
34+
The command will invoke [`cargo xbuild`](https://github.com/rust-osdev/cargo-xbuild), forwarding all passed options. Then it will build the specified bootloader together with the kernel to create a bootable disk image.
35+
36+
If you prefer a cargo subcommand, you can use the equivalent `cargo bootimage` command:
37+
38+
```
39+
cargo bootimage --target your_custom_target.json [other_args]
40+
```
41+
42+
### Running
43+
44+
To run your kernel in QEMU, you can use `bootimage run`:
45+
46+
```
47+
bootimage run --target your_custom_target.json [other_args] -- [qemu args]
48+
```
49+
50+
All arguments after `--` are passed to QEMU. If you want to use a custom run command, see the _Configuration_ section below.
51+
52+
If you prefer working directly with cargo, you can use `bootimage runner` as a custom runner in your `.cargo/config`:
53+
54+
```toml
55+
[target.'cfg(target_os = "none")']
56+
runner = "bootimage runner"
2657
```
2758

28-
The command will invoke [`cargo xbuild`](https://github.com/rust-osdev/cargo-xbuild), forwarding all passed options. Then it will download and build a bootloader, by default the [rust-osdev/bootloader](https://github.com/rust-osdev/bootloader). Finally, it combines the kernel and the bootloader into a bootable disk image.
59+
Now you can run your kernel through `cargo xrun --target […]`.
2960

3061
## Configuration
3162

32-
Configuration is done through a through a `[package.metadata.bootimage]` table in the `Cargo.toml`. The following options are available:
63+
Configuration is done through a through a `[package.metadata.bootimage]` table in the `Cargo.toml` of your kernel. The following options are available:
3364

3465
```toml
3566
[package.metadata.bootimage]
36-
default-target = "" # This target is used if no `--target` is passed
37-
output = "bootimage.bin" # The output file name
38-
minimum-image-size = 0 # The minimum output file size (in MiB)
39-
# The command invoked on `bootimage run`
67+
# This target is used if no `--target` is passed
68+
default-target = ""
69+
70+
# The command invoked on `bootimage run` or `bootimage runner`
4071
# (the "{}" will be replaced with the path to the bootable disk image)
4172
run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"]
4273

43-
[package.metadata.bootimage.bootloader]
44-
name = "bootloader" # The bootloader crate name
45-
target = "x86_64-bootloader.json" # Target triple for compiling the bootloader
74+
# Additional arguments passed to the runner on `bootimage run` or `bootimage runner`
75+
# (this is useful when you want to add some arguments to the default QEMU command)
76+
run-args = []
77+
78+
# The timeout for running an integration test through `bootimage test` in seconds
79+
test-timeout = 300
4680
```
4781

4882
## License
49-
Dual-licensed under MIT or the Apache License (Version 2.0).
83+
84+
Licensed under either of
85+
86+
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
87+
http://www.apache.org/licenses/LICENSE-2.0)
88+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
89+
90+
at your option.
91+
92+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)