mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-17 06:47:49 +00:00
Remove all the extern crate definitions
This commit is contained in:
@@ -66,12 +66,6 @@ We will use the [`uart_16550`] crate to initialize the UART and send data over t
|
||||
uart_16550 = "0.1.0"
|
||||
```
|
||||
|
||||
```rust
|
||||
// in src/main.rs
|
||||
|
||||
extern crate uart_16550;
|
||||
```
|
||||
|
||||
The `uart_16550` crate contains a `SerialPort` struct that represents the UART registers, but we still need to construct an instance of it ourselves. For that we create a new `serial` module with the following content:
|
||||
|
||||
```rust
|
||||
@@ -210,8 +204,6 @@ x86_64 = "0.2.8"
|
||||
```rust
|
||||
// in src/main.rs
|
||||
|
||||
extern crate x86_64;
|
||||
|
||||
pub unsafe fn exit_qemu() {
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
@@ -376,16 +368,6 @@ Cargo supports hybrid projects that are both a library and a binary. We only nee
|
||||
|
||||
#![cfg_attr(not(test), no_std)] // don't link the Rust standard library
|
||||
|
||||
extern crate bootloader;
|
||||
extern crate spin;
|
||||
extern crate volatile;
|
||||
extern crate lazy_static;
|
||||
extern crate uart_16550;
|
||||
extern crate x86_64;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate array_init;
|
||||
|
||||
// NEW: We need to add `pub` here to make them accessible from the outside
|
||||
pub mod vga_buffer;
|
||||
pub mod serial;
|
||||
@@ -405,9 +387,6 @@ pub unsafe fn exit_qemu() {
|
||||
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
// NEW: Add the library as dependency (same crate name as executable)
|
||||
extern crate blog_os;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use blog_os::println;
|
||||
|
||||
@@ -430,7 +409,7 @@ fn panic(info: &PanicInfo) -> ! {
|
||||
}
|
||||
```
|
||||
|
||||
So we move everything except `_start` and `panic` to `lib.rs`, make the `vga_buffer` and `serial` modules public, and add an `extern crate` definition to our `main.rs`. Everything should work exactly as before, including `bootimage run` and `cargo test`.
|
||||
So we move everything except `_start` and `panic` to `lib.rs` and make the `vga_buffer` and `serial` modules public. Everything should work exactly as before, including `bootimage run` and `cargo test`.
|
||||
|
||||
### Test Basic Boot
|
||||
|
||||
@@ -443,9 +422,6 @@ We are finally able to create our first integration test executable. We start si
|
||||
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
// add the library as dependency (same crate name as executable)
|
||||
extern crate blog_os;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use blog_os::{exit_qemu, serial_println};
|
||||
|
||||
@@ -507,8 +483,6 @@ To test that our panic handler is really invoked on a panic, we create a `test-p
|
||||
#![cfg_attr(not(test), no_main)]
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
|
||||
|
||||
extern crate blog_os;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use blog_os::{exit_qemu, serial_println};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user