Updated to be IAW new build process

master
DavidOConnor 6 years ago
parent 9e1b35bbef
commit 5a035b37c2

5
.gitignore vendored

@ -5,8 +5,5 @@ Cargo.lock
# Pycharm
/.idea
pkg/*.wasm
pkg/*.d.ts
pkg/*.ts
pkg/*.js
pkg/*
wasm-pack.log

@ -0,0 +1,50 @@
[env]
# all workspace members can use this Makefile
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
# ---- BUILD & CREATE WASMS ----
[tasks.build]
description = "Build only Seed without examples"
workspace = false
command = "cargo"
args = ["build"]
[tasks.build_release]
description = "Build only Seed without examples"
workspace = false
command = "cargo"
args = ["build", "--release"]
[tasks.create_wasms]
description = "Build examples with wasm-pack"
workspace = false
command = "cargo"
args = ["make", "create_wasm"]
[tasks.all]
description = "Build all - Seed + examples and create wasms"
workspace = false
dependencies = ["build", "create_wasms"]
[tasks.all_release]
description = "Build all - Seed + examples and create wasms, with the --release flag"
workspace = false
dependencies = ["build_release", "build_examples", "create_wasms"]
[tasks.serve]
description = "Start server for given example"
install_crate = { crate_name = "https", binary = "http", test_arg = "--help" }
workspace = false
command = "http"
args = []
# ---- PRIVATE TASKS - run only inside another task ----
# private atribute is ignored (bug?)
[tasks.create_wasm]
description = "Build example with wasm-pack"
# private = true
install_crate = "wasm-pack"
command = "wasm-pack"
args = ["build", "--target", "no-modules", "--out-name", "package"]

@ -3,29 +3,16 @@
**To get started:**
- Clone this repo
- If you don't have Rust and wasm-bindgen installed, [Download it](https://www.rust-lang.org/tools/install), and run the following commands:
`rustup update`
`rustup target add wasm32-unknown-unknown`
`cargo install wasm-bindgen-cli`
If you run into errors while installing `wasm-bindgen-cli`, you may need to install a C++
build chain. On linux, run `sudo apt install build-essential`. On Windows, download and install
[Visual Studio 2017](https://visualstudio.microsoft.com/downloads/); when asked in the installer,
include the C++ workload.
- Run `build.sh` or `build.ps1`, then start a dev server that supports WASM.
For example, with [Python](https://www.python.org/downloads/) installed, run `python serve.py`.
(Linux users may need to run `python3 serve.py`.)
If you run into permission errors on `build.sh`, try this command
to allow executing the file:`chmod +x build.sh`. If you run into persmission errors on `build.ps1`, open Powershell as an administrator, and enter this command: `Set-ExecutionPolicy RemoteSigned`.
Once you rename the crate in `Cargo.toml` (The `name` field under `[Package]`), make the
following change:
`cargo install cargo-make`
- Replace `appname` with your new name in either `build.sh`, or `build.ps1`, depending on your
operating system.
Run `cargo make all` in a terminal to build the app, and `cargo make serve` to start a dev server
on `127.0.0.0:8000`.

@ -1,5 +0,0 @@
cargo build --target wasm32-unknown-unknown
wasm-bindgen target/wasm32-unknown-unknown/debug/appname.wasm --no-modules --out-dir ./pkg --out-name package
#cargo build --target wasm32-unknown-unknown --release
#wasm-bindgen target/wasm32-unknown-unknown/release/appname.wasm --no-modules --out-dir ./pkg --out-name package

@ -1,6 +0,0 @@
#!/usr/bin/env bash
cargo build --target wasm32-unknown-unknown
wasm-bindgen target/wasm32-unknown-unknown/debug/appname.wasm --no-modules --out-dir ./pkg --out-name package
#cargo build --target wasm32-unknown-unknown --release
#wasm-bindgen target/wasm32-unknown-unknown/release/appname.wasm --no-modules --out-dir ./pkg --out-name package

@ -1,41 +0,0 @@
#!/usr/bin/env python3
import http.server
import os
import socketserver
import urllib
import sys
PORT = 8000
class Handler(http.server.SimpleHTTPRequestHandler):
# Allow SPA routing by redirecting subpaths.
def do_GET(self):
urlparts = urllib.parse.urlparse(self.path)
request_file_path = urlparts.path.strip('/')
if not os.path.exists(request_file_path):
self.path = '/'
return http.server.SimpleHTTPRequestHandler.do_GET(self)
handler = Handler
# Add support for the WASM mime type.
handler.extensions_map.update({
'.wasm': 'application/wasm',
})
socketserver.TCPServer.allow_reuse_address = True
print("Serving at port", PORT)
print("View at: http://localhost:{}/".format(PORT))
# The context manager protocol is support only since python 3.6 and higher.
if (3 <= sys.version_info[0]) and (6 <= sys.version_info[1]):
with socketserver.TCPServer(("", PORT), handler) as httpd:
httpd.allow_reuse_address = True
httpd.serve_forever()
else:
httpd = socketserver.TCPServer(("", PORT), handler)
httpd.allow_reuse_address = True
httpd.serve_forever()
httpd.serve_close()
Loading…
Cancel
Save