Skip to content

Commit

Permalink
try to repair emscripten build
Browse files Browse the repository at this point in the history
  • Loading branch information
selassje committed Oct 13, 2023
1 parent 8e17546 commit 174902a
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 21 deletions.
16 changes: 5 additions & 11 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ rustflags = [
"-C", "link-arg=-sMAX_WEBGL_VERSION=2",
"-C", "link-arg=-sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0",
"-C", "link-arg=-sLLD_REPORT_UNDEFINED",
]

[target.asmjs-unknown-emscripten]
rustflags = [
"-C", "link-arg=-sUSE_SDL=2",
"-C", "link-arg=-sUSE_SDL_IMAGE=2",
"-C", "link-arg=-sSDL2_IMAGE_FORMATS=['png']",
"-C", "link-arg=-sMIN_WEBGL_VERSION=2",
"-C", "link-arg=-sMAX_WEBGL_VERSION=2",
"-C", "link-arg=-sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0",
"-C", "link-arg=-sLLD_REPORT_UNDEFINED",
"-C", "link-arg=-sIMPORTED_MEMORY",
"-C", "link-arg=-sSTACK_SIZE=4194304",
"-C", "link-arg=-sMAXIMUM_MEMORY=4gb",
"-C", "link-arg=-sINITIAL_MEMORY=2gb",

]
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Cargo.lock
!/tests/*/*.expected.bmp
*.log
*.zip
/.vscode
*.nesrs
.cargo-ok
.cargo-ok
settings.json
nes-rs.js
nes_rs.wasm
119 changes: 119 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",

"tasks": [
{
"label": "build_rel",
"type": "shell",
"command": "cargo build --release",
"problemMatcher": "$rustc",
"group": "build"
},
{
"label": "run_rel",
"type": "shell",
"command": "cargo run --release",
"group": {
"kind": "test",
"isDefault": false
},
"dependsOn": [
"build_rel"
],
"problemMatcher": []
},
{
"label": "test",
"type": "shell",
"command": "cargo test --release",
"dependsOn": [
"build_rel"
],
"group": "test",
"problemMatcher": []
},
{
"label": "build_dev",
"type": "shell",
"command": "cargo build",
"group": {
"kind": "build"
}
},
{
"label": "run_dev",
"type": "shell",
"command": "cargo run",
"group": {
"kind": "test",
"isDefault": false
},
"dependsOn": [
"build_dev"
],
"problemMatcher": []
},
{
"label": "build_rel_emscripten",
"type": "shell",
"command": "cargo build --release --target=wasm32-unknown-emscripten",
"group": {
"kind": "build"
}
},
{
"label": "build_dev_emscripten",
"type": "shell",
"command": "cargo build --target=wasm32-unknown-emscripten",
"group": {
"kind": "build"
}
},
{
"label": "copy_emscripten_artefacts_release",
"hide": true,
"type": "shell",
"command": "cp ${workspaceFolder}/target/wasm32-unknown-emscripten/release/nes_rs.wasm ${workspaceFolder}/static; cp ${workspaceFolder}/target/wasm32-unknown-emscripten/release/nes-rs.js ${workspaceFolder}/static ",
"group": {
"kind": "build"
}
},
{
"label": "copy_emscripten_artefacts_dev",
"hide": true,
"type": "shell",
"command": "cp ${workspaceFolder}/target/wasm32-unknown-emscripten/debug/nes_rs.wasm ${workspaceFolder}/static; cp ${workspaceFolder}/target/wasm32-unknown-emscripten/debug/nes-rs.js ${workspaceFolder}/static ",
"group": {
"kind": "build"
}
},
{
"label": "deploy",
"hide": false,
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"build_rel_emscripten",
"copy_emscripten_artefacts_release"
],
"group": {
"kind": "build"
}
},
{
"label": "deploy_dev",
"hide": false,
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"build_dev_emscripten",
"copy_emscripten_artefacts_dev"
],
"group": {
"kind": "build"
}
}
]
}
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ path = "tests/blargg_ppu_tests.rs"
[[test]]
name = "apu_tests"
path = "tests/apu_tests.rs"
[[test]]
[[test]]
name = "sprite_0_hit_tests"
path = "tests/sprite_0_hit_tests.rs"
[[test]]
Expand All @@ -33,7 +33,7 @@ name = "serialization"
path = "tests/serialization.rs"

[profile.release]
debug = false
debug = true
lto = true
opt-level = 3
panic = "abort"
Expand Down
12 changes: 6 additions & 6 deletions static/script.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function upload_nes_file_btn_click() {
document.getElementById("upload_nes_file").click()
document.querySelector("#upload_nes_file").click()
}
function upload_save_file_btn_click() {
document.getElementById("upload_save_file").click()
document.querySelector("#upload_save_file").click()
}

function upload_file(file, dir) {
Expand Down Expand Up @@ -40,10 +40,10 @@ function refreshDownloadList() {
return files;
}
var save_files = getFiles("saves");
var list = document.getElementById("download_save_files");
var list = document.querySelector("#download_save_files");
list.style.display = "none";
if (save_files.length > 0) {
var ul = document.getElementById("download_list");
var ul = document.querySelector("#download_list");
ul.innerHTML = "";
save_files.forEach(element => {
var entry = document.createElement("li");
Expand All @@ -68,7 +68,7 @@ FS.rmdir("tmp");
FS.mkdir("games");
FS.mkdir("saves");

document.getElementById("upload_nes_file").addEventListener("change", upload_nes_file, false);
document.getElementById("upload_save_file").addEventListener("change", upload_save_file, false);
document.querySelector("#upload_nes_file").addEventListener("change", upload_nes_file, false);
document.querySelector("#upload_save_file").addEventListener("change", upload_save_file, false);

alignElements();

0 comments on commit 174902a

Please sign in to comment.