Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

24
deps/cjs-module-lexer/src/build/Makefile vendored Executable file
View File

@ -0,0 +1,24 @@
# These flags depend on the system and may be overridden
WASM_CC := clang
WASM_CFLAGS := --sysroot=/usr/share/wasi-sysroot
WASM_LDFLAGS := -nostartfiles
# These are project-specific and are expected to be kept intact
WASM_TARGET := -target wasm32-unknown-wasi
WASM_EXTRA_CFLAGS := -I include-wasm/ -Wno-logical-op-parentheses -Wno-parentheses -Oz
WASM_EXTRA_LDFLAGS := -Wl,-z,stack-size=13312,--no-entry,--compress-relocations,--strip-all
WASM_EXTRA_LDFLAGS += -Wl,--export=__heap_base,--export=parseCJS,--export=sa
WASM_EXTRA_LDFLAGS += -Wl,--export=e,--export=re,--export=es,--export=ee
WASM_EXTRA_LDFLAGS += -Wl,--export=rre,--export=ree,--export=res,--export=ru,--export=us,--export=ue
lib/lexer.wasm: include-wasm/cjs-module-lexer.h src/lexer.c
@mkdir -p lib
$(WASM_CC) $(WASM_CFLAGS) $(WASM_TARGET) $(WASM_EXTRA_CFLAGS) \
src/lexer.c -o lib/lexer.wasm \
$(WASM_LDFLAGS) $(WASM_EXTRA_LDFLAGS)
optimize: lib/lexer.wasm
${WASM_OPT} -Oz lib/lexer.wasm -o lib/lexer.wasm
clean:
rm lib/*

54
deps/cjs-module-lexer/src/build/wasm.js vendored Normal file
View File

@ -0,0 +1,54 @@
'use strict'
const WASM_BUILDER_CONTAINER = 'ghcr.io/nodejs/wasm-builder@sha256:975f391d907e42a75b8c72eb77c782181e941608687d4d8694c3e9df415a0970' // v0.0.9
const WASM_OPT = './wasm-opt'
const { execSync } = require('node:child_process')
const { writeFileSync, readFileSync, existsSync, mkdirSync } = require('node:fs')
const { join, resolve } = require('node:path')
const ROOT = resolve(__dirname, '../')
let platform = process.env.WASM_PLATFORM
if (!platform && process.argv[2]) {
platform = execSync('docker info -f "{{.OSType}}/{{.Architecture}}"').toString().trim()
}
if (process.argv[2] === '--docker') {
let cmd = `docker run --rm --platform=${platform.toString().trim()} `
if (process.platform === 'linux') {
cmd += ` --user ${process.getuid()}:${process.getegid()}`
}
if (!existsSync(`${ROOT}/dist`)){
mkdirSync(`${ROOT}/dist`);
}
cmd += ` --mount type=bind,source=${ROOT}/lib,target=/home/node/build/lib \
--mount type=bind,source=${ROOT}/src,target=/home/node/build/src \
--mount type=bind,source=${ROOT}/dist,target=/home/node/build/dist \
--mount type=bind,source=${ROOT}/node_modules,target=/home/node/build/node_modules \
--mount type=bind,source=${ROOT}/build/wasm.js,target=/home/node/build/wasm.js \
--mount type=bind,source=${ROOT}/build/Makefile,target=/home/node/build/Makefile \
--mount type=bind,source=${ROOT}/build.js,target=/home/node/build/build.js \
--mount type=bind,source=${ROOT}/package.json,target=/home/node/build/package.json \
--mount type=bind,source=${ROOT}/include-wasm,target=/home/node/build/include-wasm \
-t ${WASM_BUILDER_CONTAINER} node wasm.js`
console.log(`> ${cmd}\n\n`)
execSync(cmd, { stdio: 'inherit' })
process.exit(0)
}
const hasOptimizer = (function () {
try { execSync(`${WASM_OPT} --version`); return true } catch (error) { return false }
})()
// Build wasm binary
console.log('Building wasm');
execSync(`make lib/lexer.wasm`, { stdio: 'inherit' })
if (hasOptimizer) {
console.log('Optimizing wasm');
execSync(`make optimize`, { stdio: 'inherit' })
}
execSync(`node build.js`, { stdio: 'inherit' })