Skip to content

Commit

Permalink
No longer use default features in axtask
Browse files Browse the repository at this point in the history
  • Loading branch information
equation314 committed Jul 21, 2023
1 parent 88a90a0 commit 6852d92
Show file tree
Hide file tree
Showing 44 changed files with 231 additions and 143 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export PATH=`pwd`/x86_64-linux-musl-cross/bin:`pwd`/aarch64-linux-musl-cross/bin

```bash
# in arceos directory
make A=path/to/app ARCH=<arch> LOG=<log> NET=[y|n] FS=[y|n]
make A=path/to/app ARCH=<arch> LOG=<log> NET=[y|n] BLK=[y|n]
```

Where `<arch>` should be one of `riscv64`, `aarch64``x86_64`.
Expand Down Expand Up @@ -153,7 +153,6 @@ make A=apps/net/httpserver ARCH=aarch64 LOG=info NET=y SMP=4 run

```bash
# in features.txt
default
alloc
paging
net
Expand Down
1 change: 0 additions & 1 deletion apps/c/httpclient/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
alloc
paging
net
1 change: 0 additions & 1 deletion apps/c/httpserver/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
alloc
paging
net
1 change: 0 additions & 1 deletion apps/c/iperf/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
alloc
paging
net
Expand Down
1 change: 0 additions & 1 deletion apps/c/memtest/features.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
default
alloc
paging
1 change: 0 additions & 1 deletion apps/c/pthread/basic/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
alloc
paging
multitask
60 changes: 60 additions & 0 deletions apps/c/pthread/parallel/expect_info_smp4_fifo.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
smp = 4
build_mode = release
log_level = info

CPU 0 started
Found physcial memory regions:
.text (READ | EXECUTE | RESERVED)
.rodata (READ | RESERVED)
.data (READ | WRITE | RESERVED)
.percpu (READ | WRITE | RESERVED)
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize kernel page table...
Initialize platform devices...
Initialize scheduling...
use FIFO scheduler
CPU 1 started
CPU 1 init OK
CPU 2 started
CPU 2 init OK
CPU 3 started
CPU 3 init OK
CPU 0 init OK
part 0: \[0, 125000)
part 1: \[125000, 250000)
part 2: \[250000, 375000)
part 3: \[375000, 500000)
part 0 finished
part 4: \[500000, 625000)
part 1 finished
part 5: \[625000, 750000)
part 2 finished
part 6: \[750000, 875000)
part 3 finished
part 7: \[875000, 1000000)
part 4 finished
part 8: \[1000000, 1125000)
part 5 finished
part 9: \[1125000, 1250000)
part 6 finished
part 10: \[1250000, 1375000)
part 7 finished
part 11: \[1375000, 1500000)
part 8 finished
part 12: \[1500000, 1625000)
part 9 finished
part 13: \[1625000, 1750000)
part 10 finished
part 14: \[1750000, 1875000)
part 11 finished
part 15: \[1875000, 2000000)
part 12 finished
part 13 finished
part 14 finished
part 15 finished
actual sum = 61783189038
(C)Pthread parallel run OK!
Shutting down...
1 change: 0 additions & 1 deletion apps/c/pthread/parallel/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
alloc
paging
multitask
sched_rr
3 changes: 2 additions & 1 deletion apps/c/pthread/parallel/test_cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
test_one "SMP=4 LOG=info" "expect_info_smp4_rr.out"
test_one "SMP=4 LOG=info" "expect_info_smp4_fifo.out"
test_one "SMP=4 LOG=info APP_FEATURES=sched_rr" "expect_info_smp4_rr.out"
rm -f $APP/*.o
1 change: 0 additions & 1 deletion apps/c/pthread/pipe/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
paging
alloc
multitask
Expand Down
1 change: 0 additions & 1 deletion apps/c/pthread/sleep/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
paging
alloc
multitask
Expand Down
1 change: 0 additions & 1 deletion apps/c/sqlite3/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
fp_simd
alloc
paging
Expand Down
1 change: 0 additions & 1 deletion apps/c/udpserver/features.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default
alloc
paging
net
2 changes: 1 addition & 1 deletion apps/display/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ authors = ["Shiping Yuan <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libax = { path = "../../ulib/libax", features = ["alloc", "paging", "display"] }
libax = { path = "../../ulib/libax", features = ["display"] }
embedded-graphics = "0.8"
2 changes: 1 addition & 1 deletion apps/net/echoserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libax = { path = "../../../ulib/libax", features = ["paging", "multitask", "net"] }
libax = { path = "../../../ulib/libax", features = ["multitask", "net"] }
3 changes: 2 additions & 1 deletion apps/net/httpclient/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ name = "arceos-httpclient"
version = "0.1.0"
edition = "2021"
authors = ["Yuekai Jia <[email protected]>", "Dashuai Wu <[email protected]>"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libax = { path = "../../../ulib/libax", features = ["paging", "net"] }
libax = { path = "../../../ulib/libax", features = ["net"] }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion apps/net/httpserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libax = { path = "../../../ulib/libax", features = ["paging", "multitask", "net"] }
libax = { path = "../../../ulib/libax", features = ["multitask", "net"] }
2 changes: 1 addition & 1 deletion apps/net/udpserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ edition = "2021"
authors = ["Dashuai Wu <[email protected]>"]

[dependencies]
libax = { path = "../../../ulib/libax", features = ["paging", "net"] }
libax = { path = "../../../ulib/libax", features = ["net"] }
3 changes: 1 addition & 2 deletions apps/task/parallel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["libax/default"]
sched_rr = ["libax/sched_rr"]
sched_cfs = ["libax/sched_cfs"]

[dependencies]
libax = { path = "../../../ulib/libax", default-features = false, features = ["alloc", "paging", "multitask", "irq"] }
libax = { path = "../../../ulib/libax", features = ["alloc", "paging", "multitask", "irq"] }
3 changes: 1 addition & 2 deletions apps/task/priority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ authors = ["Haoxing Ye <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["libax/default"]
sched_rr = ["libax/sched_rr"]
sched_cfs = ["libax/sched_cfs"]

[dependencies]
libax = { path = "../../../ulib/libax", default-features = false, features = ["alloc", "paging", "multitask"] }
libax = { path = "../../../ulib/libax", features = ["alloc", "paging", "multitask"] }
5 changes: 2 additions & 3 deletions apps/task/sleep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
preempt = ["libax/sched_rr"]
default = ["libax/default"]
sched_rr = ["libax/sched_rr"]

[dependencies]
libax = { path = "../../../ulib/libax", default-features = false, features = ["paging", "multitask", "irq"] }
libax = { path = "../../../ulib/libax", features = ["paging", "multitask", "irq"] }
2 changes: 1 addition & 1 deletion apps/task/sleep/test_cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test_one "SMP=4 LOG=info" "expect_info_smp4_fifo.out"
test_one "SMP=4 LOG=info APP_FEATURES=preempt" "expect_info_smp4_rr.out"
test_one "SMP=4 LOG=info APP_FEATURES=sched_rr" "expect_info_smp4_rr.out"
3 changes: 1 addition & 2 deletions apps/task/yield/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ authors = ["Yuekai Jia <[email protected]>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["libax/default"]
sched_rr = ["libax/sched_rr"]
sched_cfs = ["libax/sched_cfs"]

[dependencies]
libax = { path = "../../../ulib/libax", default-features = false, features = ["paging", "multitask"] }
libax = { path = "../../../ulib/libax", features = ["paging", "multitask"] }
2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* [driver_net](../crates/driver_net): Common traits and types for network device (NIC) drivers.
* [driver_pci](../crates/driver_pci): Structures and functions for PCI bus operations.
* [driver_virtio](../crates/driver_virtio): Wrappers of some devices in the `virtio-drivers` crate, that implement traits in the `driver_common` series crates.
* [flatten_objects](../../crates/flatten_objects): A container that stores numbered objects. Each object can be assigned with a unique ID.
* [flatten_objects](../crates/flatten_objects): A container that stores numbered objects. Each object can be assigned with a unique ID.
* [handler_table](../crates/handler_table): A lock-free table of event handlers. [![Crates.io](https://img.shields.io/crates/v/handler_table)](https://crates.io/crates/handler_table)
* [kernel_guard](../crates/kernel_guard): RAII wrappers to create a critical section with local IRQs or preemption disabled. [![Crates.io](https://img.shields.io/crates/v/kernel_guard)](https://crates.io/crates/kernel_guard)
* [lazy_init](../crates/lazy_init): A wrapper for lazy initialized values without concurrency safety but more efficient.
Expand Down
3 changes: 0 additions & 3 deletions modules/axconfig/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ platform-qemu-virt-aarch64 = []
platform-raspi4-aarch64 = []
default = []

[dependencies]
cfg-if = "1.0"

[build-dependencies]
toml_edit = "0.19"
serde = "1.0"
73 changes: 60 additions & 13 deletions modules/axconfig/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,67 @@ use std::io::{Result, Write};
use std::{convert::AsRef, fs, path::Path};
use toml_edit::{Decor, Document, Item, Table, Value};

const SUPPORTED_PLATFORMS: &[(&str, &str)] = &[
("pc-x86", "x86_64"),
("qemu-virt-riscv", "riscv"),
("qemu-virt-aarch64", "aarch64"),
("raspi4-aarch64", "aarch64"),
("dummy", ""),
];

fn main() {
// generate config_*.rs for all platforms
for fname in fs::read_dir("src/platform").unwrap() {
let fname = fname.unwrap().path();
if fname.extension().unwrap() == "toml" {
let platform = fname.file_stem().unwrap().to_str().unwrap();
gen_config_rs(platform).unwrap();
println!("cargo:rerun-if-changed={}", fname.display());
}
}
let platform = resolve_platform().replace('-', "_");

let out_dir = std::env::var_os("OUT_DIR").unwrap();
let out_path = Path::new(&out_dir).join(format!("config_{platform}.rs"));
gen_config_rs(&platform, &out_path).unwrap();

println!("cargo:rustc-cfg={platform}");
println!("cargo:rerun-if-changed=src/platform/{platform}.toml");
println!("cargo:rerun-if-changed=src/defconfig.toml");
println!("cargo:rerun-if-env-changed=SMP");
}

fn resolve_platform() -> String {
fn has_feature(feature: &str) -> bool {
std::env::var(format!(
"CARGO_FEATURE_{}",
feature.to_uppercase().replace('-', "_")
))
.is_ok()
}

let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let platform = std::env::var("AX_PLATFORM").unwrap_or("dummy".to_string());

// If the `PLATFORM` environment variable is set, use it as the target platform.
if platform != "dummy" && SUPPORTED_PLATFORMS.iter().any(|(p, _)| *p == platform) {
return platform;
}

let mut candidates = vec![];
for (plat, arch) in SUPPORTED_PLATFORMS {
if has_feature(&format!("platform-{plat}")) {
candidates.push((*plat, *arch));
}
}

// If only one platform feature is specified, use it as the target platform.
if candidates.len() == 1 {
return candidates[0].0.into();
}

// Otherwise, the platform feature should be matched with the target arch.
for (plat, arch) in candidates {
if target_arch.starts_with(arch) {
return plat.into();
}
}

// If none of the above conditions is met, use the dummy platform.
"dummy".into()
}

fn add_config(config: &mut Table, key: &str, item: Item, comments: Option<&str>) {
config.insert(key, item);
if let Some(comm) = comments {
Expand Down Expand Up @@ -56,7 +103,7 @@ fn is_num(s: &str) -> bool {
}
}

fn gen_config_rs(platform: &str) -> Result<()> {
fn gen_config_rs(platform: &str, out_path: &Path) -> Result<()> {
// Load TOML config file
let mut config = Table::new();
parse_config_toml(&mut config, "src/defconfig.toml").unwrap();
Expand All @@ -75,9 +122,9 @@ fn gen_config_rs(platform: &str) -> Result<()> {
let mut output = Vec::new();
writeln!(
output,
"//! Platform constants and parameters for {platform}."
"// Platform constants and parameters for {platform}."
)?;
writeln!(output, "//! Generated by build.rs, DO NOT edit!\n")?;
writeln!(output, "// Generated by build.rs, DO NOT edit!\n")?;

for (key, item) in config.iter() {
let var_name = key.to_uppercase().replace('-', "_");
Expand Down Expand Up @@ -122,7 +169,7 @@ fn gen_config_rs(platform: &str) -> Result<()> {
}
}

let out_path = format!("src/config_{}.rs", platform.replace('-', "_"));
println!("Generating config file: {}", out_path.display());
fs::write(out_path, output)?;

Ok(())
Expand Down
Loading

0 comments on commit 6852d92

Please sign in to comment.