Skip to content

Generate html file with Bazel Emscripten toolchain #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Nerdyvedi opened this issue Mar 14, 2021 · 1 comment
Open

Generate html file with Bazel Emscripten toolchain #759

Nerdyvedi opened this issue Mar 14, 2021 · 1 comment
Assignees

Comments

@Nerdyvedi
Copy link

Nerdyvedi commented Mar 14, 2021

Hi,
I want to generate html file in addition to wasm and javascript "glue code". I am using bazel emscripten toolchain.

I want to do something like the following
emcc hello.c -s WASM=1 -o hello.html
But not able to understand what changes I need to make in the Bazel build file to get the html file as well.

I added linkopts = [ "-o hello.html"], to the BUILD file.
But getting the following error
emcc.py did not appear to output any known files!

I tried with --oformat html
Getting this error
Customizing EXPORT_NAME is not currently possible with HTML output (see https://github.com/emscripten-core/emscripten/issues/10086)'

Then, I changed EXPORT_NAME=Module,
I get the following
Due to collision in variable name "Module", the shell file "/root/.cache/bazel/_bazel_root/7c8212d09d20008d9ab2f5e31ef362d8/external/emscripten/emscripten/src/shell.html" is not compatible with build options "-s MODULARIZE=1 -s EXPORT_NAME=Module". Either provide your own shell file, change the name of the export to something else to avoid the name collision. (see https://github.com/emscripten-core/emscripten/issues/7950 for details)

@walkingeyerobot
Copy link
Collaborator

Ok, this is now mostly done.

Right now the HTML minifier doesn't appear to work. While the npm package html-minifier-terser is correctly downloaded and installed, it runs it via external/emscripten/emscripten/node_modules/.bin/html-minifier-terser, which is a symlink to node_modules/html-minifier-terser/cli.js. This is correct, except cli.js has a bunch of relative paths, so running it via the symlink doesn't work. I don't yet know if this is an emscripten bug or a bazel specific bug. I think the latter is more likely, but it's also possible not a ton of people are using the html minifier and this has just gone unreported.

For now, just pass linkopts = ["--oformat=html", "-s MINIFY_HTML=0"],. I'll keep this bug open to track using the html minifier with the bazel toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants