initial workspace setup

This commit is contained in:
antifallobst 2023-03-16 23:26:54 +01:00
parent c8e1170975
commit 61dd08bf96
4 changed files with 66 additions and 0 deletions

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "nemu"
version = "0.1.0"
edition = "2021"
authors = ["Antifallobst <antifallobst@systemausfall.org>", "Eric-Paul Ickhorn <atnx@protonmail.com"]
description = "A small web emulator for simple architectures"
license = "MIT"
repository = "https://git.nerdcult.net/nerdcult/nerdemu"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2"

24
build.sh Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/bash
nemu_build() {
echo " --> Building NerdEMU"
wasm-pack build --target web
}
nemu_run(){
echo " --> Starting HTTP server"
python3 -m http.server
}
echo "!=====[ NerdEMU build script ]=====!"
nemu_build
case $1 in
"test")
nemu_run
;;
esac
echo "!=====[ Finished ]=====!"

15
index.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>test</title>
</head>
<body>
<script type="module">
import init, { greet } from "./pkg/nemu.js";
init().then(() => {
greet("NerdEMU");
});
</script>
</body>
</html>

11
src/lib.rs Normal file
View File

@ -0,0 +1,11 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
pub fn alert(s: &str);
}
#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}