{"id":16101456,"url":"https://github.com/mendhak/wasm-tutorials-learn","last_synced_at":"2025-04-06T00:27:38.540Z","repository":{"id":214056190,"uuid":"735161017","full_name":"mendhak/wasm-tutorials-learn","owner":"mendhak","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-26T18:41:28.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T06:38:44.576Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"WebAssembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mendhak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-23T22:06:45.000Z","updated_at":"2023-12-25T12:59:54.000Z","dependencies_parsed_at":"2024-10-31T15:51:12.465Z","dependency_job_id":null,"html_url":"https://github.com/mendhak/wasm-tutorials-learn","commit_stats":null,"previous_names":["mendhak/wasm-tutorials-learn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fwasm-tutorials-learn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fwasm-tutorials-learn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fwasm-tutorials-learn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fwasm-tutorials-learn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mendhak","download_url":"https://codeload.github.com/mendhak/wasm-tutorials-learn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419640,"owners_count":20936009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T18:49:59.439Z","updated_at":"2025-04-06T00:27:38.517Z","avatar_url":"https://github.com/mendhak.png","language":"WebAssembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n## C\n\nFollowing the [WASI tutorial](https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-tutorial.md), with some modifications. \n\n\nBasic C code, compiled to wasm with clang, run with wasmtime. \n\nGet the clang compiler. \n\n    wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-21/wasi-sdk-21.0-linux.tar.gz\n    tar xf wasi-sdk-21.0-linux.tar.gz\n    ./wasi-sdk-21.0/bin/clang demo.c -o demo.wasm\n\nBuild the .wasm file. \n\n    ./wasi-sdk-21.0/bin/clang demo.c -o demo.wasm\n\nGet wasmtime.\n\n    wget https://github.com/bytecodealliance/wasmtime/releases/download/v16.0.0/wasmtime-v16.0.0-x86_64-linux.tar.xz\n    tar xf wasmtime-v16.0.0-x86_64-linux.tar.xz\n\n\nRun the file which copies a file from one place to another. \n\n    echo \"Hello world\" \u003e hello.txt\n    ./wasmtime-v16.0.0-x86_64-linux/wasmtime --dir=. demo.wasm ./hello.txt output.txt\n    cat output.txt\n\n\n## Web Assembly Text\n\nFollowing [this MDN tutorial](https://developer.mozilla.org/en-US/docs/WebAssembly/Text_format_to_wasm).\n\nDirectly execute the text. \n\n    ./wasmtime-v16.0.0-x86_64-linux/wasmtime simple.wat\n\nUse `wabt` to convert the web assembly text to binary. \n\n    wget https://github.com/WebAssembly/wabt/releases/download/1.0.34/wabt-1.0.34-ubuntu.tar.gz\n    tar xf wabt-1.0.34-ubuntu.tar.gz\n    ./wabt-1.0.34/bin/wat2wasm simple.wat\n    ./wasmtime-v16.0.0-x86_64-linux/wasmtime simple.wasm\n\nView it in an HTML file\n\n    python3 -m http.server\n    firefox http://localhost:8000/simple.html\n\n\n## Using emscripten\n\n\nFollowing [this MDN tutorial](https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm).\n\nCompile to a packaged HTML, using the emscripten Docker image\n\n    docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk emcc hello.c -o hello.html \n\nRun the resulting HTML file\n    \n    python3 -m http.server\n    firefox http://localhost:8000/output/hello.html\n\n\nCompile to a packaged Node JS file, using the emscripten Docker image\n\n    docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk emcc hello.c -o output/hello2.js\n    node output/hello2.js\n\nCompile hello3 to a template HTML file using the emscripten docker image \n\n    docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk emcc -o output/hello3.html hello3.c --shell-file shell_minimal.html -s NO_EXIT_RUNTIME=1 -s \"EXPORTED_RUNTIME_METHODS=['ccall']\"\n    python3 -m http.server\n    firefox http://localhost:8000/output/hello3.html\n\n\n## Todo - Docker = WASM\n\nhttps://docs.docker.com/engine/alternative-runtimes/#wasmtime\n\nRunning WASM in Docker without Docker Desktop.  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmendhak%2Fwasm-tutorials-learn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmendhak%2Fwasm-tutorials-learn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmendhak%2Fwasm-tutorials-learn/lists"}