mach: improvements to build system (for wasm) #313

Merged
iddev5 merged 10 commits from ay-build-improve into main 2022-05-28 04:08:10 +00:00
iddev5 commented 2022-05-27 14:37:20 +00:00 (Migrated from github.com)
  • Made general improvements to build system on how to add dependencies, removed redundant dependencies internally
  • In case of wasm, install the necessary js and html files in prefix/www. The main HTML file is generated with an application placed in tools/html-generator.zig. This application would prove to be more useful in future when we have more modules inside the engine (as all js files need to be listen inside this HTML file)
  • In case of wasm, serve the application using a http server placed in tools/http-server.zig. The address and port can be customized using the environment variables MACH_ADDRESS and MACH_PORT respectively.
  • Finally in case of wasm, launch a web browser with the link where the application is being served.

The serve + launch steps can be customized with options in future, but right now it's kept as simple as possible.

This PR enables use of run step for wasm application. Now you can freely do zig build run-example-* -Dtarget=wasm32-freestanding-none and everything will just work (regarding the build system)

Further, now generate separate html and wasm files in install:

# ls zig-out/www
example-triangle.html  example-triangle.wasm  example-two-cubes.html  example-two-cubes.wasm  main.js ...

With this PR we achieve feature parity for general support of wasm development.

Fixes hexops/mach#18


  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
- Made general improvements to build system on how to add dependencies, removed redundant dependencies internally - In case of wasm, install the necessary js and html files in prefix/www. The main HTML file is generated with an application placed in tools/html-generator.zig. This application would prove to be more useful in future when we have more modules inside the engine (as all js files need to be listen inside this HTML file) - In case of wasm, serve the application using a http server placed in tools/http-server.zig. The address and port can be customized using the environment variables ``MACH_ADDRESS`` and ``MACH_PORT`` respectively. - Finally in case of wasm, launch a web browser with the link where the application is being served. The serve + launch steps can be customized with options in future, but right now it's kept as simple as possible. This PR enables use of run step for wasm application. Now you can freely do ``zig build run-example-* -Dtarget=wasm32-freestanding-none`` and everything will just work (regarding the build system) Further, now generate separate html and wasm files in install: ``` # ls zig-out/www example-triangle.html example-triangle.wasm example-two-cubes.html example-two-cubes.wasm main.js ... ``` With this PR we achieve feature parity for general support of wasm development. Fixes hexops/mach#18 --- - [x] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
GithubPrankster commented 2022-05-27 16:02:53 +00:00 (Migrated from github.com)

Successfully works in Windows+Chromium and Windows+Firefox. Firefox may require serving html files as index.html (issue encountered in Librewolf fork)

Successfully works in Windows+Chromium and Windows+Firefox. Firefox may require serving html files as `index.html` (issue encountered in Librewolf fork)
emidoots commented 2022-05-28 03:59:07 +00:00 (Migrated from github.com)

I made a small change to ensure the apple_pie submodule is cloned automatically

I made a small change to ensure the apple_pie submodule is cloned automatically
emidoots (Migrated from github.com) approved these changes 2022-05-28 04:05:36 +00:00
emidoots commented 2022-05-28 04:07:08 +00:00 (Migrated from github.com)

Damn, this is so cool @iddev5!

I can also confirm this works on macOS+Firefox and macOS+Safari

Damn, this is so cool @iddev5! I can also confirm this works on macOS+Firefox and macOS+Safari
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach!313
No description provided.