-
Notifications
You must be signed in to change notification settings - Fork 541
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
Use llhttp wasm build #575
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9bd4b0b
use parser.execute
ronag 08ebbed
fixup
ronag 723afc5
fixup
ronag aa7531c
fixup
ronag 5de2a3c
fixup
ronag 361b560
fixup
ronag 2361b8e
fixup
ronag 6920db3
Merge branch 'master' into parser-execute
ronag 66af633
feat: use llhttp with wasm for parsing
dnlup e20a2f0
Merge branch 'main' into llhttp_wasm
mcollina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict' | ||
|
||
const { join, resolve } = require('path') | ||
const { copyFileSync, rmSync } = require('fs') | ||
const { execSync } = require('child_process') | ||
const TMP = require('os').tmpdir() | ||
|
||
const REPO = '[email protected]:dnlup/llhttp.git' | ||
const CHECKOUT = 'undici_wasm' | ||
ronag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const REPO_PATH = join(TMP, 'llhttp') | ||
ronag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const WASM_OUT = resolve(__dirname, '../lib/llhttp') | ||
|
||
let code = 0 | ||
|
||
try { | ||
execSync(`git clone ${REPO}`, { stdio: 'inherit', cwd: TMP }) | ||
execSync(`git checkout ${CHECKOUT}`, { stdio: 'inherit', cwd: REPO_PATH }) | ||
// https://docs.npmjs.com/cli/v7/commands/npm-ci | ||
// Performs a clean install using the lockfile, this makes the installation faster. | ||
execSync('npm ci', { stdio: 'inherit', cwd: REPO_PATH }) | ||
ronag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
execSync('npm run build-wasm', { stdio: 'inherit', cwd: REPO_PATH }) | ||
copyFileSync(join(REPO_PATH, 'build', 'wasm', 'llhttp.wasm'), join(WASM_OUT, 'llhttp.wasm')) | ||
copyFileSync(join(REPO_PATH, 'build', 'wasm', 'constants.js'), join(WASM_OUT, 'constants.js')) | ||
} catch (error) { | ||
console.error(error) | ||
code = 1 | ||
} finally { | ||
rmSync(REPO_PATH, { recursive: true, force: true }) | ||
process.exit(code) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we used the upstream repository instead and we copy over whatever files we need.
Alternatively, I'd be ok in doing that adds this to llhttp itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding on https://github.com/nodejs/undici/pull/575/files#r589005221 (and thinking out loud), we need to build the
c
files prior to build the wasm binary (and the source files are the samellhttp
is using to build the parser), I think moving that out ofllhttp
would require us to duplicate a lot of build logic in here. Like, we would need thec
src files, thejs
files to build the parser, add the build scripts.I'll open a PR to
llhttp
and see what happens.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, here's the PR:
nodejs/llhttp#93