aboutsummaryrefslogtreecommitdiff
path: root/src/js/_codegen/static-hash-tables.ts
blob: 858974aa10b6f8cc068e0d4f34ed4e0c663be8b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// TODO: move this file somewhere else. it doesnt make sense in src/js/
// it generates C++ code not related to javascript at all
import { spawn } from "bun";
import path from "../node/path";

const STATIC_HASH_TABLES = [
  //
  "src/bun.js/bindings/BunObject.cpp",
  "src/bun.js/bindings/ZigGlobalObject.lut.txt",
  "src/bun.js/bindings/JSBuffer.cpp",
  "src/bun.js/bindings/Process.cpp",
  "src/bun.js/bindings/ProcessBindingConstants.cpp",
  "src/bun.js/bindings/ProcessBindingNatives.cpp",
];

console.time("Creating static hash tables...");
const create_hash_table = path.join(import.meta.dir, "../../../src/bun.js/scripts/create_hash_table");
if (!create_hash_table) {
  console.warn("Could not find create_hash_table executable. Run `bun i` or clone webkit to build static hash tables");
  process.exit(1);
}

await Promise.all(
  STATIC_HASH_TABLES.map(async cpp => {
    cpp = path.join(import.meta.dir, "../../../", cpp);
    const { stdout, exited } = spawn({
      cmd: [create_hash_table, cpp],
      stdout: "pipe",
      stderr: "inherit",
    });
    await exited;
    let str = await new Response(stdout).text();
    str = str.replaceAll(/^\/\/.*$/gm, "");
    str = str.replaceAll(/^#include.*$/gm, "");
    str = str.replaceAll(`namespace JSC {`, "");
    str = str.replaceAll(`} // namespace JSC`, "");
    str = "// File generated via `make static-hash-table` / `make cpp`\n" + str.trim() + "\n";
    await Bun.write(cpp.replace(/\.cpp$/, ".lut.h").replace(/(\.lut)?\.txt$/, ".lut.h"), str);
    console.log("Wrote", path.relative(process.cwd(), cpp.replace(/\.cpp$/, ".lut.h")));
  }),
);

console.timeEnd("Creating static hash tables...");
ple images * chore: changeset 2023-03-30[RSS] Fix: update `RSSFeedItem` type to comply with `strictest` tsconfig (#6614)Gravatar Aivars Liepa 2-1/+6 * fix RSSFeedItem type for `strictest` tsconfig * add .changeset --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> 2023-03-29Update lit-ssr dependency (#6681)Gravatar Elliott Marquez 13-82/+107 * update lit-ssr dependency * delete unnecessary lit shim checks * delete another unused lit shim feature * fix sass build * bump lit and polyfill versions to match ssr req * shim HTMLElement in test * remove lit global shim workarounds * re-shim Astro's ce.define * remove fix window test and shim HTML Element * Update .changeset/gold-windows-fly.md Co-authored-by: Augustine Kim <ajk830@gmail.com> * fix window check test * implement suggestoins --------- Co-authored-by: Augustine Kim <ajk830@gmail.com> 2023-03-29fix(images): Improve error handling around the new assets feature (#6649)Gravatar Erika 17-21/+290 * fix(images): Improve error handling around the new assets feature * fix: add missing error message * fix(images): Fix schema preprocessing logic returning undefined when the file doesn't exist * test: add tests * chore: lockfile * chore: changeset * Apply suggestions from code review Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * test: remove console.logs * fix(images): properly join with path * fix: attempt a fix * test: remove console.log * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * fix: add undefined test for global for SSR --------- Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> 2023-03-29Use debug option for debugDir (#6554)Gravatar Isaac 1-1/+1 Co-authored-by: Matthew Phillips <matthew@skypack.dev>