@smoothbricks/nx-plugin 0.7.17 → 0.7.19
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.
- package/README.md +315 -114
- package/dist/.build-inputs.json +47 -38
- package/dist/built-output-packages.js +1 -1
- package/dist/bun-lock-scope.d.ts +128 -20
- package/dist/bun-lock-scope.d.ts.map +1 -1
- package/dist/bun-lock-scope.js +267 -44
- package/dist/cargo-closure-input.d.ts +8 -6
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +15 -12
- package/dist/cargo-source-hash.d.ts +26 -25
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +84 -105
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts +20 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +43 -22
- package/dist/ensure-built-receipt.d.ts +3 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +3 -2
- package/dist/eslint-config-closure.d.ts +8 -3
- package/dist/eslint-config-closure.d.ts.map +1 -1
- package/dist/eslint-config-closure.js +24 -5
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +19 -6
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +22 -15
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
- package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-rise.js +111 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts +1 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +256 -86
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +45 -8
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
- package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress-channel.js +113 -0
- package/dist/executors/bounded-exec/progress.d.ts +5 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +123 -16
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +7 -2
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/schema.js +17 -1
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +39 -10
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +60 -14
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +294 -152
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/managed-files/generator.d.ts +5 -1
- package/dist/managed-files/generator.d.ts.map +1 -1
- package/dist/managed-files/generator.js +22 -7
- package/dist/managed-files/render-memo.d.ts +13 -0
- package/dist/managed-files/render-memo.d.ts.map +1 -0
- package/dist/managed-files/render-memo.js +94 -0
- package/dist/task-results.js +2 -1
- package/dist/test-program.d.ts +11 -6
- package/dist/test-program.d.ts.map +1 -1
- package/dist/test-program.js +39 -35
- package/dist/tool-bins.d.ts +12 -0
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +31 -6
- package/dist/typecheck-test-policy.d.ts +10 -1
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +40 -24
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/dist/workspace-index.d.ts +14 -1
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +36 -4
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1851 -221
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +122 -14
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +68 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/bun-lock-scope.ts +293 -40
- package/src/cargo-closure-input.ts +20 -12
- package/src/cargo-source-hash.ts +119 -145
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +59 -21
- package/src/ensure-built-receipt.ts +3 -2
- package/src/eslint-config-closure.ts +27 -6
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +41 -19
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/cpu-rise.ts +156 -0
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +341 -123
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +57 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress-channel.ts +129 -0
- package/src/executors/bounded-exec/progress.ts +39 -3
- package/src/executors/bounded-exec/ram-temp.ts +137 -17
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +21 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +83 -22
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +357 -166
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/managed-files/generator.ts +21 -6
- package/src/managed-files/render-memo.ts +135 -0
- package/src/test-program.ts +36 -41
- package/src/tool-bins.ts +35 -6
- package/src/typecheck-test-policy.ts +49 -24
- package/src/workspace-config-policy.ts +161 -43
- package/src/workspace-index.ts +40 -5
- package/test-timings.json +157 -141
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -0,0 +1,1055 @@
|
|
|
1
|
+
diff --git a/driver/emit_plugin.go b/driver/emit_plugin.go
|
|
2
|
+
index 3793b3a406c2bf2643567a755d34e66a26eac5c8..3c690ac3d9a99be7914ad9aed76e5890d236ea9b 100644
|
|
3
|
+
--- a/driver/emit_plugin.go
|
|
4
|
+
+++ b/driver/emit_plugin.go
|
|
5
|
+
@@ -427,7 +427,13 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
6
|
+
return diagnostics, err
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
- return diagnostics, output.flush()
|
|
10
|
+
+ if err := output.flush(); err != nil {
|
|
11
|
+
+ return diagnostics, err
|
|
12
|
+
+ }
|
|
13
|
+
+ // Files linked plugins reported writing beside these outputs follow them
|
|
14
|
+
+ // through the host's writer, so the host lists them too (ReportHostOutput).
|
|
15
|
+
+ _, err = p.writeHostOutputs(writeFile)
|
|
16
|
+
+ return diagnostics, err
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// writePluginEmitOutput writes one artifact of the hand-assembled emit, passing
|
|
20
|
+
diff --git a/driver/force_emit_analysis_options_test.go b/driver/force_emit_analysis_options_test.go
|
|
21
|
+
new file mode 100644
|
|
22
|
+
index 0000000000000000000000000000000000000000..97d1522f7979b488dc62b86cc1d78d72f1913cb5
|
|
23
|
+
--- /dev/null
|
|
24
|
+
+++ b/driver/force_emit_analysis_options_test.go
|
|
25
|
+
@@ -0,0 +1,69 @@
|
|
26
|
+
+package driver
|
|
27
|
+
+
|
|
28
|
+
+import (
|
|
29
|
+
+ "os"
|
|
30
|
+
+ "path/filepath"
|
|
31
|
+
+ "strings"
|
|
32
|
+
+ "testing"
|
|
33
|
+
+
|
|
34
|
+
+ shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
35
|
+
+ shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
36
|
+
+ shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
37
|
+
+)
|
|
38
|
+
+
|
|
39
|
+
+func TestForceEmitRewritesAnalysisOnlyImports(t *testing.T) {
|
|
40
|
+
+ root, err := filepath.EvalSymlinks(t.TempDir())
|
|
41
|
+
+ if err != nil {
|
|
42
|
+
+ t.Fatal(err)
|
|
43
|
+
+ }
|
|
44
|
+
+ files := map[string]string{
|
|
45
|
+
+ "tsconfig.json": `{"compilerOptions":{"target":"ES2022","module":"ESNext","moduleResolution":"Bundler","types":[],"strict":true,"noEmit":true,"noEmitOnError":true,"allowImportingTsExtensions":true,"outDir":"out"},"files":["index.ts","dependency.ts"]}`,
|
|
46
|
+
+ "dependency.ts": `export const value = 7;`,
|
|
47
|
+
+ "index.ts": `import { value } from "./dependency.ts"; export const result = value;`,
|
|
48
|
+
+ }
|
|
49
|
+
+ for name, text := range files {
|
|
50
|
+
+ if err := os.WriteFile(filepath.Join(root, name), []byte(text), 0o644); err != nil {
|
|
51
|
+
+ t.Fatal(err)
|
|
52
|
+
+ }
|
|
53
|
+
+ }
|
|
54
|
+
+ analysis, diagnostics, err := LoadProgram(root, "tsconfig.json", LoadProgramOptions{})
|
|
55
|
+
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
56
|
+
+ t.Fatalf("analysis load failed: %v; %v", err, diagnostics)
|
|
57
|
+
+ }
|
|
58
|
+
+ defer analysis.Close()
|
|
59
|
+
+ if diagnostics := analysis.Diagnostics(); CountErrors(diagnostics) != 0 {
|
|
60
|
+
+ t.Fatalf("valid analysis-only imports failed checking: %v", diagnostics)
|
|
61
|
+
+ }
|
|
62
|
+
+ diagnostics, err = analysis.EmitWithPluginTransformer(
|
|
63
|
+
+ func(_ *shimprinter.EmitContext, source *shimast.SourceFile) *shimast.SourceFile {
|
|
64
|
+
+ t.Fatal("analysis-only program ran a JavaScript emit hook")
|
|
65
|
+
+ return source
|
|
66
|
+
+ },
|
|
67
|
+
+ func(name, text string, _ *shimcompiler.WriteFileData) error {
|
|
68
|
+
+ t.Fatalf("analysis-only program wrote %s", name)
|
|
69
|
+
+ return nil
|
|
70
|
+
+ },
|
|
71
|
+
+ )
|
|
72
|
+
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
73
|
+
+ t.Fatalf("analysis-only emit failed: %v; %v", err, diagnostics)
|
|
74
|
+
+ }
|
|
75
|
+
+ emitting, diagnostics, err := LoadProgram(root, "tsconfig.json", LoadProgramOptions{ForceEmit: true})
|
|
76
|
+
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
77
|
+
+ t.Fatalf("forced emit load failed: %v; %v", err, diagnostics)
|
|
78
|
+
+ }
|
|
79
|
+
+ defer emitting.Close()
|
|
80
|
+
+ output := make(map[string]string)
|
|
81
|
+
+ diagnostics, err = emitting.EmitWithPluginTransformer(
|
|
82
|
+
+ func(_ *shimprinter.EmitContext, source *shimast.SourceFile) *shimast.SourceFile { return source },
|
|
83
|
+
+ func(name, text string, _ *shimcompiler.WriteFileData) error {
|
|
84
|
+
+ output[filepath.Base(name)] = text
|
|
85
|
+
+ return nil
|
|
86
|
+
+ },
|
|
87
|
+
+ )
|
|
88
|
+
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
89
|
+
+ t.Fatalf("forced emit rejected analysis-only imports: %v; %v", err, diagnostics)
|
|
90
|
+
+ }
|
|
91
|
+
+ if !strings.Contains(output["index.js"], `from "./dependency.js"`) {
|
|
92
|
+
+ t.Fatalf("forced emit did not rewrite the runtime import: %s", output["index.js"])
|
|
93
|
+
+ }
|
|
94
|
+
+}
|
|
95
|
+
diff --git a/driver/plugins.go b/driver/plugins.go
|
|
96
|
+
index 3224cea63290e7b90629e2814143ccc94ef0ba86..aff211cb9b6c3e06191eccd322bf7c6dde7856d8 100644
|
|
97
|
+
--- a/driver/plugins.go
|
|
98
|
+
+++ b/driver/plugins.go
|
|
99
|
+
@@ -9,6 +9,8 @@ import (
|
|
100
|
+
"sort"
|
|
101
|
+
"strings"
|
|
102
|
+
"sync"
|
|
103
|
+
+
|
|
104
|
+
+ "github.com/microsoft/typescript-go/shim/ast"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
// LinkedPluginsEnv is the environment variable ttsc sets to pass the JSON
|
|
108
|
+
@@ -171,6 +173,7 @@ type PluginContext struct {
|
|
109
|
+
reportFileComplete func(string)
|
|
110
|
+
reportEveryFileComplete func()
|
|
111
|
+
readEnvironment func(string) (string, bool)
|
|
112
|
+
+ reportHostOutput func(string)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ReportObservationIncomplete declares that this hook's input population could
|
|
116
|
+
@@ -233,6 +236,24 @@ func (ctx PluginContext) Env(name string) (string, bool) {
|
|
117
|
+
return ctx.readEnvironment(name)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
+// ReportHostOutput declares a file this hook wrote beside the compiler's
|
|
121
|
+
+// outputs, such as a census or a manifest in outDir. A later emit of this
|
|
122
|
+
+// generation hands the file's bytes as they are then to the host's writer,
|
|
123
|
+
+// after the compiler's own outputs, so every host lists it with them: a caller
|
|
124
|
+
+// that keeps exactly the files an emit lists (a build that prunes its outDir by
|
|
125
|
+
+// that list) keeps it too. A relative file is resolved against Cwd. An emit
|
|
126
|
+
+// fails when a reported file cannot be read. A context without a driver
|
|
127
|
+
+// callback ignores the report.
|
|
128
|
+
+func (ctx PluginContext) ReportHostOutput(file string) {
|
|
129
|
+
+ if ctx.reportHostOutput == nil || strings.TrimSpace(file) == "" {
|
|
130
|
+
+ return
|
|
131
|
+
+ }
|
|
132
|
+
+ if !filepath.IsAbs(file) {
|
|
133
|
+
+ file = filepath.Join(ctx.Cwd, file)
|
|
134
|
+
+ }
|
|
135
|
+
+ ctx.reportHostOutput(filepath.Clean(file))
|
|
136
|
+
+}
|
|
137
|
+
+
|
|
138
|
+
// ReportHostInputHash declares the exact file state consumed by a native
|
|
139
|
+
// plugin. hash is a lowercase SHA-256 digest for an observed file and nil for
|
|
140
|
+
// a missing candidate. Conflicting observations are retained as host inputs
|
|
141
|
+
@@ -544,11 +565,29 @@ type EmitTransformPlugin interface {
|
|
142
|
+
EmitTransform(PluginContext) (PluginTransform, error)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
+// DiagnosticPlugin is a linked plugin whose ProgramPlugin lowers a construct
|
|
146
|
+
+// the stock checker refuses, a dialect its compiles admit: a source spelling
|
|
147
|
+
+// the plugin rewrites before emit or a transform's output, which TypeScript has
|
|
148
|
+
+// no grammar for. The checker judges the parse tree before any ProgramPlugin
|
|
149
|
+
+// applies, so its refusal of such a construct names nothing the output holds,
|
|
150
|
+
+// and every lane that gates on the program's diagnostics (check, emit, a
|
|
151
|
+
+// transform) would refuse the dialect it was built to compile.
|
|
152
|
+
+// LoweredDiagnostics names those refusals among the diagnostics it is given;
|
|
153
|
+
+// the driver drops exactly the ones it names that it gave, and reports every
|
|
154
|
+
+// other diagnostic as it would without the plugin.
|
|
155
|
+
+type DiagnosticPlugin interface {
|
|
156
|
+
+ // LoweredDiagnostics returns the diagnostics, among those given, whose cause
|
|
157
|
+
+ // this plugin's ProgramPlugin removes. It reads the parse tree the checker
|
|
158
|
+
+ // judged, before any ProgramPlugin applies.
|
|
159
|
+
+ LoweredDiagnostics(*Program, PluginContext, []*ast.Diagnostic) []*ast.Diagnostic
|
|
160
|
+
+}
|
|
161
|
+
+
|
|
162
|
+
type linkedPluginState struct {
|
|
163
|
+
cwd string
|
|
164
|
+
declarations *pluginFileDeclarations
|
|
165
|
+
entries []PluginEntry
|
|
166
|
+
inputs *pluginHostInputScopes
|
|
167
|
+
+ outputs *pluginHostOutputs
|
|
168
|
+
tsconfig string
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@@ -895,6 +934,7 @@ func loadLinkedPluginState(cwd, tsconfigPath string) (linkedPluginState, error)
|
|
172
|
+
cwd: cwd,
|
|
173
|
+
declarations: newPluginFileDeclarations(),
|
|
174
|
+
inputs: newPluginHostInputScopes(),
|
|
175
|
+
+ outputs: newPluginHostOutputs(),
|
|
176
|
+
tsconfig: tsconfigPath,
|
|
177
|
+
}, nil
|
|
178
|
+
}
|
|
179
|
+
@@ -907,6 +947,7 @@ func loadLinkedPluginState(cwd, tsconfigPath string) (linkedPluginState, error)
|
|
180
|
+
declarations: newPluginFileDeclarations(),
|
|
181
|
+
entries: entries,
|
|
182
|
+
inputs: newPluginHostInputScopes(),
|
|
183
|
+
+ outputs: newPluginHostOutputs(),
|
|
184
|
+
tsconfig: tsconfigPath,
|
|
185
|
+
}, nil
|
|
186
|
+
}
|
|
187
|
+
@@ -991,6 +1032,46 @@ func (state linkedPluginState) emitTransforms() ([]PluginTransform, error) {
|
|
188
|
+
return out, nil
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
+// dropLoweredDiagnostics splits in into the diagnostics it keeps and the ones a
|
|
192
|
+
+// registered DiagnosticPlugin names as lowered, which it withdraws. Each plugin
|
|
193
|
+
+// is asked, in registration order, about what the plugins before it kept; a
|
|
194
|
+
+// diagnostic it names that it was not given is ignored, so a plugin can only
|
|
195
|
+
+// withdraw a diagnostic, never add one. An entry with no registration is
|
|
196
|
+
+// skipped here: apply reports it.
|
|
197
|
+
+func (state linkedPluginState) dropLoweredDiagnostics(prog *Program, in []*ast.Diagnostic) (kept, withdrawn []*ast.Diagnostic) {
|
|
198
|
+
+ kept = in
|
|
199
|
+
+ for index, entry := range state.entries {
|
|
200
|
+
+ if len(kept) == 0 {
|
|
201
|
+
+ break
|
|
202
|
+
+ }
|
|
203
|
+
+ plugin, ok := registeredPlugin(index)
|
|
204
|
+
+ if !ok {
|
|
205
|
+
+ continue
|
|
206
|
+
+ }
|
|
207
|
+
+ judge, ok := plugin.(DiagnosticPlugin)
|
|
208
|
+
+ if !ok {
|
|
209
|
+
+ continue
|
|
210
|
+
+ }
|
|
211
|
+
+ lowered := map[*ast.Diagnostic]struct{}{}
|
|
212
|
+
+ for _, diagnostic := range judge.LoweredDiagnostics(prog, state.contextAt(index, entry), kept) {
|
|
213
|
+
+ lowered[diagnostic] = struct{}{}
|
|
214
|
+
+ }
|
|
215
|
+
+ if len(lowered) == 0 {
|
|
216
|
+
+ continue
|
|
217
|
+
+ }
|
|
218
|
+
+ next := make([]*ast.Diagnostic, 0, len(kept))
|
|
219
|
+
+ for _, diagnostic := range kept {
|
|
220
|
+
+ if _, drop := lowered[diagnostic]; drop {
|
|
221
|
+
+ withdrawn = append(withdrawn, diagnostic)
|
|
222
|
+
+ } else {
|
|
223
|
+
+ next = append(next, diagnostic)
|
|
224
|
+
+ }
|
|
225
|
+
+ }
|
|
226
|
+
+ kept = next
|
|
227
|
+
+ }
|
|
228
|
+
+ return kept, withdrawn
|
|
229
|
+
+}
|
|
230
|
+
+
|
|
231
|
+
// registeredPlugin returns the plugin registered at position index, or
|
|
232
|
+
// (nil, false) when the index is out of range. Registration order matches
|
|
233
|
+
// the order of linked Go init() calls.
|
|
234
|
+
@@ -1028,7 +1109,43 @@ func (state linkedPluginState) contextAt(index int, entry PluginEntry) PluginCon
|
|
235
|
+
reportFileComplete: declaration.addComplete,
|
|
236
|
+
reportEveryFileComplete: declaration.completeEveryFile,
|
|
237
|
+
readEnvironment: state.inputs.readEnvironment,
|
|
238
|
+
+ reportHostOutput: state.outputs.add,
|
|
239
|
+
+ }
|
|
240
|
+
+}
|
|
241
|
+
+
|
|
242
|
+
+// pluginHostOutputs keeps the files linked plugins reported writing beside the
|
|
243
|
+
+// compiler's outputs in this generation (ReportHostOutput), each once, in the
|
|
244
|
+
+// order first reported.
|
|
245
|
+
+type pluginHostOutputs struct {
|
|
246
|
+
+ mu sync.Mutex
|
|
247
|
+
+ seen map[string]struct{}
|
|
248
|
+
+ files []string
|
|
249
|
+
+}
|
|
250
|
+
+
|
|
251
|
+
+func newPluginHostOutputs() *pluginHostOutputs {
|
|
252
|
+
+ return &pluginHostOutputs{seen: map[string]struct{}{}}
|
|
253
|
+
+}
|
|
254
|
+
+
|
|
255
|
+
+func (outputs *pluginHostOutputs) add(file string) {
|
|
256
|
+
+ if outputs == nil {
|
|
257
|
+
+ return
|
|
258
|
+
+ }
|
|
259
|
+
+ outputs.mu.Lock()
|
|
260
|
+
+ defer outputs.mu.Unlock()
|
|
261
|
+
+ if _, ok := outputs.seen[file]; ok {
|
|
262
|
+
+ return
|
|
263
|
+
+ }
|
|
264
|
+
+ outputs.seen[file] = struct{}{}
|
|
265
|
+
+ outputs.files = append(outputs.files, file)
|
|
266
|
+
+}
|
|
267
|
+
+
|
|
268
|
+
+func (outputs *pluginHostOutputs) list() []string {
|
|
269
|
+
+ if outputs == nil {
|
|
270
|
+
+ return nil
|
|
271
|
+
}
|
|
272
|
+
+ outputs.mu.Lock()
|
|
273
|
+
+ defer outputs.mu.Unlock()
|
|
274
|
+
+ return append([]string(nil), outputs.files...)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// hostInputs returns the exact native configuration inputs reported in this
|
|
278
|
+
diff --git a/driver/program.go b/driver/program.go
|
|
279
|
+
index 8dc486a3b147754fb30cb87ef1eb3ffccbbda780..7babe76685f9072efeeea184711339720e5faa68 100644
|
|
280
|
+
--- a/driver/program.go
|
|
281
|
+
+++ b/driver/program.go
|
|
282
|
+
@@ -801,6 +801,12 @@ func forceEmit(parsed *tsoptions.ParsedCommandLine) {
|
|
283
|
+
options := parsed.ParsedConfig.CompilerOptions
|
|
284
|
+
options.NoEmit = core.TSFalse
|
|
285
|
+
options.EmitDeclarationOnly = core.TSFalse
|
|
286
|
+
+ // Match the CLI's --emit override: TypeScript-extension imports must become
|
|
287
|
+
+ // JavaScript-extension imports when an analysis-only program is emitted,
|
|
288
|
+
+ // including private plugin traversals whose caller discards the output.
|
|
289
|
+
+ if options.AllowImportingTsExtensions.IsTrue() {
|
|
290
|
+
+ options.RewriteRelativeImportExtensions = core.TSTrue
|
|
291
|
+
+ }
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// forceNoEmit sets noEmit so the program type-checks without writing files.
|
|
295
|
+
@@ -1246,6 +1252,13 @@ func (p *Program) diagnostics(files []*ast.SourceFile) []Diagnostic {
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
raw = filterDiagnostics(raw)
|
|
299
|
+
+ // A linked DiagnosticPlugin withdraws the checker's refusals of the dialect
|
|
300
|
+
+ // its ProgramPlugin lowers. It asks about the tree the checker judged, which
|
|
301
|
+
+ // the hooks have not mutated yet on every lane that gates on diagnostics.
|
|
302
|
+
+ raw, withdrawn := p.plugins.dropLoweredDiagnostics(p, raw)
|
|
303
|
+
+ if err := p.recordWithdrawnDiagnostics(withdrawn); err != nil {
|
|
304
|
+
+ out = append(out, Diagnostic{Severity: SeverityError, Message: "driver: " + err.Error()})
|
|
305
|
+
+ }
|
|
306
|
+
// filterDiagnostics runs first because it resolves a node from the position
|
|
307
|
+
// tsgo recorded, which only makes sense against the tree tsgo parsed. The
|
|
308
|
+
// preamble correction happens inside convertProgramDiagnostics, once the
|
|
309
|
+
diff --git a/driver/rewrite.go b/driver/rewrite.go
|
|
310
|
+
index 79be74d24e879da216ad680d23ecfeb5f11a29db..6db9dddba05bd50e13ed92535ca442c3a4f0b28a 100644
|
|
311
|
+
--- a/driver/rewrite.go
|
|
312
|
+
+++ b/driver/rewrite.go
|
|
313
|
+
@@ -204,6 +204,9 @@ func (p *Program) EmitAllRaw(writeFile shimcompiler.WriteFile) (*shimcompiler.Em
|
|
314
|
+
result := p.emitProgram(shimcompiler.EmitOptions{
|
|
315
|
+
WriteFile: wf,
|
|
316
|
+
})
|
|
317
|
+
+ if err := p.listHostOutputs(result, writeFile); err != nil {
|
|
318
|
+
+ return result, p.convertProgramDiagnostics(result.Diagnostics), err
|
|
319
|
+
+ }
|
|
320
|
+
return result, p.convertProgramDiagnostics(result.Diagnostics), nil
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@@ -271,9 +274,52 @@ func (p *Program) emit(rs *RewriteSet, target *ast.SourceFile, writeFile shimcom
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
result := p.emitProgram(shimcompiler.TargetedEmitOptions(target, wf))
|
|
327
|
+
+ if target == nil {
|
|
328
|
+
+ if err := p.listHostOutputs(result, writeFile); err != nil {
|
|
329
|
+
+ return result, p.convertProgramDiagnostics(result.Diagnostics), err
|
|
330
|
+
+ }
|
|
331
|
+
+ }
|
|
332
|
+
return result, p.convertProgramDiagnostics(result.Diagnostics), nil
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
+// listHostOutputs hands the files linked plugins reported writing beside a
|
|
336
|
+
+// whole-program emit's outputs to writeFile and lists them among the result's
|
|
337
|
+
+// EmittedFiles, unless the emit wrote nothing (noEmit, or noEmitOnError
|
|
338
|
+
+// withholding a failed program).
|
|
339
|
+
+func (p *Program) listHostOutputs(result *shimcompiler.EmitResult, writeFile shimcompiler.WriteFile) error {
|
|
340
|
+
+ if result == nil || result.EmitSkipped || p.TSProgram.Options().NoEmit.IsTrue() {
|
|
341
|
+
+ return nil
|
|
342
|
+
+ }
|
|
343
|
+
+ handed, err := p.writeHostOutputs(writeFile)
|
|
344
|
+
+ result.EmittedFiles = append(result.EmittedFiles, handed...)
|
|
345
|
+
+ return err
|
|
346
|
+
+}
|
|
347
|
+
+
|
|
348
|
+
+// writeHostOutputs hands each file a linked plugin reported writing beside the
|
|
349
|
+
+// compiler's outputs (PluginContext.ReportHostOutput) to writeFile, with its
|
|
350
|
+
+// bytes as they are now, after the compiler's own outputs, so a host lists it
|
|
351
|
+
+// with them. It answers the files handed, and fails on one it cannot read: a
|
|
352
|
+
+// plugin reported an output it did not leave.
|
|
353
|
+
+func (p *Program) writeHostOutputs(writeFile shimcompiler.WriteFile) ([]string, error) {
|
|
354
|
+
+ var handed []string
|
|
355
|
+
+ for _, file := range p.plugins.outputs.list() {
|
|
356
|
+
+ text, err := os.ReadFile(file)
|
|
357
|
+
+ if err != nil {
|
|
358
|
+
+ return handed, fmt.Errorf("ttsc driver: a linked plugin reported the host output %s, which cannot be read: %w", file, err)
|
|
359
|
+
+ }
|
|
360
|
+
+ if writeFile != nil {
|
|
361
|
+
+ err = writeFile(shimtspath.RootedFilePathFromAbsolute(file), string(text), nil)
|
|
362
|
+
+ } else {
|
|
363
|
+
+ err = DefaultWriteFile(file, string(text))
|
|
364
|
+
+ }
|
|
365
|
+
+ if err != nil {
|
|
366
|
+
+ return handed, err
|
|
367
|
+
+ }
|
|
368
|
+
+ handed = append(handed, file)
|
|
369
|
+
+ }
|
|
370
|
+
+ return handed, nil
|
|
371
|
+
+}
|
|
372
|
+
+
|
|
373
|
+
// emitProgram runs one whole-program or single-file emit, taking tsgo's
|
|
374
|
+
// incremental lane when the resolved compiler options ask for build
|
|
375
|
+
// information.
|
|
376
|
+
@@ -317,22 +363,28 @@ func (p *Program) emitsBuildInfo() bool {
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// DefaultWriteFile is the default disk writer used when EmitAll's caller does not
|
|
380
|
+
-// supply a custom WriteFile callback. Existing files are normally truncated; a
|
|
381
|
+
-// watch child setting TTSC_WATCH_WRITE_IF_CHANGED=1 preserves byte-identical
|
|
382
|
+
-// regular output files instead. A failed write can leave partial output.
|
|
383
|
+
-// Requested creation modes are subject to the native platform and umask, and
|
|
384
|
+
-// do not replace existing file permissions.
|
|
385
|
+
+// supply a custom WriteFile callback. Existing files are normally truncated,
|
|
386
|
+
+// which a caller that finds stale outputs by file identity relies on: one that
|
|
387
|
+
+// removes each outDir file the emit did not touch (smoo's typescript-emit
|
|
388
|
+
+// executor through nx-plugin 0.7.9) would otherwise remove every unchanged
|
|
389
|
+
+// output. A watch child setting TTSC_WATCH_WRITE_IF_CHANGED=1, or a caller that
|
|
390
|
+
+// prunes its outDir by the emitted-file list and sets TTSC_WRITE_IF_CHANGED=1,
|
|
391
|
+
+// preserves byte-identical regular output files instead, inode and mtime
|
|
392
|
+
+// included: rewriting identical bytes is file churn every copy-on-write clone of
|
|
393
|
+
+// the output pays for. A failed write can leave partial output. Requested
|
|
394
|
+
+// creation modes are subject to the native platform and umask, and do not
|
|
395
|
+
+// replace existing file permissions.
|
|
396
|
+
//
|
|
397
|
+
-// @evidence contracts/common.md#principled-implementation The watch-only opt-in compares an existing writable regular output before deciding whether native writing is needed; all other writes use the original directory and file operations.
|
|
398
|
+
+// @evidence contracts/common.md#principled-implementation An opted-in emit compares an existing writable regular output before deciding whether native writing is needed; all other writes use the original directory and file operations.
|
|
399
|
+
// @evidence contracts/common.md#clear-and-simple-design One opt-in decision selects the unchanged-output check or the original writer.
|
|
400
|
+
// @evidence contracts/common.md#prohibited-implementation-shortcuts Native file identity and bytes decide whether to skip; unknown state falls back to the original writer and its errors.
|
|
401
|
+
-// @evidence contracts/common.md#meaningful-documentation Native prose states normal truncation, watch opt-in, partial failure and permission behavior.
|
|
402
|
+
+// @evidence contracts/common.md#meaningful-documentation Native prose states normal truncation, who relies on it, both opt-ins, partial failure and permission behavior.
|
|
403
|
+
// @evidence contracts/portability.md#os-neutral-implementation filepath.Dir, os.MkdirAll and os.WriteFile preserve native path and permission behavior; the optional check uses native file identity rather than path spelling.
|
|
404
|
+
-// @evidence contracts/performance.md#efficient-algorithms Normal writes retain one directory creation and file write. Watch writes add metadata and streamed comparison of up to the existing output size, then write only when content differs or safe comparison fails; no prior-output cache is retained.
|
|
405
|
+
+// @evidence contracts/performance.md#efficient-algorithms Normal writes retain one directory creation and file write. Opted-in writes add metadata and streamed comparison of up to the existing output size, then write only when content differs or safe comparison fails; no prior-output cache is retained.
|
|
406
|
+
// @evidenceExclude contracts/performance.md#reuse-equivalent-work Each emit write is requested independently; this writer owns no cross-emit reuse coordinator.
|
|
407
|
+
// @evidence contracts/performance.md#bound-retention-and-release-resources The optional comparison closes its one read/write handle before return or fallback; os.WriteFile owns and closes the later write handle. No output buffer or handle survives this call, while created directories and partial or completed files remain on disk.
|
|
408
|
+
func DefaultWriteFile(fileName, text string) error {
|
|
409
|
+
- return writeFileWithWatchMode(fileName, text, os.Getenv("TTSC_WATCH_WRITE_IF_CHANGED") == "1")
|
|
410
|
+
+ return writeFileWithWatchMode(fileName, text, os.Getenv("TTSC_WATCH_WRITE_IF_CHANGED") == "1" || os.Getenv("TTSC_WRITE_IF_CHANGED") == "1")
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
func defaultWriteFile(fileName, text string) error {
|
|
414
|
+
diff --git a/driver/withdrawn_diagnostics.go b/driver/withdrawn_diagnostics.go
|
|
415
|
+
new file mode 100644
|
|
416
|
+
index 0000000000000000000000000000000000000000..cccf3d0b7243a7a0574e6f9aa1f6fa1a0bf03a80
|
|
417
|
+
--- /dev/null
|
|
418
|
+
+++ b/driver/withdrawn_diagnostics.go
|
|
419
|
+
@@ -0,0 +1,50 @@
|
|
420
|
+
+package driver
|
|
421
|
+
+
|
|
422
|
+
+import (
|
|
423
|
+
+ "bytes"
|
|
424
|
+
+ "errors"
|
|
425
|
+
+ "fmt"
|
|
426
|
+
+ "os"
|
|
427
|
+
+ "path/filepath"
|
|
428
|
+
+
|
|
429
|
+
+ "github.com/microsoft/typescript-go/shim/ast"
|
|
430
|
+
+ shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
431
|
+
+)
|
|
432
|
+
+
|
|
433
|
+
+// WithdrawnDiagnosticsPathEnv names the file the driver records the
|
|
434
|
+
+// diagnostics its linked DiagnosticPlugins withdrew into. ttsc sets it for
|
|
435
|
+
+// every native plugin command it runs: when that command fails, ttsc checks the
|
|
436
|
+
+// project again with the stock compiler, which loads no plugin, and reports
|
|
437
|
+
+// only what the failed command did not print. A withdrawn diagnostic was never
|
|
438
|
+
+// printed, so without this record that pass would report it as an error.
|
|
439
|
+
+const WithdrawnDiagnosticsPathEnv = "TTSC_WITHDRAWN_DIAGNOSTICS_PATH"
|
|
440
|
+
+
|
|
441
|
+
+// recordWithdrawnDiagnostics appends withdrawn to the file
|
|
442
|
+
+// WithdrawnDiagnosticsPathEnv names, rendered as WritePrettyDiagnostics renders
|
|
443
|
+
+// the diagnostics a host prints, so ttsc reads both with one parser and compares
|
|
444
|
+
+// them by one identity. Every host computes its diagnostics through the
|
|
445
|
+
+// Program, so the record does not depend on how a host prints them. A pass
|
|
446
|
+
+// appends, so a host that asks for diagnostics more than once keeps every
|
|
447
|
+
+// withdrawal. It records nothing when the variable is unset or nothing was
|
|
448
|
+
+// withdrawn; an absent file records that nothing was. The path must be
|
|
449
|
+
+// absolute.
|
|
450
|
+
+func (p *Program) recordWithdrawnDiagnostics(withdrawn []*ast.Diagnostic) error {
|
|
451
|
+
+ path := os.Getenv(WithdrawnDiagnosticsPathEnv)
|
|
452
|
+
+ if path == "" || len(withdrawn) == 0 {
|
|
453
|
+
+ return nil
|
|
454
|
+
+ }
|
|
455
|
+
+ if !filepath.IsAbs(path) {
|
|
456
|
+
+ return fmt.Errorf("withdrawn diagnostics path must be absolute: %q", path)
|
|
457
|
+
+ }
|
|
458
|
+
+ var rendered bytes.Buffer
|
|
459
|
+
+ WritePrettyDiagnostics(&rendered, p.convertProgramDiagnostics(shimcompiler.SortAndDeduplicateDiagnostics(withdrawn)), p.TSProgram.GetCurrentDirectory())
|
|
460
|
+
+ file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600)
|
|
461
|
+
+ if err != nil {
|
|
462
|
+
+ return fmt.Errorf("withdrawn diagnostics: %w", err)
|
|
463
|
+
+ }
|
|
464
|
+
+ _, writeErr := file.Write(rendered.Bytes())
|
|
465
|
+
+ if err := errors.Join(writeErr, file.Close()); err != nil {
|
|
466
|
+
+ return fmt.Errorf("withdrawn diagnostics: %w", err)
|
|
467
|
+
+ }
|
|
468
|
+
+ return nil
|
|
469
|
+
+}
|
|
470
|
+
diff --git a/lib/compiler/internal/build/BuildExecution.js b/lib/compiler/internal/build/BuildExecution.js
|
|
471
|
+
index 9386a16e3c1f98c877f1bc3454b91d416cde9a63..f5f9f54e09eddecc5c06a00c998a6b98785bb702 100644
|
|
472
|
+
--- a/lib/compiler/internal/build/BuildExecution.js
|
|
473
|
+
+++ b/lib/compiler/internal/build/BuildExecution.js
|
|
474
|
+
@@ -352,7 +352,8 @@ var BuildExecution;
|
|
475
|
+
(0, assertSharedHostCompatibility_1.assertSharedHostCompatibility)(compilers, "emit");
|
|
476
|
+
const compiled = buildWithNativeCompilerPlugins(buildOptions, execution, compilers, timing);
|
|
477
|
+
const result = (0, appendBuildOutput_1.appendBuildOutput)(checked, compiled);
|
|
478
|
+
- return compiled.status === 0
|
|
479
|
+
+ return compiled.status === 0 ||
|
|
480
|
+
+ PluginFailureDiagnostics_1.PluginFailureDiagnostics.transformHostReported(compiled)
|
|
481
|
+
? result
|
|
482
|
+
: appendTypeScriptDiagnosticsAfterPluginFailure(result, buildOptions, execution);
|
|
483
|
+
}
|
|
484
|
+
@@ -366,7 +367,8 @@ var BuildExecution;
|
|
485
|
+
(0, assertSharedHostCompatibility_1.assertSharedHostCompatibility)(compilers, "emit");
|
|
486
|
+
const compiled = buildWithNativeCompilerPlugins(buildOptions, execution, compilers, timing);
|
|
487
|
+
result = (0, appendBuildOutput_1.appendBuildOutput)(checked, compiled);
|
|
488
|
+
- if (compiled.status !== 0) {
|
|
489
|
+
+ if (compiled.status !== 0 &&
|
|
490
|
+
+ !PluginFailureDiagnostics_1.PluginFailureDiagnostics.transformHostReported(compiled)) {
|
|
491
|
+
result = appendTypeScriptDiagnosticsAfterPluginFailure(result, buildOptions, execution);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
@@ -548,6 +550,13 @@ var BuildExecution;
|
|
495
|
+
* can propagate before that result merge. NoEmit prevents compiler emission,
|
|
496
|
+
* not unrelated native/cache effects or incremental metadata writes.
|
|
497
|
+
*
|
|
498
|
+
+ * The transform-host build sites skip this pass when the failed host printed
|
|
499
|
+
+ * error diagnostics of its own
|
|
500
|
+
+ * (`PluginFailureDiagnostics.transformHostReported`): that host already
|
|
501
|
+
+ * checked the build's Program, and this pass would check a different one,
|
|
502
|
+
+ * without linked plugins and with each referenced project read from its
|
|
503
|
+
+ * declaration outputs.
|
|
504
|
+
+ *
|
|
505
|
+
* @evidence contracts/common.md#principled-implementation An independent no-emit pass adds only unreported diagnostics, seeds an otherwise unstructured plugin failure when needed and restores the original failure status after output merging.
|
|
506
|
+
* @evidence contracts/common.md#clear-and-simple-design Recovery policy, compiler execution and diagnostic identity comparison are separate shared operations, with one result merge preserving the failed producer's ownership.
|
|
507
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The second pass addresses a supported failed-sidecar reporting gap; it never retries emission or converts the plugin failure into a successful build.
|
|
508
|
+
@@ -1051,16 +1060,22 @@ var BuildExecution;
|
|
509
|
+
cwd: execution.projectRoot,
|
|
510
|
+
env,
|
|
511
|
+
encoding: "utf8",
|
|
512
|
+
+ reportWithdrawnDiagnostics: true,
|
|
513
|
+
});
|
|
514
|
+
BuildTiming_1.BuildTiming.recordTiming(timing, timingLabel, startedAt);
|
|
515
|
+
if (res.error) {
|
|
516
|
+
throw new Error(`${label}: failed to spawn ${plugin.binary}: ${res.error.message}`);
|
|
517
|
+
}
|
|
518
|
+
+ // The host renders what its linked DiagnosticPlugins withdrew as it
|
|
519
|
+
+ // renders what it prints, so one parser reads both and the recovery
|
|
520
|
+
+ // pass after a failure compares them by one identity.
|
|
521
|
+
+ const withdrawnDiagnostics = (0, normalizeBuildOutput_1.parseCompilerDiagnostics)({ stderr: "", stdout: res.withdrawn }, execution.projectRoot);
|
|
522
|
+
return (0, normalizeBuildOutput_1.normalizeBuildOutput)({
|
|
523
|
+
processCompletedNormally: res.status !== null && res.signal === null,
|
|
524
|
+
status: res.status ?? 1,
|
|
525
|
+
stdout: (0, outputText_1.outputText)(res.stdout),
|
|
526
|
+
stderr: (0, outputText_1.outputText)(res.stderr),
|
|
527
|
+
+ ...(withdrawnDiagnostics.length === 0 ? {} : { withdrawnDiagnostics }),
|
|
528
|
+
}, execution.projectRoot);
|
|
529
|
+
}
|
|
530
|
+
BuildExecution.runNativePluginCommand = runNativePluginCommand;
|
|
531
|
+
diff --git a/lib/compiler/internal/build/CompilerDiagnostics.js b/lib/compiler/internal/build/CompilerDiagnostics.js
|
|
532
|
+
index 41017580431084dd18ae9e555d4ef32082714b38..3ddaba4ddd0942baa6fdbfc47fdb398b9d05150a 100644
|
|
533
|
+
--- a/lib/compiler/internal/build/CompilerDiagnostics.js
|
|
534
|
+
+++ b/lib/compiler/internal/build/CompilerDiagnostics.js
|
|
535
|
+
@@ -28,6 +28,9 @@ var CompilerDiagnostics;
|
|
536
|
+
(function (CompilerDiagnostics) {
|
|
537
|
+
/**
|
|
538
|
+
* Return fallback diagnostics the failed plugin did not already report.
|
|
539
|
+
+ * A diagnostic the failed run's linked DiagnosticPlugins withdrew
|
|
540
|
+
+ * (`failure.withdrawnDiagnostics`) counts as reported: the fallback loads no
|
|
541
|
+
+ * plugin, so it finds that diagnostic again, and it is not an error.
|
|
542
|
+
* Matching offsets take precedence only when both reports carry offsets;
|
|
543
|
+
* otherwise rendered line and column determine the position. A completely
|
|
544
|
+
* redundant fallback returns null. Partial filtering retains selected report
|
|
545
|
+
@@ -48,7 +51,9 @@ var CompilerDiagnostics;
|
|
546
|
+
if (typechecked.diagnostics.length === 0) {
|
|
547
|
+
return typechecked.status === 0 ? null : typechecked;
|
|
548
|
+
}
|
|
549
|
+
- const alreadyReported = indexCompilerDiagnostics(failure.diagnostics);
|
|
550
|
+
+ const alreadyReported = indexCompilerDiagnostics(failure.withdrawnDiagnostics === undefined
|
|
551
|
+
+ ? failure.diagnostics
|
|
552
|
+
+ : [...failure.diagnostics, ...failure.withdrawnDiagnostics]);
|
|
553
|
+
const diagnostics = typechecked.diagnostics.filter((diagnostic) => !alreadyReported(diagnostic));
|
|
554
|
+
if (diagnostics.length === 0)
|
|
555
|
+
return null;
|
|
556
|
+
diff --git a/lib/compiler/internal/build/PluginFailureDiagnostics.d.ts b/lib/compiler/internal/build/PluginFailureDiagnostics.d.ts
|
|
557
|
+
index 7e0c116b7d073a66ad643e8bd50ffe9773241c53..16b43ecf6a8d1f164442a02ac1500cae6e2fae67 100644
|
|
558
|
+
--- a/lib/compiler/internal/build/PluginFailureDiagnostics.d.ts
|
|
559
|
+
+++ b/lib/compiler/internal/build/PluginFailureDiagnostics.d.ts
|
|
560
|
+
@@ -30,6 +30,27 @@ export declare namespace PluginFailureDiagnostics {
|
|
561
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This predicate retains no option population, handle or task.
|
|
562
|
+
*/
|
|
563
|
+
function shouldCollect(options: RunBuildOptions): boolean;
|
|
564
|
+
+ /**
|
|
565
|
+
+ * Whether a failed transform host already reported the diagnostics of its
|
|
566
|
+
+ * Program. A transform host's `build` runs the project's diagnostics before
|
|
567
|
+
+ * it writes outputs, which is why a successful shared-host build has no
|
|
568
|
+
+ * separate TypeScript check. A host that printed an error diagnostic got that
|
|
569
|
+
+ * far, so the independent check could only add reports about another Program:
|
|
570
|
+
+ * a plain `tsgo --noEmit` loads no linked plugin and reads each referenced
|
|
571
|
+
+ * project's declaration outputs where the host read its sources. A host that
|
|
572
|
+
+ * printed no error diagnostic (a Go panic, a launch or load failure written
|
|
573
|
+
+ * as plain text) keeps the independent check.
|
|
574
|
+
+ *
|
|
575
|
+
+ * @evidence contracts/common.md#principled-implementation Only the failed host's own parsed error reports decide; check-stage results, warnings and unparsed process failures never suppress the independent check.
|
|
576
|
+
+ * @evidence contracts/common.md#clear-and-simple-design One predicate states when the build's own Program already answered, beside the mode gate it complements.
|
|
577
|
+
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No diagnostic code, plugin name or message text is inspected; the decision rests on the host's reported category alone.
|
|
578
|
+
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the build contract the predicate relies on and both outcomes.
|
|
579
|
+
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Parsed report categories are inspected without native paths, filesystem or process calls.
|
|
580
|
+
+ * @evidence contracts/performance.md#efficient-algorithms One short-circuit scan of the host's parsed diagnostics.
|
|
581
|
+
+ * @evidence contracts/performance.md#reuse-equivalent-work The host's completed Program diagnostics stand in for a second compiler run over a different Program.
|
|
582
|
+
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This predicate retains no diagnostic population, handle or task.
|
|
583
|
+
+ */
|
|
584
|
+
+ function transformHostReported(host: TtscBuildResult): boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Keep the original failure when no new diagnostic batch remains. Otherwise
|
|
587
|
+
* seed its unparsed process failure before the recovered reports and retain
|
|
588
|
+
diff --git a/lib/compiler/internal/build/PluginFailureDiagnostics.js b/lib/compiler/internal/build/PluginFailureDiagnostics.js
|
|
589
|
+
index d2863a9ea33d267630088412cc65e98953de4f2c..b7c954703c2c955e9b117756193edb94ddc495c3 100644
|
|
590
|
+
--- a/lib/compiler/internal/build/PluginFailureDiagnostics.js
|
|
591
|
+
+++ b/lib/compiler/internal/build/PluginFailureDiagnostics.js
|
|
592
|
+
@@ -40,6 +40,30 @@ var PluginFailureDiagnostics;
|
|
593
|
+
PassthroughFlags_1.PassthroughFlags.forwardsTerminalTsgoFlag(options));
|
|
594
|
+
}
|
|
595
|
+
PluginFailureDiagnostics.shouldCollect = shouldCollect;
|
|
596
|
+
+ /**
|
|
597
|
+
+ * Whether a failed transform host already reported the diagnostics of its
|
|
598
|
+
+ * Program. A transform host's `build` runs the project's diagnostics before
|
|
599
|
+
+ * it writes outputs, which is why a successful shared-host build has no
|
|
600
|
+
+ * separate TypeScript check. A host that printed an error diagnostic got that
|
|
601
|
+
+ * far, so the independent check could only add reports about another Program:
|
|
602
|
+
+ * a plain `tsgo --noEmit` loads no linked plugin and reads each referenced
|
|
603
|
+
+ * project's declaration outputs where the host read its sources. A host that
|
|
604
|
+
+ * printed no error diagnostic (a Go panic, a launch or load failure written
|
|
605
|
+
+ * as plain text) keeps the independent check.
|
|
606
|
+
+ *
|
|
607
|
+
+ * @evidence contracts/common.md#principled-implementation Only the failed host's own parsed error reports decide; check-stage results, warnings and unparsed process failures never suppress the independent check.
|
|
608
|
+
+ * @evidence contracts/common.md#clear-and-simple-design One predicate states when the build's own Program already answered, beside the mode gate it complements.
|
|
609
|
+
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No diagnostic code, plugin name or message text is inspected; the decision rests on the host's reported category alone.
|
|
610
|
+
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the build contract the predicate relies on and both outcomes.
|
|
611
|
+
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Parsed report categories are inspected without native paths, filesystem or process calls.
|
|
612
|
+
+ * @evidence contracts/performance.md#efficient-algorithms One short-circuit scan of the host's parsed diagnostics.
|
|
613
|
+
+ * @evidence contracts/performance.md#reuse-equivalent-work The host's completed Program diagnostics stand in for a second compiler run over a different Program.
|
|
614
|
+
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This predicate retains no diagnostic population, handle or task.
|
|
615
|
+
+ */
|
|
616
|
+
+ function transformHostReported(host) {
|
|
617
|
+
+ return host.diagnostics.some((diagnostic) => diagnostic.category === "error");
|
|
618
|
+
+ }
|
|
619
|
+
+ PluginFailureDiagnostics.transformHostReported = transformHostReported;
|
|
620
|
+
/**
|
|
621
|
+
* Keep the original failure when no new diagnostic batch remains. Otherwise
|
|
622
|
+
* seed its unparsed process failure before the recovered reports and retain
|
|
623
|
+
diff --git a/lib/compiler/internal/build/appendBuildOutput.js b/lib/compiler/internal/build/appendBuildOutput.js
|
|
624
|
+
index 96c8d4e6ed4dd92156bf28064055177277cfd2ff..435a311e174004eec0d110ba0919d1bb3e45a722 100644
|
|
625
|
+
--- a/lib/compiler/internal/build/appendBuildOutput.js
|
|
626
|
+
+++ b/lib/compiler/internal/build/appendBuildOutput.js
|
|
627
|
+
@@ -9,6 +9,8 @@ const normalizeBuildOutput_1 = require("./normalizeBuildOutput");
|
|
628
|
+
*
|
|
629
|
+
* - `status`: the right status wins unless it is 0 (failure propagates).
|
|
630
|
+
* - `diagnostics`: concatenated left then right.
|
|
631
|
+
+ * - `withdrawnDiagnostics`: concatenated left then right, present when either
|
|
632
|
+
+ * phase's host withdrew one.
|
|
633
|
+
* - `emittedFiles`: right wins when present, otherwise left is kept.
|
|
634
|
+
* - `emittedSources`: only the right phase's proof survives. An unknown later
|
|
635
|
+
* producer must not inherit an earlier phase's source ownership.
|
|
636
|
+
@@ -39,6 +41,15 @@ function appendBuildOutput(left, right) {
|
|
637
|
+
return (0, normalizeBuildOutput_1.normalizeBuildOutput)({
|
|
638
|
+
graph: mergeCheckGraphs(left.graph, right.graph),
|
|
639
|
+
diagnostics: [...left.diagnostics, ...right.diagnostics],
|
|
640
|
+
+ ...(left.withdrawnDiagnostics === undefined &&
|
|
641
|
+
+ right.withdrawnDiagnostics === undefined
|
|
642
|
+
+ ? {}
|
|
643
|
+
+ : {
|
|
644
|
+
+ withdrawnDiagnostics: [
|
|
645
|
+
+ ...(left.withdrawnDiagnostics ?? []),
|
|
646
|
+
+ ...(right.withdrawnDiagnostics ?? []),
|
|
647
|
+
+ ],
|
|
648
|
+
+ }),
|
|
649
|
+
emittedFiles: right.emittedFiles !== undefined ? right.emittedFiles : left.emittedFiles,
|
|
650
|
+
emittedSources: right.emittedSources,
|
|
651
|
+
emittedSourceProofFailures: right.emittedSourceProofFailures,
|
|
652
|
+
diff --git a/lib/compiler/internal/build/normalizeBuildOutput.js b/lib/compiler/internal/build/normalizeBuildOutput.js
|
|
653
|
+
index 889d79686b3b8a830e69695f8370e36d109e50b6..0fc1166d503630090b48ab54809d06d886d6a6c7 100644
|
|
654
|
+
--- a/lib/compiler/internal/build/normalizeBuildOutput.js
|
|
655
|
+
+++ b/lib/compiler/internal/build/normalizeBuildOutput.js
|
|
656
|
+
@@ -1,6 +1,7 @@
|
|
657
|
+
"use strict";
|
|
658
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
659
|
+
exports.normalizeBuildOutput = normalizeBuildOutput;
|
|
660
|
+
+exports.parseCompilerDiagnostics = parseCompilerDiagnostics;
|
|
661
|
+
const CompilerDiagnostics_1 = require("./CompilerDiagnostics");
|
|
662
|
+
/**
|
|
663
|
+
* Normalise a raw spawn result into a `TtscBuildResult`.
|
|
664
|
+
diff --git a/lib/compiler/internal/captureProcessOutput.js b/lib/compiler/internal/captureProcessOutput.js
|
|
665
|
+
index 06a4734a978facf210ffe4e5ce087d00a2b11412..b84d2a1ccde1ba107beebed987a477c42f9c4179 100644
|
|
666
|
+
--- a/lib/compiler/internal/captureProcessOutput.js
|
|
667
|
+
+++ b/lib/compiler/internal/captureProcessOutput.js
|
|
668
|
+
@@ -10,7 +10,9 @@ const createCanonicalTempDirectory_1 = require("../../internal/createCanonicalTe
|
|
669
|
+
const selectedRecordIdentityTempParent_1 = require("../../plugin/internal/source/selectedRecordIdentityTempParent");
|
|
670
|
+
const SidecarEnvironment_1 = require("./sharedHost/SidecarEnvironment");
|
|
671
|
+
/**
|
|
672
|
+
- * Acquire two private files and descriptors for a child's output.
|
|
673
|
+
+ * Acquire two private files and descriptors for a child's output, and a path in
|
|
674
|
+
+ * the same private directory where a native plugin host may record the
|
|
675
|
+
+ * diagnostics it withdrew (`readWithdrawn`).
|
|
676
|
+
*
|
|
677
|
+
* File descriptors avoid spawnSync's piped maxBuffer ceiling. Reading after
|
|
678
|
+
* exit still allocates complete output and is subject to filesystem, Buffer and
|
|
679
|
+
@@ -45,6 +47,7 @@ function captureProcessOutput(env = process.env) {
|
|
680
|
+
const directory = (0, createCanonicalTempDirectory_1.createCanonicalTempDirectory)("ttsc-spawn-", (0, selectedRecordIdentityTempParent_1.selectedRecordIdentityTempParent)(recordRoot));
|
|
681
|
+
const stdoutPath = node_path_1.default.join(directory, "stdout");
|
|
682
|
+
const stderrPath = node_path_1.default.join(directory, "stderr");
|
|
683
|
+
+ const withdrawnPath = node_path_1.default.join(directory, "withdrawn");
|
|
684
|
+
let stdoutFd;
|
|
685
|
+
try {
|
|
686
|
+
stdoutFd = node_fs_1.default.openSync(stdoutPath, "w+");
|
|
687
|
+
@@ -80,10 +83,22 @@ function captureProcessOutput(env = process.env) {
|
|
688
|
+
const raw = node_fs_1.default.readFileSync(location);
|
|
689
|
+
return encoding === "buffer" ? raw : raw.toString(encoding ?? "utf8");
|
|
690
|
+
},
|
|
691
|
+
+ /** What the child wrote at withdrawnPath, or "" when it wrote nothing. */
|
|
692
|
+
+ readWithdrawn() {
|
|
693
|
+
+ try {
|
|
694
|
+
+ return node_fs_1.default.readFileSync(withdrawnPath, "utf8");
|
|
695
|
+
+ }
|
|
696
|
+
+ catch (error) {
|
|
697
|
+
+ if (error.code === "ENOENT")
|
|
698
|
+
+ return "";
|
|
699
|
+
+ throw error;
|
|
700
|
+
+ }
|
|
701
|
+
+ },
|
|
702
|
+
stderrFd,
|
|
703
|
+
stderrPath,
|
|
704
|
+
stdoutFd,
|
|
705
|
+
stdoutPath,
|
|
706
|
+
+ withdrawnPath,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
/** Attempt closure without replacing the acquisition or process outcome. */
|
|
710
|
+
diff --git a/lib/compiler/internal/sharedHost/WITHDRAWN_DIAGNOSTICS_PATH_ENV.js b/lib/compiler/internal/sharedHost/WITHDRAWN_DIAGNOSTICS_PATH_ENV.js
|
|
711
|
+
new file mode 100644
|
|
712
|
+
index 0000000000000000000000000000000000000000..557e3eaf1e05ff7f9cb4d231699b4f7a91fcc345
|
|
713
|
+
--- /dev/null
|
|
714
|
+
+++ b/lib/compiler/internal/sharedHost/WITHDRAWN_DIAGNOSTICS_PATH_ENV.js
|
|
715
|
+
@@ -0,0 +1,12 @@
|
|
716
|
+
+"use strict";
|
|
717
|
+
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
718
|
+
+exports.WITHDRAWN_DIAGNOSTICS_PATH_ENV = void 0;
|
|
719
|
+
+/**
|
|
720
|
+
+ * Environment channel naming the file a native plugin host writes the
|
|
721
|
+
+ * diagnostics its linked DiagnosticPlugins withdrew into. Mirrors
|
|
722
|
+
+ * `driver.WithdrawnDiagnosticsPathEnv` on the Go side. A failed host's
|
|
723
|
+
+ * recovery pass checks the project with no plugin and finds those diagnostics
|
|
724
|
+
+ * again; this record is how it knows they are not errors.
|
|
725
|
+
+ */
|
|
726
|
+
+exports.WITHDRAWN_DIAGNOSTICS_PATH_ENV = "TTSC_WITHDRAWN_DIAGNOSTICS_PATH";
|
|
727
|
+
+//# sourceMappingURL=WITHDRAWN_DIAGNOSTICS_PATH_ENV.js.map
|
|
728
|
+
|
|
729
|
+
diff --git a/lib/compiler/internal/spawnNative.js b/lib/compiler/internal/spawnNative.js
|
|
730
|
+
index b347a08e9a843a5277bcd750f6acbd5d48b08d2e..cae5f80042583fbf5abd57bb54460ac5ef56f3a5 100644
|
|
731
|
+
--- a/lib/compiler/internal/spawnNative.js
|
|
732
|
+
+++ b/lib/compiler/internal/spawnNative.js
|
|
733
|
+
@@ -5,6 +5,8 @@ const isSpawnSyncFdExhaustion_1 = require("../../internal/isSpawnSyncFdExhaustio
|
|
734
|
+
const spawnSyncResilient_1 = require("../../internal/spawnSyncResilient");
|
|
735
|
+
const captureProcessOutput_1 = require("./captureProcessOutput");
|
|
736
|
+
const ensureExecutable_1 = require("./ensureExecutable");
|
|
737
|
+
+const SidecarEnvironment_1 = require("./sharedHost/SidecarEnvironment");
|
|
738
|
+
+const WITHDRAWN_DIAGNOSTICS_PATH_ENV_1 = require("./sharedHost/WITHDRAWN_DIAGNOSTICS_PATH_ENV");
|
|
739
|
+
/**
|
|
740
|
+
* Spawn a native binary (or a Node.js script when the path has a JS/TS
|
|
741
|
+
* extension) and return its result with decoded or raw-buffer output streams.
|
|
742
|
+
@@ -20,6 +22,12 @@ const ensureExecutable_1 = require("./ensureExecutable");
|
|
743
|
+
* When `options.encoding` is omitted it defaults to `"utf8"`. Pass `"buffer"`
|
|
744
|
+
* when the caller needs raw bytes.
|
|
745
|
+
*
|
|
746
|
+
+ * With `options.reportWithdrawnDiagnostics`, the child's environment names a
|
|
747
|
+
+ * private file for the diagnostics its linked DiagnosticPlugins withdrew
|
|
748
|
+
+ * (`WITHDRAWN_DIAGNOSTICS_PATH_ENV`), and the result's `withdrawn` holds what
|
|
749
|
+
+ * it wrote there as UTF-8 text, "" when it wrote nothing. The pipe lane never
|
|
750
|
+
+ * takes such a call: native plugin commands always capture to files.
|
|
751
|
+
+ *
|
|
752
|
+
* @evidence contracts/common.md#principled-implementation Executable plus argv are passed directly to Node spawning; script candidates instead pass their path to process.execPath, and file-backed or unbounded piped output reconstructs the normal stdout/stderr/output result fields. Pipes are used only when the caller states the command starts no descendant that could hold them open.
|
|
753
|
+
* @evidence contracts/common.md#clear-and-simple-design This operation owns synchronous execution and capture lifetime; permission preparation, low-descriptor recovery and byte decoding remain explicit delegated boundaries.
|
|
754
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No shell parses argv or foreign process API is replaced. Descriptor recovery is selected by the real resource-exhaustion contract in spawnSyncResilient rather than a fixture outcome.
|
|
755
|
+
@@ -69,9 +77,14 @@ function spawnNative(binary, args, options) {
|
|
756
|
+
}
|
|
757
|
+
const capture = (0, captureProcessOutput_1.captureProcessOutput)();
|
|
758
|
+
try {
|
|
759
|
+
+ let env = options.env;
|
|
760
|
+
+ if (options.reportWithdrawnDiagnostics === true) {
|
|
761
|
+
+ env = SidecarEnvironment_1.SidecarEnvironment.merge(options.env ?? process.env);
|
|
762
|
+
+ SidecarEnvironment_1.SidecarEnvironment.write(env, WITHDRAWN_DIAGNOSTICS_PATH_ENV_1.WITHDRAWN_DIAGNOSTICS_PATH_ENV, capture.withdrawnPath);
|
|
763
|
+
+ }
|
|
764
|
+
const result = (0, spawnSyncResilient_1.spawnSyncResilient)(viaNode ? process.execPath : binary, viaNode ? [binary, ...args] : [...args], {
|
|
765
|
+
cwd: options.cwd,
|
|
766
|
+
- env: options.env,
|
|
767
|
+
+ env,
|
|
768
|
+
stdio: ["ignore", capture.stdoutFd, capture.stderrFd],
|
|
769
|
+
windowsHide: true,
|
|
770
|
+
}, { stderr: capture.stderrPath, stdout: capture.stdoutPath });
|
|
771
|
+
@@ -82,6 +95,9 @@ function spawnNative(binary, args, options) {
|
|
772
|
+
output: [null, stdout, stderr],
|
|
773
|
+
stderr,
|
|
774
|
+
stdout,
|
|
775
|
+
+ ...(options.reportWithdrawnDiagnostics === true
|
|
776
|
+
+ ? { withdrawn: capture.readWithdrawn() }
|
|
777
|
+
+ : {}),
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
finally {
|
|
781
|
+
diff --git a/lib/internal/javascriptRuntimeCapabilities.js b/lib/internal/javascriptRuntimeCapabilities.js
|
|
782
|
+
index 53dc81d7ae8b6eac246306ad8f94b01f2594689a..d6ad694d69deca3661f5b89b491a48f282b34d42 100644
|
|
783
|
+
--- a/lib/internal/javascriptRuntimeCapabilities.js
|
|
784
|
+
+++ b/lib/internal/javascriptRuntimeCapabilities.js
|
|
785
|
+
@@ -43,6 +43,19 @@ const spawnSyncWithLowDescriptors_1 = require("./spawnSyncWithLowDescriptors");
|
|
786
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources The synchronous probe owns child completion and fallback captures; finally attempts capture close/removal, whose helper suppresses cleanup failures, so native/file release is unconfirmed on failure. Capability entries retain absolute spellings and path/identity text with no eviction quota; failed identity validation can remove an entry. Returned capability copies transfer to callers.
|
|
787
|
+
*/
|
|
788
|
+
function javascriptRuntimeCapabilities(runtime, env, cwd, identities) {
|
|
789
|
+
+ // The running process answers for itself. Under Bun, process.execPath names
|
|
790
|
+
+ // Bun (pluginDescriptorRuntimeBinary), and a probe of it can fail for reasons
|
|
791
|
+
+ // that say nothing about the executable: its 30 s timeout under load, or a
|
|
792
|
+
+ // spawn the host refused. Read as "not Bun", that failure handed Bun Node's
|
|
793
|
+
+ // `--input-type ""`, which Bun runs as an empty `bun run` script, so the
|
|
794
|
+
+ // plugin descriptor produced no output. This process knows what it is.
|
|
795
|
+
+ if (node_path_1.default.isAbsolute(runtime) && sameRuntimeExecutable(runtime, process.execPath)) {
|
|
796
|
+
+ return {
|
|
797
|
+
+ bun: typeof globalThis.Bun === "object",
|
|
798
|
+
+ executable: process.execPath,
|
|
799
|
+
+ registerHooks: typeof require("node:module").registerHooks === "function",
|
|
800
|
+
+ };
|
|
801
|
+
+ }
|
|
802
|
+
// Inside a ttsx run this is the user's NODE_OPTIONS, not ttsx's preloads,
|
|
803
|
+
// which would refuse the cache and run in the probe (#1740).
|
|
804
|
+
const effectiveEnv = TtsxNodeOptions_1.TtsxNodeOptions.forHelpers(SidecarEnvironment_1.SidecarEnvironment.merge(process.env, env));
|
|
805
|
+
diff --git a/lib/plugin/internal/source/GoSourceInputs.js b/lib/plugin/internal/source/GoSourceInputs.js
|
|
806
|
+
index 6bf30f65eb6f046eb2b9d505f6838b330a444df4..abc3485a35c4e380dc6e4c07fbacf2553ff2e21a 100644
|
|
807
|
+
--- a/lib/plugin/internal/source/GoSourceInputs.js
|
|
808
|
+
+++ b/lib/plugin/internal/source/GoSourceInputs.js
|
|
809
|
+
@@ -73,6 +73,16 @@ var GoSourceInputs;
|
|
810
|
+
function goBuildEnv(goBinary, goBuildCacheRoot, effectiveEnv = process.env) {
|
|
811
|
+
const env = { ...effectiveEnv };
|
|
812
|
+
env.GOWORK = "auto";
|
|
813
|
+
+ // GOWORK=auto puts go in workspace mode wherever a go.work lies (typia's
|
|
814
|
+
+ // native plugin ships one), where go accepts only -mod=readonly or
|
|
815
|
+
+ // -mod=vendor. A caller's GOFLAGS -mod=mod, a host shell's say, failed
|
|
816
|
+
+ // every invocation; ttsc owns the workspace, so it drops that flag and
|
|
817
|
+
+ // keeps the caller's others.
|
|
818
|
+
+ if (env.GOFLAGS) {
|
|
819
|
+
+ env.GOFLAGS = env.GOFLAGS.split(/\s+/)
|
|
820
|
+
+ .filter((flag) => flag !== "" && !/^--?mod=/.test(flag))
|
|
821
|
+
+ .join(" ");
|
|
822
|
+
+ }
|
|
823
|
+
// Only the actual `go build` needs ttsc's GOCACHE; read-only metadata spawns
|
|
824
|
+
// (`go mod edit`, `go env`, `go version`) call goBuildEnv with no cache root
|
|
825
|
+
// and inherit ambient GOCACHE rather than receiving the managed build
|
|
826
|
+
diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
827
|
+
index da585c3ce22340d4a7d3c2b2793ae5c951958372..63c842daefa4c15cbc17b778dd382ac038eed69a 100644
|
|
828
|
+
--- a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
829
|
+
+++ b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
830
|
+
@@ -20,10 +20,10 @@ const pluginBuildEnvironment_1 = require("./pluginBuildEnvironment");
|
|
831
|
+
* Cold asynchronous reads run in an exclusively owned worker. Its complete
|
|
832
|
+
* environment snapshot is passed explicitly to the native reader. Publication
|
|
833
|
+
* rechecks both current host variables and external witnesses after transfer.
|
|
834
|
+
- * The worker reads the parent's shared environment for native fallback rules;
|
|
835
|
+
- * neither it nor this owner writes that environment. Explicit reader inputs
|
|
836
|
+
- * still use the request snapshot and publication still qualifies that
|
|
837
|
+
- * snapshot.
|
|
838
|
+
+ * The worker keeps the environment copy it started with, never SHARE_ENV:
|
|
839
|
+
+ * Bun replaces the parent's process.env object for SHARE_ENV, stranding every
|
|
840
|
+
+ * module that captured the old one (node:os tmpdir() among them). Explicit
|
|
841
|
+
+ * reader inputs use the request snapshot, which publication qualifies.
|
|
842
|
+
*
|
|
843
|
+
* @evidence contracts/common.md#principled-implementation Readings pair complete environment identity with the producer's native pre-read witness; cached reuse validates that witness and asynchronous publication rechecks variables/witness after transfer. Synchronous fresh reads publish their paired observations without an extra post-read holds call here; native metadata distinguishability remains a premise.
|
|
844
|
+
* @evidence contracts/common.md#clear-and-simple-design One owner shares observation records across synchronous reads, cache-only proof and asynchronous preparation.
|
|
845
|
+
@@ -253,7 +253,7 @@ var PluginBuildEnvironmentReadings;
|
|
846
|
+
function acquireWorker() {
|
|
847
|
+
if (worker !== undefined)
|
|
848
|
+
return worker;
|
|
849
|
+
- const created = new node_worker_threads_1.Worker((0, workerModuleUrl_1.workerModuleUrl)(node_path_1.default.join(__dirname, `pluginBuildEnvironmentWorker${node_path_1.default.extname(__filename)}`)), { env: node_worker_threads_1.SHARE_ENV });
|
|
850
|
+
+ const created = new node_worker_threads_1.Worker((0, workerModuleUrl_1.workerModuleUrl)(node_path_1.default.join(__dirname, `pluginBuildEnvironmentWorker${node_path_1.default.extname(__filename)}`)), {});
|
|
851
|
+
worker = created;
|
|
852
|
+
const retire = () => {
|
|
853
|
+
if (worker === created)
|
|
854
|
+
diff --git a/lib/plugin/internal/source/collectPluginSourceFiles.d.ts b/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
|
|
855
|
+
index bd872710a248aa9bd2dbd0c9bc59f89d9b60970c..46184064f7ba45602b03e99db69291bbbe522675 100644
|
|
856
|
+
--- a/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
|
|
857
|
+
+++ b/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
|
|
858
|
+
@@ -21,7 +21,11 @@
|
|
859
|
+
* A link (a symbolic link or a Windows junction) outside those directories is
|
|
860
|
+
* refused rather than skipped. The build would compile what it names, which
|
|
861
|
+
* neither this list nor anything keyed on it covers; a Go module zip excludes
|
|
862
|
+
- * links from a module's content for the same reason.
|
|
863
|
+
+ * links from a module's content for the same reason. A link at or below a name
|
|
864
|
+
+ * the go tool passes over (one beginning with `.` or `_`, or `testdata`; `go
|
|
865
|
+
+ * help packages`) is skipped like one in an excluded directory: Go neither
|
|
866
|
+
+ * compiles it nor embeds a link. Tools keep links there, as cowshed does for a
|
|
867
|
+
+ * package's `.cache/lmao`, and refusing one cost the module its source identity.
|
|
868
|
+
*
|
|
869
|
+
* A caller that keeps the population as a listing (`IPluginSourceListing`)
|
|
870
|
+
* passes `visit`, which sees each directory the walk lists just before its
|
|
871
|
+
diff --git a/lib/plugin/internal/source/collectPluginSourceFiles.js b/lib/plugin/internal/source/collectPluginSourceFiles.js
|
|
872
|
+
index 22ef5cb14a41ddea0ec480c45c4c8806cfc7c4af..e6aae920c3c6fc897b2953d25d38f3c3c4fa2d29 100644
|
|
873
|
+
--- a/lib/plugin/internal/source/collectPluginSourceFiles.js
|
|
874
|
+
+++ b/lib/plugin/internal/source/collectPluginSourceFiles.js
|
|
875
|
+
@@ -30,7 +30,11 @@ const GoSourceInputs_1 = require("./GoSourceInputs");
|
|
876
|
+
* A link (a symbolic link or a Windows junction) outside those directories is
|
|
877
|
+
* refused rather than skipped. The build would compile what it names, which
|
|
878
|
+
* neither this list nor anything keyed on it covers; a Go module zip excludes
|
|
879
|
+
- * links from a module's content for the same reason.
|
|
880
|
+
+ * links from a module's content for the same reason. A link at or below a name
|
|
881
|
+
+ * the go tool passes over (one beginning with `.` or `_`, or `testdata`; `go
|
|
882
|
+
+ * help packages`) is skipped like one in an excluded directory: Go neither
|
|
883
|
+
+ * compiles it nor embeds a link. Tools keep links there, as cowshed does for a
|
|
884
|
+
+ * package's `.cache/lmao`, and refusing one cost the module its source identity.
|
|
885
|
+
*
|
|
886
|
+
* A caller that keeps the population as a listing (`IPluginSourceListing`)
|
|
887
|
+
* passes `visit`, which sees each directory the walk lists just before its
|
|
888
|
+
@@ -79,7 +83,8 @@ function walk(root, dir, out, visit) {
|
|
889
|
+
// list, the key, nor a watch covers, and a copy of the module cannot
|
|
890
|
+
// recreate a link without the symlink privilege on Windows.
|
|
891
|
+
if (GoSourceInputs_1.GoSourceInputs.shouldPruneDirectory(entry.name) ||
|
|
892
|
+
- GoSourceInputs_1.GoSourceInputs.shouldOmitSourceFile(entry.name))
|
|
893
|
+
+ GoSourceInputs_1.GoSourceInputs.shouldOmitSourceFile(entry.name) ||
|
|
894
|
+
+ goToolIgnores(root, full))
|
|
895
|
+
continue;
|
|
896
|
+
throw new Error(`ttsc: plugin source ${root} contains a link at ${full}. A plugin's Go ` +
|
|
897
|
+
`sources are its own files, as a Go module zip holds them: replace the ` +
|
|
898
|
+
@@ -99,4 +104,15 @@ function walk(root, dir, out, visit) {
|
|
899
|
+
out.push(full);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
+/**
|
|
903
|
+
+ * Whether the go tool passes over `full`: it ignores every directory and file
|
|
904
|
+
+ * whose name begins with "." or "_", and directories named "testdata" (`go help
|
|
905
|
+
+ * packages`), so nothing at or below such a name is compiled.
|
|
906
|
+
+ */
|
|
907
|
+
+function goToolIgnores(root, full) {
|
|
908
|
+
+ return node_path_1.default
|
|
909
|
+
+ .relative(root, full)
|
|
910
|
+
+ .split(node_path_1.default.sep)
|
|
911
|
+
+ .some((name) => name.startsWith(".") || name.startsWith("_") || name === "testdata");
|
|
912
|
+
+}
|
|
913
|
+
//# sourceMappingURL=collectPluginSourceFiles.js.map
|
|
914
|
+
|
|
915
|
+
diff --git a/lib/plugin/internal/source/inspectPluginBuildLock.js b/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
916
|
+
index 1d9fba4c59143dc68efff3dba52499121f727b66..63d7ba0a344119dad76df5fdc2477c69dccb7ba9 100644
|
|
917
|
+
--- a/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
918
|
+
+++ b/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
919
|
+
@@ -65,9 +65,16 @@ function inspectPluginBuildLock(lockDir) {
|
|
920
|
+
const PLUGIN_BUILD_LOCK_OBSERVER = node_crypto_1.default.randomBytes(16).toString("hex");
|
|
921
|
+
function inspectV3PluginBuildLock(lockDir) {
|
|
922
|
+
const generationDir = node_path_1.default.join(lockDir, PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_CURRENT_DIR);
|
|
923
|
+
+ // `current` changes only by whole-directory renames: a holder retires it
|
|
924
|
+
+ // onto its tombstone, and the next holder publishes a directory that
|
|
925
|
+
+ // already holds its generation. A read that finds no valid generation
|
|
926
|
+
+ // proves the lock malformed only when the same directory was `current`
|
|
927
|
+
+ // before and after it. Otherwise the read straddled a handoff of the key,
|
|
928
|
+
+ // and a handoff is a release: the caller observes the key again.
|
|
929
|
+
+ const observed = pluginBuildLockDirectoryIdentity(generationDir);
|
|
930
|
+
const generation = readPluginBuildLockGeneration(generationDir);
|
|
931
|
+
if (generation === null) {
|
|
932
|
+
- if (pluginBuildLockPathMissing(generationDir)) {
|
|
933
|
+
+ if (observed === null || observed !== pluginBuildLockDirectoryIdentity(generationDir)) {
|
|
934
|
+
return { state: "released" };
|
|
935
|
+
}
|
|
936
|
+
throw new Error(`ttsc plugin build lock has no valid ${PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_GENERATION_FILE}: ${generationDir}`);
|
|
937
|
+
@@ -269,6 +276,22 @@ function readPluginBuildLockGeneration(generationDir) {
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
+/**
|
|
942
|
+
+ * The device and inode of a lock directory, or null when a lookup proves it
|
|
943
|
+
+ * absent. A permission or sharing failure proves nothing and propagates.
|
|
944
|
+
+ */
|
|
945
|
+
+function pluginBuildLockDirectoryIdentity(directory) {
|
|
946
|
+
+ try {
|
|
947
|
+
+ const stat = node_fs_1.default.statSync(directory, { bigint: true });
|
|
948
|
+
+ return `${stat.dev}:${stat.ino}`;
|
|
949
|
+
+ }
|
|
950
|
+
+ catch (error) {
|
|
951
|
+
+ if (PluginBuildLockProtocol_1.PluginBuildLockProtocol.isMissingPathError(error)) {
|
|
952
|
+
+ return null;
|
|
953
|
+
+ }
|
|
954
|
+
+ throw error;
|
|
955
|
+
+ }
|
|
956
|
+
+}
|
|
957
|
+
/**
|
|
958
|
+
* Whether a path lookup proves absence. Permission and sharing failures are
|
|
959
|
+
* inconclusive, never evidence of a released or old abandoned generation.
|
|
960
|
+
diff --git a/lib/plugin/internal/source/waitForPluginBinary.js b/lib/plugin/internal/source/waitForPluginBinary.js
|
|
961
|
+
index 191b99ea9f36da615f82f921d40c185a56737bbd..a741af5a3e5d401f1827d896774d89bf7e2bd0c5 100644
|
|
962
|
+
--- a/lib/plugin/internal/source/waitForPluginBinary.js
|
|
963
|
+
+++ b/lib/plugin/internal/source/waitForPluginBinary.js
|
|
964
|
+
@@ -25,6 +25,12 @@ const inspectPluginBuildLock_1 = require("./inspectPluginBuildLock");
|
|
965
|
+
* run. An opted-in synchronous owner can cancel observation or interrupt a
|
|
966
|
+
* polling sleep; cancellation never retires the holder's generation.
|
|
967
|
+
*
|
|
968
|
+
+ * A published binary is not admission: the caller registers as its reader
|
|
969
|
+
+ * under the key, which only release or retirement frees. Each poll therefore
|
|
970
|
+
+ * inspects the lock before it reports publication, so a holder that died
|
|
971
|
+
+ * holding the key after its binary was published is reported abandoned
|
|
972
|
+
+ * instead of outwaiting the admission budget.
|
|
973
|
+
+ *
|
|
974
|
+
* @evidence contracts/common.md#principled-implementation Polling first refuses unknown/malformed native guards, suppresses publication while pending and rechecks after observed release; actual abandoned-owner observations retain their exact generation, while budget expiry fails without revoking a possibly active payload task.
|
|
975
|
+
* @evidence contracts/common.md#clear-and-simple-design The loop separates publication, release, retirement and periodic status reporting; generation interpretation belongs to inspectPluginBuildLock.
|
|
976
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Budget expiry throws instead of retiring a live-looking generation and compensating for concurrent callbacks; status output never substitutes for ownership evidence.
|
|
977
|
+
@@ -43,22 +49,9 @@ function waitForPluginBinary(opts) {
|
|
978
|
+
OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
|
|
979
|
+
SourceNativeRetirement_1.SourceNativeRetirement.assertAvailable(protocolDir);
|
|
980
|
+
const protectedNativeInputs = SourceNativeRetirement_1.SourceNativeRetirement.isProtected(protocolDir);
|
|
981
|
+
- if (!protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)) {
|
|
982
|
+
- OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
|
|
983
|
+
- return { outcome: "published" };
|
|
984
|
+
- }
|
|
985
|
+
const clock = performance.now();
|
|
986
|
+
const lock = (0, inspectPluginBuildLock_1.inspectPluginBuildLock)(opts.lockDir);
|
|
987
|
+
OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
|
|
988
|
+
- if (lock.state === "released") {
|
|
989
|
+
- // The holder retired its generation between the binary check above and
|
|
990
|
+
- // this observation. That is a normal release, not abandonment: prefer the
|
|
991
|
+
- // binary when it landed inside that window, otherwise hand the free key
|
|
992
|
+
- // back to the caller.
|
|
993
|
+
- return !protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)
|
|
994
|
+
- ? { outcome: "published" }
|
|
995
|
+
- : { outcome: "released" };
|
|
996
|
+
- }
|
|
997
|
+
if (lock.state === "abandoned") {
|
|
998
|
+
return {
|
|
999
|
+
outcome: "abandoned",
|
|
1000
|
+
@@ -66,6 +59,12 @@ function waitForPluginBinary(opts) {
|
|
1001
|
+
fence: lock.fence,
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
+ if (!protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)) {
|
|
1005
|
+
+ return { outcome: "published" };
|
|
1006
|
+
+ }
|
|
1007
|
+
+ if (lock.state === "released") {
|
|
1008
|
+
+ return { outcome: "released" };
|
|
1009
|
+
+ }
|
|
1010
|
+
if (clock - startedAt >= opts.timeoutMs) {
|
|
1011
|
+
throw new Error(`ttsc: timed out after ${(0, formatDuration_1.formatDuration)(clock - startedAt)} waiting for ` +
|
|
1012
|
+
`${opts.lockInfo.label} "${opts.lockInfo.pluginName}" at ${opts.lockDir}; ` +
|
|
1013
|
+
diff --git a/utility/host.go b/utility/host.go
|
|
1014
|
+
index ce42de43a7fab2d28b3a50529a88c21a988d0d0d..dcd04ca94c0900896b0e1bc04e9ed53e7da47b65 100644
|
|
1015
|
+
--- a/utility/host.go
|
|
1016
|
+
+++ b/utility/host.go
|
|
1017
|
+
@@ -7,6 +7,7 @@ import (
|
|
1018
|
+
"io"
|
|
1019
|
+
"os"
|
|
1020
|
+
"path/filepath"
|
|
1021
|
+
+ "sort"
|
|
1022
|
+
"strings"
|
|
1023
|
+
|
|
1024
|
+
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
1025
|
+
@@ -260,7 +261,10 @@ func RunBuildWithIO(args []string, stdout, stderr io.Writer) int {
|
|
1026
|
+
opts.quiet = false // --verbose overrides the default --quiet=true
|
|
1027
|
+
}
|
|
1028
|
+
if !opts.quiet {
|
|
1029
|
+
- fmt.Fprintf(opts.stdout, "// ttsc utility: plugins=%d emit=%v\n", len(entries), !opts.noEmit)
|
|
1030
|
+
+ // The header and the " + <path>" list below are the summary shape ttsc's
|
|
1031
|
+
+ // build lane (cmd/ttsc/build.go) and ttsc-typia print, so a caller that
|
|
1032
|
+
+ // reads the emitted files from --verbose reads this lane the same way.
|
|
1033
|
+
+ fmt.Fprintf(opts.stdout, "// ttsc utility: tsconfig=%s cwd=%s emit=%v plugins=%d\n", opts.tsconfig, opts.cwd, !opts.noEmit, len(entries))
|
|
1034
|
+
}
|
|
1035
|
+
writeFile, finishPreamble := makeSourcePreambleWriteFile(prog)
|
|
1036
|
+
var snapshot func() map[string][]string
|
|
1037
|
+
@@ -310,6 +314,18 @@ func RunBuildWithIO(args []string, stdout, stderr io.Writer) int {
|
|
1038
|
+
}
|
|
1039
|
+
if !opts.quiet {
|
|
1040
|
+
fmt.Fprintf(opts.stdout, "// ttsc utility: emitted=%d files\n", len(emittedFiles))
|
|
1041
|
+
+ listed := make([]string, 0, len(emittedFiles))
|
|
1042
|
+
+ for fileName := range emittedFiles {
|
|
1043
|
+
+ listed = append(listed, fileName)
|
|
1044
|
+
+ }
|
|
1045
|
+
+ sort.Strings(listed)
|
|
1046
|
+
+ for _, fileName := range listed {
|
|
1047
|
+
+ rel := fileName
|
|
1048
|
+
+ if relative, err := filepath.Rel(opts.cwd, fileName); err == nil {
|
|
1049
|
+
+ rel = relative
|
|
1050
|
+
+ }
|
|
1051
|
+
+ fmt.Fprintln(opts.stdout, " +", rel)
|
|
1052
|
+
+ }
|
|
1053
|
+
driver.WriteEnvironmentInputsSummary(opts.stdout, "// ttsc utility: ", prog)
|
|
1054
|
+
}
|
|
1055
|
+
return 0
|