@git.zone/tsrust 1.13.2 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.smartconfig.json +4 -0
  2. package/assets/notices/gcc-gpl-3.0.txt +674 -0
  3. package/assets/notices/gcc-runtime-library-exception-3.1.txt +73 -0
  4. package/assets/notices/glibc-lgpl-2.1.txt +502 -0
  5. package/assets/notices/musl-copyright.txt +193 -0
  6. package/dist_ts/00_commitinfo_data.js +1 -1
  7. package/dist_ts/index.d.ts +1 -0
  8. package/dist_ts/index.js +2 -1
  9. package/dist_ts/mod_cli/classes.tsrustcli.d.ts +10 -0
  10. package/dist_ts/mod_cli/classes.tsrustcli.js +91 -11
  11. package/dist_ts/mod_cli/helpers.targets.d.ts +2 -0
  12. package/dist_ts/mod_cli/helpers.targets.js +1 -1
  13. package/dist_ts/mod_matrix/classes.nativematrixbuilder.d.ts +6 -0
  14. package/dist_ts/mod_matrix/classes.nativematrixbuilder.js +44 -1
  15. package/dist_ts/mod_notices/classes.nativenoticesgenerator.d.ts +96 -0
  16. package/dist_ts/mod_notices/classes.nativenoticesgenerator.js +912 -0
  17. package/dist_ts/mod_notices/classes.noticetoolchain.d.ts +30 -0
  18. package/dist_ts/mod_notices/classes.noticetoolchain.js +69 -0
  19. package/dist_ts/mod_notices/helpers.licensetext.d.ts +12 -0
  20. package/dist_ts/mod_notices/helpers.licensetext.js +81 -0
  21. package/dist_ts/mod_notices/helpers.muslversion.d.ts +6 -0
  22. package/dist_ts/mod_notices/helpers.muslversion.js +47 -0
  23. package/dist_ts/mod_notices/helpers.noticesconfig.d.ts +51 -0
  24. package/dist_ts/mod_notices/helpers.noticesconfig.js +113 -0
  25. package/dist_ts/mod_notices/helpers.runtimetexts.d.ts +9 -0
  26. package/dist_ts/mod_notices/helpers.runtimetexts.js +45 -0
  27. package/dist_ts/mod_notices/helpers.spdx.d.ts +21 -0
  28. package/dist_ts/mod_notices/helpers.spdx.js +88 -0
  29. package/dist_ts/mod_notices/helpers.staticglibc.d.ts +26 -0
  30. package/dist_ts/mod_notices/helpers.staticglibc.js +45 -0
  31. package/dist_ts/mod_notices/index.d.ts +8 -0
  32. package/dist_ts/mod_notices/index.js +9 -0
  33. package/package.json +5 -5
  34. package/readme.md +105 -13
  35. package/ts/00_commitinfo_data.ts +1 -1
  36. package/ts/index.ts +1 -0
  37. package/ts/mod_cli/classes.tsrustcli.ts +104 -10
  38. package/ts/mod_cli/helpers.targets.ts +2 -0
  39. package/ts/mod_matrix/classes.nativematrixbuilder.ts +44 -0
  40. package/ts/mod_notices/classes.nativenoticesgenerator.ts +1151 -0
  41. package/ts/mod_notices/classes.noticetoolchain.ts +92 -0
  42. package/ts/mod_notices/helpers.licensetext.ts +111 -0
  43. package/ts/mod_notices/helpers.muslversion.ts +46 -0
  44. package/ts/mod_notices/helpers.noticesconfig.ts +190 -0
  45. package/ts/mod_notices/helpers.runtimetexts.ts +63 -0
  46. package/ts/mod_notices/helpers.spdx.ts +107 -0
  47. package/ts/mod_notices/helpers.staticglibc.ts +79 -0
  48. package/ts/mod_notices/index.ts +8 -0
@@ -0,0 +1,79 @@
1
+ import { friendlyTargetName } from '../mod_cli/helpers.targets.js';
2
+
3
+ export interface IStaticGlibcCheckOptions {
4
+ targets: Array<{ triple: string; friendly: string }>;
5
+ /** `static` from the configuration or `--static`. */
6
+ staticLinking: boolean;
7
+ /** `rustflags` from the tsrust configuration. */
8
+ rustflags: string[];
9
+ environment: NodeJS.ProcessEnv;
10
+ }
11
+
12
+ const isGnuTarget = (tripleArg: string): boolean => tripleArg.endsWith('-linux-gnu');
13
+
14
+ /**
15
+ * The error for a Linux GNU target that links glibc statically: static glibc
16
+ * carries LGPL-2.1 relinking obligations that native notices do not fulfil.
17
+ */
18
+ export function staticGlibcError(
19
+ friendlyArg: string,
20
+ tripleArg: string,
21
+ reasonArg: string,
22
+ remedyArg: string,
23
+ ): Error {
24
+ const musl = friendlyTargetName(tripleArg.replace(/-gnu$/, '-musl'));
25
+ return new Error(
26
+ `${reasonArg}. Static glibc carries LGPL-2.1 relinking obligations that tsrust notices do not fulfil. ` +
27
+ `Choose (a) a static musl target such as ${musl} instead of ${friendlyArg}, or (b) dynamic glibc by ` +
28
+ `${remedyArg}.`,
29
+ );
30
+ }
31
+
32
+ /**
33
+ * Refuses a build with native notices that would link glibc statically, from
34
+ * any source tsrust can see before building: `static`, tsrust `rustflags`,
35
+ * and the rustflags environment variables Cargo reads. Static linking set up
36
+ * elsewhere (a Cargo configuration file) is caught by inspecting the built
37
+ * binary with `staticGlibcArtifactError`.
38
+ */
39
+ export function assertNoStaticGlibc(optionsArg: IStaticGlibcCheckOptions): void {
40
+ for (const target of optionsArg.targets.filter((entry) => isGnuTarget(entry.triple))) {
41
+ if (optionsArg.staticLinking) {
42
+ throw staticGlibcError(
43
+ target.friendly,
44
+ target.triple,
45
+ `Target ${target.friendly} links glibc statically ("static" or --static)`,
46
+ 'removing "static" from the @git.zone/tsrust configuration and not passing --static',
47
+ );
48
+ }
49
+ const sources: Array<[string, string | undefined]> = [
50
+ ['the @git.zone/tsrust rustflags', optionsArg.rustflags.join(' ')],
51
+ ['RUSTFLAGS', optionsArg.environment.RUSTFLAGS],
52
+ ['CARGO_ENCODED_RUSTFLAGS', optionsArg.environment.CARGO_ENCODED_RUSTFLAGS],
53
+ ['CARGO_BUILD_RUSTFLAGS', optionsArg.environment.CARGO_BUILD_RUSTFLAGS],
54
+ ];
55
+ const targetVariable = `CARGO_TARGET_${target.triple.toUpperCase().replace(/-/g, '_')}_RUSTFLAGS`;
56
+ sources.push([targetVariable, optionsArg.environment[targetVariable]]);
57
+ for (const [name, value] of sources) {
58
+ if (value?.includes('+crt-static')) {
59
+ throw staticGlibcError(
60
+ target.friendly,
61
+ target.triple,
62
+ `Target ${target.friendly} links glibc statically (+crt-static in ${name})`,
63
+ `removing +crt-static from ${name}`,
64
+ );
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ /** The error for a GNU binary that the build produced without an interpreter. */
71
+ export function staticGlibcArtifactError(friendlyArg: string, tripleArg: string): Error {
72
+ return staticGlibcError(
73
+ friendlyArg,
74
+ tripleArg,
75
+ `${friendlyArg} was linked statically: the binary has no ELF interpreter although no tsrust setting or ` +
76
+ 'rustflags environment variable requested static linking',
77
+ 'removing crt-static and static link arguments from the Cargo configuration (.cargo/config.toml)',
78
+ );
79
+ }
@@ -0,0 +1,8 @@
1
+ export * from './helpers.spdx.js';
2
+ export * from './helpers.licensetext.js';
3
+ export * from './helpers.muslversion.js';
4
+ export * from './helpers.noticesconfig.js';
5
+ export * from './helpers.runtimetexts.js';
6
+ export * from './helpers.staticglibc.js';
7
+ export * from './classes.noticetoolchain.js';
8
+ export * from './classes.nativenoticesgenerator.js';