Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalium committed Sep 6, 2024
1 parent 33b0da9 commit 6717d1f
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ make run
make internal_run_app_test INIT="app_name_here"
```

## Build an app for WasabiOS

For example, to create a "hello2" app, run following commands outside of WasabiOS checkout:

```
cargo new hello2
cd hello2
cargo add noli --git https://github.com/hikalium/wasabi.git
rustup target add x86_64-unknown-none
wget https://raw.githubusercontent.com/hikalium/wasabi/main/rust-toolchain.toml
```

## Debugging tips

```
Expand Down
1 change: 1 addition & 0 deletions app/template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
7 changes: 7 additions & 0 deletions app/template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "hello2"
version = "0.1.0"
edition = "2021"

[dependencies]
noli = { git = "https://github.com/hikalium/wasabi.git", version = "0.1.0" }
50 changes: 50 additions & 0 deletions app/template/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
TARGET=x86_64-unknown-none
NAME=$(shell echo "${PWD##*/}")
ROOT=./generated
RUSTFLAGS=\
-C link-args=-e \
-C link-args=entry \
-C link-args=-z \
-C link-args=execstack
CARGO=RUSTFLAGS='$(RUSTFLAGS)' cargo
BIN_PATH_DEBUG=$(shell cargo metadata --format-version 1 | jq -r .target_directory)/debug/$(NAME)
APP_BUILD_ARG=-v --target x86_64-unknown-none --release

.PHONY : build
build :
$(CARGO) build $(APP_BUILD_ARG)

.PHONY : test
test :
cargo build
cargo test

.PHONY : clippy
clippy :
rustup target add $(TARGET)
cargo clippy --all-features --target=$(TARGET) -- -D warnings
cargo clippy --all-features -- -D warnings

.PHONY : objdump
objdump :
cargo install cargo-binutils
rustup component add llvm-tools-preview
$(CARGO) objdump -- -d

.PHONY : nm
nm :
cargo install cargo-binutils
rustup component add llvm-tools-preview
$(CARGO) nm

.PHONY : readelf
readelf : build
readelf -l $(BIN_PATH_DEBUG)

.PHONY : hexdump
hexdump : build
hexdump -C $(BIN_PATH_DEBUG)

.PHONY : run
run :
make -C ../../ run
6 changes: 6 additions & 0 deletions app/template/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[toolchain]
channel = "nightly-2024-01-01"
components = [ "rustfmt"]
# https://doc.rust-lang.org/nightly/rustc/platform-support.html
targets = [ "x86_64-unknown-linux-gnu"]
profile = "default"
8 changes: 8 additions & 0 deletions app/template/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![no_std]
#![cfg_attr(not(target_os = "linux"), no_main)]
use noli::prelude::*;
entry_point!(main);

fn main() {
println!("Hello, world!");
}

0 comments on commit 6717d1f

Please sign in to comment.