Skip to content

Rewrite for new bootloader build system #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b182044
Update to 2018 edition
phil-opp Mar 26, 2019
3d508ca
Rewrite for new bootloader build system
phil-opp Mar 26, 2019
89e9c50
Remove various config options
phil-opp Mar 27, 2019
a1745f8
Remove the dependency on failure
phil-opp Mar 27, 2019
2e98cbe
Update help and Readme
phil-opp Mar 27, 2019
935dacc
Add example kernels and azure pipelines CI script
phil-opp Mar 27, 2019
7515dee
Add a new `bootimage runner` subcommand for use as `target.runner`
phil-opp Mar 27, 2019
8328212
Run cargo fmt
phil-opp Mar 27, 2019
acfc0b2
Refactor: Move everything to library
phil-opp Mar 27, 2019
e3b7f75
Add a `cargo-bootimage` executable (equivalent to `bootimage build`)
phil-opp Mar 27, 2019
1fc4abd
Avoid newlines between `BUILD` lines in output of `bootimage test`
phil-opp Mar 27, 2019
9287964
Increase test timeout to 5 minutes to allow for longer tests
phil-opp Mar 27, 2019
4c3bca0
Make `test_timeout` configurable
phil-opp Mar 27, 2019
60f0506
Update changelog
phil-opp Mar 27, 2019
3d1bbcb
Add a tester subcommand that can be used to run integration tests
phil-opp Mar 27, 2019
6b53e04
Avoid TryFrom, since it is not in stable yet
phil-opp Apr 1, 2019
bf405e3
We don't need u64 for the test timeout
phil-opp Apr 1, 2019
c8e7bf7
Add a `--run-args` argument
phil-opp Apr 1, 2019
e1d59cd
Add a separate `parse_tester_args` function and add add a `--target` …
phil-opp Apr 1, 2019
9ccaf9f
Use correct target for tester and respect default targets
phil-opp Apr 1, 2019
5aad6cd
Run build command with --message-format=json to find out binary paths
phil-opp Apr 2, 2019
675c8ac
Pass through exit code of run commands
phil-opp Apr 2, 2019
2e6c48f
Print newlines before errors
phil-opp Apr 2, 2019
3739e4e
Update test suite
phil-opp Apr 1, 2019
13b3998
Convert runner args to config keys
phil-opp Apr 2, 2019
c73be6f
Check for correct exit code of `cargo xrun` in CI script
phil-opp Apr 2, 2019
81860b3
Exclude generated test crates from parent workspace
phil-opp Apr 2, 2019
03528dd
Fix imports in tester tests
phil-opp Apr 2, 2019
80aeb7c
Place bootimage-*.bin in default target directory for `runner`
phil-opp Apr 2, 2019
976289a
Use kernel target dir for tester to improve performance
phil-opp Apr 2, 2019
841d2ec
Print path in error message when canonicalization fails
phil-opp Apr 2, 2019
a01c22c
Try to fix test error on Windows
phil-opp Apr 2, 2019
ee987a1
Remove `tester` subcommand again
phil-opp Apr 2, 2019
9598497
Apply config.run_args for `bootimage run` too
phil-opp Apr 2, 2019
683b3ee
Add a `--quiet` argument
phil-opp Apr 2, 2019
cd7d510
Update changelog
phil-opp Apr 2, 2019
a703656
Remove travis CI script
phil-opp Apr 2, 2019
2517b94
Update Readme
phil-opp Apr 2, 2019
2e89280
Remove unused `ExitCode` field of `ErrorString`
phil-opp Apr 2, 2019
667bb26
Rename `ErrorString` to `ErrorMessage`
phil-opp Apr 2, 2019
c6f5afd
Make args module private and remove unused methods
phil-opp Apr 2, 2019
211415d
Remove remaining unwraps in builder module
phil-opp Apr 2, 2019
48d7b80
Make BuildKernelError and CreateBootimageError non-exhaustive
phil-opp Apr 2, 2019
1e8306b
Remove unused config.manifest_path field
phil-opp Apr 2, 2019
3d9e95c
Make config::Config struct non-exhaustive
phil-opp Apr 2, 2019
df26d3e
Remove now unused `tester` example crate
phil-opp Apr 2, 2019
2e73c32
Document all library types
phil-opp Apr 2, 2019
04cdce2
Make help module private
phil-opp Apr 2, 2019
a94c1c3
Update --help output
phil-opp Apr 2, 2019
bfd3858
Replace remaining early exits with proper ErrorMessage returns
phil-opp Apr 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

112 changes: 23 additions & 89 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ license = "MIT/Apache-2.0"
name = "bootimage"
version = "0.6.6"
repository = "https://github.com/rust-osdev/bootimage"
edition = "2018"

[dependencies]
byteorder = "1.3.1"
rayon = "1.0"
toml = "0.5.0"
wait-timeout = "0.2"
xmas-elf = "0.6.2"
llvm-tools = "0.1.1"
locate-cargo-manifest = "0.1.0"
json = "0.11.13"

[dependencies.cargo_metadata]
version = "0.7.4"
default-features = false

[dependencies.failure]
version = "0.1.5"
default-features = false
features = ["std"]
26 changes: 26 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@

## Breaking

- Rewrite for new bootloader build system
- Compatible with bootloader 0.5.0+
- Remove the following config options: `output`, `bootloader.*`, `minimum_image_size`, and `package_filepath`
- The bootloader is now fully controlled through cargo dependencies.
- 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).
- Remove support for `bootloader_precompiled`
- The `bootloader` crate compiles fine on all architectures for some time and should be prefered
- Require the `llvm-tools-preview` rustup component
- Pass the QEMU exit code in `bootimage run`

## Other

- Add support for default targets declared in `.cargo/config` files
- Add a `cargo-bootimage` executable that is equivalent to `bootimage build` and can be used as cargo subcommand (`cargo bootimage`)
- Add a new `bootimage runner` subcommand that can be used as `target.[…].runner` in `.cargo/config` files
- Make test timeout configurable and increase default to 5 minutes
- Move crate to 2018 edition
- Refactor and cleanup the code
- Remove the dependency on `failure`
- Use a custom `ErrorMessage` type instead
- Add a new `run-args` config key
- Add a new `--quiet` argument to suppress output

# 0.6.6

- Update dependencies
Expand Down
69 changes: 56 additions & 13 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,83 @@ Creates a bootable disk image from a Rust OS kernel.

## Usage

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

```toml
# in your Cargo.toml

[dependencies]
bootloader = "0.2.0-alpha"
bootloader = "0.5.0"
```

**Note**: At least bootloader version `0.5.0` is required.

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).

### Building

Now you can build the kernel project and create a bootable disk image from it by running:

```
> bootimage build --target your_custom_target.json [other_args]
bootimage build --target your_custom_target.json [other_args]
```

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.

If you prefer a cargo subcommand, you can use the equivalent `cargo bootimage` command:

```
cargo bootimage --target your_custom_target.json [other_args]
```

### Running

To run your kernel in QEMU, you can use `bootimage run`:

```
bootimage run --target your_custom_target.json [other_args] -- [qemu args]
```

All arguments after `--` are passed to QEMU. If you want to use a custom run command, see the _Configuration_ section below.

If you prefer working directly with cargo, you can use `bootimage runner` as a custom runner in your `.cargo/config`:

```toml
[target.'cfg(target_os = "none")']
runner = "bootimage runner"
```

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.
Now you can run your kernel through `cargo xrun --target […]`.

## Configuration

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

```toml
[package.metadata.bootimage]
default-target = "" # This target is used if no `--target` is passed
output = "bootimage.bin" # The output file name
minimum-image-size = 0 # The minimum output file size (in MiB)
# The command invoked on `bootimage run`
# This target is used if no `--target` is passed
default-target = ""

# The command invoked on `bootimage run` or `bootimage runner`
# (the "{}" will be replaced with the path to the bootable disk image)
run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"]

[package.metadata.bootimage.bootloader]
name = "bootloader" # The bootloader crate name
target = "x86_64-bootloader.json" # Target triple for compiling the bootloader
# Additional arguments passed to the runner on `bootimage run` or `bootimage runner`
# (this is useful when you want to add some arguments to the default QEMU command)
run-args = []

# The timeout for running an integration test through `bootimage test` in seconds
test-timeout = 300
```

## License
Dual-licensed under MIT or the Apache License (Version 2.0).

Licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

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.
Loading