Skip to content

Commit

Permalink
[wasm building on windows (PixarAnimationStudios#1331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jochen Stier authored and GitHub Enterprise committed Oct 16, 2024
1 parent 3cf5de5 commit 8d6e4c9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
6 changes: 6 additions & 0 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def GetBuildTargets():
return apple_utils.GetBuildTargets() + [TARGET_WASM, TARGET_WASM_NODE]
elif Linux():
return [TARGET_WASM, TARGET_WASM_NODE]
elif Windows():
return [TARGET_WASM, TARGET_WASM_NODE]
else:
return []

Expand Down Expand Up @@ -987,6 +989,10 @@ def InstallBoost(context, force, buildArgs):

def InstallOneTBB(context, force, buildArgs):
with CurrentWorkingDirectory(DownloadURL(ONETBB_URL, context, force)):
if context.targetWasm:
PatchFile("cmake/compilers/Clang.cmake",
[("if (CMAKE_SYSTEM_PROCESSOR MATCHES \"(AMD64|amd64|i.86|x86)\")",
"if (CMAKE_SYSTEM_PROCESSOR MATCHES \"(AMD64|amd64|i.86|x86)\" AND NOT EMSCRIPTEN)")])
RunCMake(context, force,
['-DTBB_TEST=OFF',
'-DTBB_STRICT=OFF'] + buildArgs)
Expand Down
6 changes: 5 additions & 1 deletion pxr/base/tf/diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ _fatalSignalHandler(int signo)
fflush(stderr);

// Simulate the exit status of being killed by signal signo
_exit(128 + signo);
#ifdef __EMSCRIPTEN__
emscripten_force_exit(128 + signo);
#else
_exit(128 + signo);
#endif
}

void
Expand Down
2 changes: 0 additions & 2 deletions pxr/base/vt/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#include "pxr/base/tf/pyObjWrapper.h"

#if PXR_JS_BINDINGS_SUPPORT_ENABLED
#include "pxr/usd/sdf/wrapPathJs.h"
#include "pxr/base/tf/wrapTokenJs.h"
#include "pxr/usd/sdf/wrapAssetPathJs.h"

#include <emscripten/bind.h>
#endif // PXR_JS_BINDINGS_SUPPORT_ENABLED
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/sdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pxr_library(sdf
ts
vt
work
usd
ar
${Boost_PYTHON_LIBRARY}
${TBB_tbb_LIBRARY}
Expand Down
22 changes: 17 additions & 5 deletions pxr/usdImaging/bin/usdviewweb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,33 @@ source ./emsdk_env.sh
# Download and install the latest SDK tools.
emsdk install 3.1.66
# Make the specific SDK for the current user. (writes .emscripten file)
# Activate the specific SDK for the current user. (writes .emscripten file)
emsdk activate 3.1.66
```

Depending on your current system configuration additional build tools may be required, for example

```
# Download and install MinGW.
emsdk install mingw-4.6.2-32bit
# Activate a specific MinGW installation.
emsdk activate mingw-4.6.2-32bit
```

Note! Run emsdk activate every time you open a new powershell. The above commands will not update the system PATH permanently.

## Build USD to WebAssembly

```
# Clone the USD source code
git clone --recursive https://git.autodesk.com/autodesk-forks/usd/tree/adsk/feature/webgpu
# Go into the root of usd source repo, if the folder name is "usd_repo"
cd usd_repo
# Go into the root of usd source repo, if the folder name is "USD"
cd USD
# Build USD with --build-target wasm , where "../build_dir" is your local build folder
python3 ./build_scripts/build_usd.py --build-target wasm ../build_dir
python3 ./build_scripts/build_usd.py --build-target wasm --onetbb ../build_dir
```

This also builds the UsdViewWeb application, which you can use to test Hydra Storm with the WebGPU backend.
Expand All @@ -54,7 +66,7 @@ Start a web server in the build dir with the appropriate flags.
Go into the <build_dir>/bin folder first.

```
python ./wasm-server.py
python3 ./wasm-server.py
```

## Browser Requirements
Expand Down

0 comments on commit 8d6e4c9

Please sign in to comment.