arcboot/
lib.rs

1// PLACE MODULES AND ANY COMPILER GLOBAL CONFIGS HERE
2
3//
4// API
5//
6
7pub mod bootimg;
8pub mod builder;
9pub mod readenv;
10
11//
12// TEST
13//
14
15#[cfg(test)]
16mod tests {
17    #[test]
18    fn it_works() {
19        let result = 2 + 2;
20        assert_eq!(result, 4);
21    }
22}
23
24#[test]
25fn test_build_basic() {
26    let build = builder::Build::new(builder::Arch::Riscv64);
27    // compile boot.S. (! should auto convert {...}.s to {...}.o using prefixing)
28    build.assemble("asm/riscv64/boot.S", "build/boot.o");
29
30    // should be specifying the staticlib as well, can get it from Cargo.toml or the API
31    build.link(
32        &[
33            "build/boot.o".to_string(),
34            "deps/libneutronkern.a".to_string(),
35        ],
36        "link/riscv64/linker.ld",
37        "build/kernel.elf",
38    );
39
40    // cleanup
41    build.clean();
42}
43
44#[test]
45fn test_build_basic_chain() {
46    let build = builder::Build::new(builder::Arch::Riscv64);
47    build
48        .assemble("asm/riscv64/boot.S", "build/boot.o")
49        .link(
50            &[
51                "build/boot.o".to_string(),
52                "deps/libneutronkern.a".to_string(),
53            ],
54            "link/riscv64/linker.ld",
55            "build/kernel.elf",
56        )
57        .clean();
58}