tools: rewrite x86_64 build system #334
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So I rewrote the x86_64 kernel's build system again.
This commit rewrites the builder for the x86_64 kernel to be a cargo
custom runner, rather than a build script in a normal crate. This way,
we can use
$ cargo run --package mnemos-x86_64 --target-arch x86_64-unknown-none
to build the x86 kernel normally using cargo, outputting a path that's
then passed into the custom runner binary by Cargo. This way, we don't
build the whole kernel inside a build script, so we get normal cargo
output from the kernel build, and we don't need to deal with the fact
that we have to rerun the build script whenever the kernel or any of its
dependencies changes. Instead, the kernel is built by a normal cargo
invocation, which is like infinitely better in literally every possible
way. The custom runner can also launch QEMU, so you can now
cargo run
the x86 kernel and IT JUST WORKS, RIGHT OUT OF THE BOX.1
The one weird thing about this approach is that now, you build the
kernel by running
cargo run
with abuild
subcommand that tells it tonot actually build the kernel, instead of
cargo build
like a normalperson. This is, admittedly, weird; but it's so much less bad than the
previous thing where you had to run
cargo clean
every time you changedthe kernel if you didn't want to get a stale build artifact (see #332),
which was incredibly life-ruining and made developing the x86 kernel a
horrific nightmare of infinite pain. And, most of the time you'll build
it using the Justfile
just run-x86
andjust build-x86
recipes so youdon't have to face the horrible truth that you're using
cargo run
tobuild something without running it. So, whatever.
Closes #332
Footnotes
Provided that, like, you have
qemu-system-x86_64
on yourcomputer, and stuff. ↩