Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Unreleased changes ([Source](https://github.com/neotron-compute/neotron-os/tree/develop) | [Changes](https://github.com/neotron-compute/neotron-os/compare/v0.8.1...develop))

* None
* Add `GFX:` device and some ioctls for mode changing, plotting pixels and drawing lines
* Add `nbuild` build system
* Add a ROMFS containing `neoplay`, `snake`, `vidtest`, `logo` and `desktop` utilities / demos

## v0.8.1 - 2024-05-17 ([Source](https://github.com/neotron-compute/neotron-os/tree/v0.8.1) | [Release](https://github.com/neotron-compute/neotron-os/releases/tag/v0.8.1))

Expand Down
25 changes: 23 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude = [
]

[workspace.dependencies]
neotron-sdk = "0.2.0"
neotron-sdk = { git = "https://github.com/neotron-compute/neotron-sdk.git", branch = "add-gfx-ioctl-defines" }

[profile.release]
lto = true
Expand Down
55 changes: 44 additions & 11 deletions nbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,7 @@ where
{
let path = path.as_ref();
println!("Making binary of: {}", path.display());
let output = std::process::Command::new("rustc")
.arg("--print")
.arg("target-libdir")
.output()
.expect("Failed to run rustc --print target-libdir");
let sysroot = String::from_utf8(output.stdout).expect("sysroot path isn't UTF-8");
let sysroot: std::path::PathBuf = sysroot.trim().into();
let mut objcopy = sysroot.clone();
objcopy.pop();
objcopy.push("bin");
objcopy.push("llvm-objcopy");
let objcopy = tool_path("llvm-objcopy");
let mut command_line = std::process::Command::new(objcopy);
command_line.args(["-O", "binary"]);
command_line.arg(path);
Expand All @@ -153,4 +143,47 @@ where
}
}

/// Make a binary version of an ELF file
pub fn strip_elf<P1, P2>(input_path: P1, output_path: P2) -> Result<(), ProcessError>
where
P1: AsRef<std::path::Path>,
P2: AsRef<std::path::Path>,
{
let input_path = input_path.as_ref();
let output_path = output_path.as_ref();

println!(
"Stripping {} as {}",
input_path.display(),
output_path.display()
);
let strip = tool_path("llvm-strip");
let mut command_line = std::process::Command::new(strip);
command_line.arg(input_path);
command_line.arg("-o");
command_line.arg(output_path);
println!("Running: {:?}", command_line);
let output = command_line.output().map_err(ProcessError::SpawnError)?;
if output.status.success() {
Ok(())
} else {
Err(ProcessError::RunError(output.status))
}
}

/// Get the path where `llvm-objcopy` and friends live.
pub fn tool_path(tool: &str) -> std::path::PathBuf {
let output = std::process::Command::new("rustc")
.arg("--print")
.arg("target-libdir")
.output()
.expect("Failed to run rustc --print target-libdir");
let sysroot = String::from_utf8(output.stdout).expect("sysroot path isn't UTF-8");
let mut result: std::path::PathBuf = sysroot.trim().into();
result.pop();
result.push("bin");
result.push(tool);
result
}

// End of file
30 changes: 28 additions & 2 deletions nbuild/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,27 @@ fn packages() -> Vec<nbuild::Package> {
testable: nbuild::Testable::All,
},
// *** utilities ***
nbuild::Package {
name: "desktop",
path: std::path::Path::new("./utilities/desktop/Cargo.toml"),
output_template: Some("./target/{target}/{profile}/desktop"),
kind: nbuild::PackageKind::Utility,
testable: nbuild::Testable::No,
},
nbuild::Package {
name: "flames",
path: std::path::Path::new("./utilities/flames/Cargo.toml"),
output_template: Some("./target/{target}/{profile}/flames"),
kind: nbuild::PackageKind::Utility,
testable: nbuild::Testable::No,
},
nbuild::Package {
name: "logo",
path: std::path::Path::new("./utilities/logo/Cargo.toml"),
output_template: Some("./target/{target}/{profile}/logo"),
kind: nbuild::PackageKind::Utility,
testable: nbuild::Testable::No,
},
nbuild::Package {
name: "neoplay",
path: std::path::Path::new("./utilities/neoplay/Cargo.toml"),
Expand All @@ -72,6 +86,13 @@ fn packages() -> Vec<nbuild::Package> {
kind: nbuild::PackageKind::Utility,
testable: nbuild::Testable::No,
},
nbuild::Package {
name: "vidtest",
path: std::path::Path::new("./utilities/vidtest/Cargo.toml"),
output_template: Some("./target/{target}/{profile}/vidtest"),
kind: nbuild::PackageKind::Utility,
testable: nbuild::Testable::No,
},
// *** OS ***
nbuild::Package {
name: "Neotron OS",
Expand Down Expand Up @@ -133,10 +154,15 @@ fn binary(packages: &[nbuild::Package], start_address: &str, target: &str) {
let package_output = package
.output(target, "release")
.expect("utilties should have an output");
let contents = match std::fs::read(&package_output) {
let stripped = package_output.clone() + ".stripped";
if let Err(e) = nbuild::strip_elf(&package_output, &stripped) {
eprintln!("Reading of {} failed: {}", stripped, e);
continue;
};
let contents = match std::fs::read(&stripped) {
Ok(contents) => contents,
Err(e) => {
eprintln!("Reading of {} failed: {}", package_output, e);
eprintln!("Reading of {} failed: {}", stripped, e);
continue;
}
};
Expand Down
1 change: 0 additions & 1 deletion neotron-os/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub static OS_MENU: menu::Menu<Ctx> = menu::Menu {
&fs::ROM_ITEM,
&screen::CLS_ITEM,
&screen::MODE_ITEM,
&screen::GFX_ITEM,
&input::KBTEST_ITEM,
&hardware::SHUTDOWN_ITEM,
&sound::MIXER_ITEM,
Expand Down
Loading
Loading