Skip to content

Bazel add html support #765

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

Merged
merged 5 commits into from
Mar 22, 2021
Merged

Bazel add html support #765

merged 5 commits into from
Mar 22, 2021

Conversation

walkingeyerobot
Copy link
Collaborator

This gets us most of the way there for #759.

@walkingeyerobot walkingeyerobot requested a review from sbc100 March 18, 2021 22:11
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('-o')
parser.add_argument('--oformat')
(options, _) = parser.parse_known_args(param_file_args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe options = parser.parse_known_args(param_file_args)[0] (or at least drop the braces on the left hand side of the expression.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


# The output file name is the name of the build rule that was built.
# Add an appropriate file extension based on --oformat.
if oformat is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

If oformat is None don't we want to default to "js" since that is what emcc will do?

How about parser.add_argument('--oformat', default='js') above and then you can remove this condition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This check is a bit overly cautious, but I prefer to keep it in there. If oformat is None, I'd rather emcc handle what to do by default, just in case emcc ever changes. Also, in the crosstool we're setting --oformat=js as a default, so realistically this won't ever be None.

# Re-write response file if needed.
if replace_response_file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

(unrelated) I wonder if we can completely remove this at some point... how does bazel + clang deal with this issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's an internal P3 bug filed with the bazel folks that we're tracking.

# the output_file so it has the proper extension.
# Note that if you do something like name your build rule "foo.js" and pass
# "--oformat=html", emscripten will write to the same file for both the js and
# html output, overwriting the js output entirely with the html.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sounds like there is still a bug in emscripten?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Possibly. Emscripten could ensure it's only writing to files it just created and throw an error. I can file a bug for later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@walkingeyerobot walkingeyerobot merged commit 848260e into master Mar 22, 2021
@walkingeyerobot walkingeyerobot deleted the bazel_add_html_support branch March 22, 2021 00:08
radekdoulik referenced this pull request in dotnet/emsdk May 20, 2021
* allow the bazel toolchain to output html files

* allow for cc_binary rule names to end in .js

* fix python name

* continue to call emcc instead of em++ for now

* small cleanup

Co-authored-by: Mitch Foley <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants