summaryrefslogtreecommitdiff
path: root/WebInterface
diff options
context:
space:
mode:
authornatrixaeria <janng@gmx.de>2019-05-25 02:06:41 +0200
committernatrixaeria <janng@gmx.de>2019-05-25 02:06:41 +0200
commit90be5f8d63e77ee51256270dec018e2c7448e115 (patch)
tree949159bcdc5cdff23a73f5f03172a17897a87e7c /WebInterface
parent233106ee4fc302579af0224611e55be5b1479f51 (diff)
Resetup webassembly on the cool way
Diffstat (limited to 'WebInterface')
-rw-r--r--WebInterface/wasm/asm-paint/Cargo.toml6
-rwxr-xr-xWebInterface/wasm/asm-paint/build.sh3
-rwxr-xr-xWebInterface/wasm/asm-paint/deploy4
-rwxr-xr-x[-rw-r--r--]WebInterface/wasm/asm-paint/deploy.py6
-rw-r--r--WebInterface/wasm/asm-paint/index.html3
-rw-r--r--WebInterface/wasm/asm-paint/loader.js3
-rw-r--r--WebInterface/wasm/asm-paint/src/lib.rs16
-rw-r--r--WebInterface/wasm/asm-paint/src/main.rs14
8 files changed, 34 insertions, 21 deletions
diff --git a/WebInterface/wasm/asm-paint/Cargo.toml b/WebInterface/wasm/asm-paint/Cargo.toml
index 8a4cc92..c0a7c68 100644
--- a/WebInterface/wasm/asm-paint/Cargo.toml
+++ b/WebInterface/wasm/asm-paint/Cargo.toml
@@ -1,7 +1,11 @@
[package]
-name = "asm-paint"
+name = "asm-paint-rs"
version = "0.1.0"
authors = ["Dennis Kobert <d-kobert@web.de>"]
edition = "2018"
+[lib]
+crate-type = ["cdylib"]
+
[dependencies]
+wasm-bindgen = "0.2"
diff --git a/WebInterface/wasm/asm-paint/build.sh b/WebInterface/wasm/asm-paint/build.sh
index 457d1d8..61c1997 100755
--- a/WebInterface/wasm/asm-paint/build.sh
+++ b/WebInterface/wasm/asm-paint/build.sh
@@ -1,2 +1,3 @@
#!/bin/sh
-cargo build --target=wasm32-unknown-emscripten --release
+
+wasm-pack build --target web
diff --git a/WebInterface/wasm/asm-paint/deploy b/WebInterface/wasm/asm-paint/deploy
new file mode 100755
index 0000000..9f7f823
--- /dev/null
+++ b/WebInterface/wasm/asm-paint/deploy
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+./build.sh
+./deploy.py
diff --git a/WebInterface/wasm/asm-paint/deploy.py b/WebInterface/wasm/asm-paint/deploy.py
index fce7a02..b64c322 100644..100755
--- a/WebInterface/wasm/asm-paint/deploy.py
+++ b/WebInterface/wasm/asm-paint/deploy.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
from socket import (socket, AF_INET, SOCK_STREAM, IPPROTO_TCP,
SOL_SOCKET, SO_REUSEADDR)
from threading import Thread
@@ -10,8 +12,8 @@ HTML_MIME = 'text/html'
REQUESTS = {
'/': ('index.html', HTML_MIME),
'/loader.js': ('loader.js', JS_MIME),
- '/asm-paint.js': ('target/wasm32-unknown-emscripten/release/asm-paint.js', JS_MIME),
- '/asm_paint.wasm': ('target/wasm32-unknown-emscripten/release/asm_paint.wasm', WASM_MIME),
+ '/asm_paint_rs.js': ('pkg/asm_paint_rs.js', JS_MIME),
+ '/asm_paint_rs_bg.wasm': ('pkg/asm_paint_rs_bg.wasm', WASM_MIME),
}
PAGE_404 = '''<!doctype html><html><head></head>
diff --git a/WebInterface/wasm/asm-paint/index.html b/WebInterface/wasm/asm-paint/index.html
index c47d89d..46be213 100644
--- a/WebInterface/wasm/asm-paint/index.html
+++ b/WebInterface/wasm/asm-paint/index.html
@@ -3,8 +3,7 @@
<head>
<meta charset="UTF-8">
<title> Scribblio </title>
- <script src='asm-paint.js'></script>
- <script src='loader.js'></script>
+ <script src='loader.js' type='module'></script>
</head>
<body>
</body>
diff --git a/WebInterface/wasm/asm-paint/loader.js b/WebInterface/wasm/asm-paint/loader.js
index 3e25291..f1d15ef 100644
--- a/WebInterface/wasm/asm-paint/loader.js
+++ b/WebInterface/wasm/asm-paint/loader.js
@@ -1 +1,2 @@
-//Module.
+import {default as init} from './asm_paint_rs.js'
+init('asm_paint_rs_bg.wasm');
diff --git a/WebInterface/wasm/asm-paint/src/lib.rs b/WebInterface/wasm/asm-paint/src/lib.rs
new file mode 100644
index 0000000..52ddc8f
--- /dev/null
+++ b/WebInterface/wasm/asm-paint/src/lib.rs
@@ -0,0 +1,16 @@
+use wasm_bindgen::prelude::*;
+
+macro_rules! console_log {
+ ($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
+}
+
+#[wasm_bindgen]
+extern "C" {
+ #[wasm_bindgen(js_namespace = console)]
+ fn log(s: &str);
+}
+
+#[wasm_bindgen(start)]
+pub fn entry() {
+ console_log!("hello {} wasm", 42);
+}
diff --git a/WebInterface/wasm/asm-paint/src/main.rs b/WebInterface/wasm/asm-paint/src/main.rs
deleted file mode 100644
index f8949ee..0000000
--- a/WebInterface/wasm/asm-paint/src/main.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use std::os::raw::c_int;
-
-#[no_mangle]
-pub extern fn run_infinite() {
- std::thread::spawn(move || {
- loop {
- println!("iterating infititely");
- }
- });
-}
-
-fn main() {
- println!("haha from wasm lol");
-}