Skip to content

Add support for WebAssembly builds of some 3p-packages#284

Merged
nick-l-o3de merged 14 commits intoo3de:mainfrom
guillaume-haerinck:emscripten
Mar 10, 2026
Merged

Add support for WebAssembly builds of some 3p-packages#284
nick-l-o3de merged 14 commits intoo3de:mainfrom
guillaume-haerinck:emscripten

Conversation

@guillaume-haerinck
Copy link
Copy Markdown
Contributor

@guillaume-haerinck guillaume-haerinck commented Jul 1, 2025

What does this PR do?

Allow to build several 3p package to the WebAssembly target thanks to emscripten compiler

Related to :

What remains :

  • Emscripten should likely be a 3p-package itself so that users can target WebAssembly without the need of installing emscripten by themself
  • Need to have all 3p required by the engine/game (and not editor) built with emscripten so that we can build the engine/game itself to WebAssembly

How was this PR tested?

Local build on windows.

Setup required for now:

Steps:

  • Clone this repository and 3p-package-script next to each other
  • From the 3p package scripts folder, open a terminal and run python .\build_package.py --search_path ..\..\3p-package-source Lua-5.4.4-rev1-emscripten
  • Build exit successfully
  • Unzip the created package and check that it is correct
  • (near future) Link package against o3de and build tests in webassembly (just need to create a wasm folder in the cloned repo and run emcmake cmake .. -DLY_3RDPARTY_PATH=YOUR_PATH then build the test targets)


cmake_generate_cmd = [self.cmake_command,
# emcmake self configure the proper environment when targeting WebAssembly
cmake_command = self.cmake_command
Copy link
Copy Markdown
Contributor Author

@guillaume-haerinck guillaume-haerinck Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure about this approach, we might want to setup the same environment as emcmake is doing in the configure json file. Yet this is the easiest and lowest maintenance path so I let the build system pro decide on what is best

@guillaume-haerinck guillaume-haerinck added the enhancement New feature or request label Jul 1, 2025
@guillaume-haerinck guillaume-haerinck marked this pull request as draft July 1, 2025 19:03
@guillaume-haerinck guillaume-haerinck marked this pull request as ready for review July 3, 2025 06:39
@guillaume-haerinck guillaume-haerinck changed the title [WIP] Add support for WebAssembly builds of 3p-packages Add support for WebAssembly builds of some 3p-packages Jul 3, 2025
@guillaume-haerinck guillaume-haerinck requested review from a team July 4, 2025 16:17
@@ -1 +1,2 @@
package-system/Crashpad/add_o3de_handler_extensions.patch eol=lf
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.gitattributes files can be in any folder, why not put this in a .gitattributes file in the same folder as the file it affects?

"custom_additional_compile_definitions":[
"GTEST_HAS_TR1_TUPLE=0",
"GTEST_OS_SUPPORTS_DEATH_TEST=0"
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm under the impression that we now build googletest as an inline fetchcontent build, this package is unused. see Code\Framework\AzTest\3rdParty\Findgoogletest.cmake

"googlebenchmark-1.7.0-rev1-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Windows --package-root ../../package-system --clean",
"googletest-1.8.1-rev4-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Android --package-root ../../package-system --clean",
"googletest-1.8.1-rev4-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Windows --package-root ../../package-system --clean",
"googletest-1.8.1-rev4-emscripten": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Emscripten --package-root ../../package-system --clean",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.. you can do this, but the engine doesn't use it.

@guillaume-haerinck
Copy link
Copy Markdown
Contributor Author

Noted just updated the files following your feedbacks :)

@nick-l-o3de
Copy link
Copy Markdown
Contributor

This looks good, but how do we want to proceed with this, should we keep this alive while the emscripten changes happen on o3de, until its all in, or do you expect no further revisions of this package need be made?

Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
@guillaume-haerinck guillaume-haerinck added the status/ready-for-merge Indicates that this PR has been approved, built against AR and can now be merged label Feb 15, 2026
@nick-l-o3de nick-l-o3de merged commit cb2d074 into o3de:main Mar 10, 2026
11 checks passed
@guillaume-haerinck guillaume-haerinck deleted the emscripten branch March 10, 2026 21:39
nick-l-o3de pushed a commit to o3de/o3de that referenced this pull request Mar 10, 2026
## What does this PR do?

Related to :
- #19083
- o3de/3p-package-source#284

Allow O3DE to be configured by [Emscripten](https://emscripten.org/) compiler to target webassembly. Configuration will just fail on the missing 3p dependencies which will be progressively added by the PR above and its follow-ups.

Right now, removing occurences of these 3p-packages in the few cmake files using them will allow the configuration to succeed, and allow anyone to try building and start fixing compilation issues.

**Convention**

Emscripten is as much a platform as it is a compiler, they decided to use an [unix-like API](https://emscripten.org/docs/api_reference/Filesystem-API.html) for the file system etc but you could implement a C++ to WebAssembly compiler exposing windows-like API. This is why the Platform Abstraction Layer uses `emscripten` as a name instead of `wasm`

## How was this PR tested?

Tried on Windows development branch

Setup :

- Follow emscripten [install instruction](https://emscripten.org/docs/getting_started/downloads.html)
- Install ninja build system
- Build the 3p package from emscripten using the branch above
- In the emscripten o3de branch. Create a new folder "wasm", go inside, and run `emcmake cmake ..  -DLY_3RDPARTY_PATH=YOUR_PATH` -> As stated above, will currently fail here
- Then build with  `cmake --build .`

Signed-off-by: guillaume-haerinck <guillaume.haerinck@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request status/ready-for-merge Indicates that this PR has been approved, built against AR and can now be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants