1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-11 18:17:48 -05:00
denoland-deno/tools/napi/generate_symbols_lists.js
Luke Channings d2c8b5f087
fix(build) fix linux symbols export list format (#16313)
Fixes the error reported in #16304.

> = note:
/usr/bin/ld:/home/abotella/Projects/deno/cli/generated_symbol_exports_list_linux.def:1:
syntax error in dynamic list
          collect2: error: ld returned 1 exit status

This was caused by the format of the symbols list on Linux being
malformed (as the error implies).
The format is documented in ld's
[VERSION](https://sourceware.org/binutils/docs/ld/VERSION.html) as well
as:

>  --export-dynamic-symbol-list=file
           Specify a --export-dynamic-symbol for each pattern in the
           file.  The format of the file is the same as the version node
           without scope and node name.  See VERSION for more
           information.

Previously, the format for the Linux symbols list was simply a list of
symbols, now it follows the format:

```
{ symbol_name_a;  ...; symbol_name_z };
```
2022-10-17 00:53:35 +02:00

24 lines
769 B
JavaScript
Executable file

#!/usr/bin/env -S deno run --unstable --allow-read --allow-write
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import exports from "../../cli/napi_sym/symbol_exports.json" assert {
type: "json",
};
const symbolExportLists = {
linux: `{ ${exports.symbols.map((s) => `"${s}"`).join("; ")}; };`,
windows: `LIBRARY\nEXPORTS\n${
exports.symbols
.map((symbol) => " " + symbol)
.join("\n")
}`,
macos: exports.symbols.map((symbol) => "_" + symbol).join("\n"),
};
for await (const [os, def] of Object.entries(symbolExportLists)) {
const defUrl = new URL(
`../../cli/napi_sym/generated_symbol_exports_list_${os}.def`,
import.meta.url,
);
await Deno.writeTextFile(defUrl.pathname, def, { create: true });
}