Skip to content
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

chore: use common WASM builder #3791

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions build/Dockerfile

This file was deleted.

30 changes: 7 additions & 23 deletions build/wasm.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict'

const WASM_BUILDER_CONTAINER = 'ghcr.io/nodejs/wasm-builder@sha256:975f391d907e42a75b8c72eb77c782181e941608687d4d8694c3e9df415a0970' // v0.0.9
Copy link
Member

Choose a reason for hiding this comment

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

Are there plans to provide regular updates to it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have been thinking a bit about that, I think we want to update regularly but not necessarily too often. At least a month before every new Node.js major but I could see more often making sense as well.

The repo where it is maintained has release please and all of the automation to generate a new vesion so it's as simple as a PR to update the dockerfile used to build the container and once that lands the rest is pretty much automated.

@metcoder95 how often do you think an update would make sense ? How often was undici updating?

Copy link
Member

Choose a reason for hiding this comment

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

I cannot develop a cadence, as I'd say that should be up to the things added to the new version. If it contains security fixes, maybe faster than usual, otherwise we can make a check every time we prepare a new undici's release.

@mcollina @ronag wdyt?


const { execSync } = require('node:child_process')
const { writeFileSync, readFileSync } = require('node:fs')
const { join, resolve } = require('node:path')

const ROOT = resolve(__dirname, '../')
const WASM_SRC = resolve(__dirname, '../deps/llhttp')
const WASM_OUT = resolve(__dirname, '../lib/llhttp')
const DOCKERFILE = resolve(__dirname, './Dockerfile')

// These are defined by build environment
const WASM_CC = process.env.WASM_CC || 'clang'
Expand Down Expand Up @@ -52,33 +53,16 @@ if (!platform && process.argv[2]) {
platform = execSync('docker info -f "{{.OSType}}/{{.Architecture}}"').toString().trim()
}

if (process.argv[2] === '--rm') {
const cmd = 'docker image rm llhttp_wasm_builder'

console.log(`> ${cmd}\n\n`)
try {
execSync(cmd, { stdio: 'inherit' })
} catch (e) {}

process.exit(0)
}

if (process.argv[2] === '--prebuild') {
const cmd = `docker build --platform=${platform.toString().trim()} -t llhttp_wasm_builder -f ${DOCKERFILE} ${ROOT}`

console.log(`> ${cmd}\n\n`)
execSync(cmd, { stdio: 'inherit' })

process.exit(0)
}

if (process.argv[2] === '--docker') {
let cmd = `docker run --rm -t --platform=${platform.toString().trim()}`
let cmd = `docker run --rm --platform=${platform.toString().trim()} `
if (process.platform === 'linux') {
cmd += ` --user ${process.getuid()}:${process.getegid()}`
}

cmd += ` --mount type=bind,source=${ROOT}/lib/llhttp,target=/home/node/undici/lib/llhttp llhttp_wasm_builder node build/wasm.js`
cmd += ` --mount type=bind,source=${ROOT}/lib/llhttp,target=/home/node/build/lib/llhttp \
--mount type=bind,source=${ROOT}/build,target=/home/node/build/build \
--mount type=bind,source=${ROOT}/deps,target=/home/node/build/deps \
-t ${WASM_BUILDER_CONTAINER} node build/wasm.js`
console.log(`> ${cmd}\n\n`)
execSync(cmd, { stdio: 'inherit' })
process.exit(0)
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"types": "index.d.ts",
"scripts": {
"build:node": "esbuild index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names && node scripts/strip-comments.js",
"prebuild:wasm": "node build/wasm.js --prebuild",
"build:wasm": "node build/wasm.js --docker",
"generate-pem": "node scripts/generate-pem.js",
"lint": "eslint --cache",
Expand Down
Loading