mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Every file tsc-ts reads goes through scriptc's file system callbacks, including the ~80 files of tsc-ts's own default library directory: one round trip from the checker to the compiler and back for each. Those files belong to the installed tsc-ts (the build caches key on its executable's identity), and no build serves them differently. When tsc-ts takes --default-libraries-from-disk, the native compiler passes it to the checker it starts and to the shared checker server, so tsc-ts reads those files itself; every other path keeps the callbacks. Released tsc-ts versions reject the flag, so checker-features.ts asks each tsc-ts executable once (tsc-ts --api --default-libraries-from-disk with an empty input exits with 0 only when it knows the flag) and keeps the answer in the native cache, keyed by the executable's identity. With a tsc-ts that does not know the flag, builds run as before. Edit builds of small programs through the shared checker server are about 18 ms faster, and 6-9 ms faster without it.
44 lines
2.4 KiB
C
44 lines
2.4 KiB
C
#ifndef SCRIPTC_TS7_PROCESS_H
|
|
#define SCRIPTC_TS7_PROCESS_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
/* A compiler host boundary, called synchronously on the compiler thread.
|
|
* Handles are monotonically assigned IDs, never pointer-shaped numbers.
|
|
* Zero is an invalid handle. Failed transfers return -1; EOF returns 0.
|
|
* The last error is copied before another host operation can overwrite it.
|
|
* All spans are borrowed for the duration of the call only. */
|
|
uint32_t scriptc_ts7_open(const uint8_t *executable, size_t executable_size,
|
|
const uint8_t *cwd, size_t cwd_size,
|
|
const uint8_t *callbacks, size_t callbacks_size,
|
|
uint8_t timing, uint8_t libraries_from_disk);
|
|
/* Connects to the shared checker server `name` (`--api --listen`) in this
|
|
* user's private server directory, starting it in its own process group
|
|
* with `--idle-exit idle_exit` and a limit of `memory` megabytes
|
|
* (TSC_TS_LISTEN_MEMORY, unless the environment sets it) when none answers. Returns 0 with the error
|
|
* text when another build is connected to it, it cannot be started or
|
|
* reached, or the platform has no Unix sockets; the caller then starts its
|
|
* own server with scriptc_ts7_open. Closing the handle ends the connection
|
|
* and leaves the server running. */
|
|
uint32_t scriptc_ts7_attach(const uint8_t *name, size_t name_size,
|
|
const uint8_t *executable, size_t executable_size,
|
|
const uint8_t *cwd, size_t cwd_size,
|
|
const uint8_t *callbacks, size_t callbacks_size,
|
|
uint8_t timing, uint8_t libraries_from_disk, uint32_t idle_exit,
|
|
uint32_t memory);
|
|
int32_t scriptc_ts7_read(uint32_t handle, uint8_t *bytes, size_t size,
|
|
uint32_t offset, uint32_t length);
|
|
int32_t scriptc_ts7_write(uint32_t handle, const uint8_t *bytes, size_t size,
|
|
uint32_t offset, uint32_t length);
|
|
uint32_t scriptc_ts7_pid(uint32_t handle);
|
|
void scriptc_ts7_close(uint32_t handle);
|
|
void scriptc_ts7_close_all(void);
|
|
int32_t scriptc_ts7_error(uint8_t *bytes, size_t size);
|
|
/* The index after the JSON value that starts at `start` in a checker reply,
|
|
* as jsonValueEnd in semantic-json.ts computes it, or -1 when the reply is
|
|
* malformed there. */
|
|
int32_t scriptc_ts7_json_value_end(const uint8_t *bytes, size_t size, uint32_t start);
|
|
|
|
#endif
|