Update proper dep for builder in OSDK and allow publishing

This commit is contained in:
Zhang Junyang
2024-04-25 10:07:14 +08:00
committed by Tate, Hongliang Tian
parent bd0611f1e3
commit 57f4ed778d
8 changed files with 31 additions and 6 deletions

View File

@ -22,8 +22,12 @@ pub fn execute_new_command(args: &NewArgs) {
/// OSDK assumes that the toolchain used by the kernel should be same same as the toolchain
/// specified in the asterinas workspace.
fn aster_rust_toolchain() -> &'static str {
include_str!("../../../../rust-toolchain.toml")
fn aster_rust_toolchain() -> String {
// Here we can't just include it in the repository root because that can't be
// read when publishing. Please ensure update both files when updating the toolchain.
let template = include_str!("./rust-toolchain.toml.template");
// Delete first two lines of comments.
template.lines().skip(2).collect::<Vec<_>>().join("\n")
}
fn add_manifest_dependencies(cargo_metadata: &serde_json::Value, crate_name: &str) {
@ -190,7 +194,7 @@ fn get_package_metadata<'a>(
fn check_rust_toolchain(toolchain: &toml::Table) {
let expected = {
let contents = aster_rust_toolchain();
toml::Table::from_str(contents).unwrap()
toml::Table::from_str(&contents).unwrap()
};
let expected = expected.get("toolchain").unwrap().as_table().unwrap();

View File

@ -0,0 +1,5 @@
# One should also update asterinas/rust-toolchain.toml when updating this.
# The first two lines will be deleted when generating the user's toolchain file.
[toolchain]
channel = "nightly-2024-01-01"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]