Repository navigation
Commit 827be16
Replace lib/bs and lib/ocaml with a flat lib/rescript (#9245)
* Write each package's build artifacts flat to lib/rescript
Why:
Every artifact existed in lib/bs, nested like the sources, and again in
lib/ocaml, flat, and lib/bs also held copies of the sources and the
generated JavaScript (#9151). The build now writes one flat lib/rescript.
Layout modified (artifact directory of a package):
Before (text):
lib/bs/src/A.ast lib/bs/src/A.cmi lib/bs/src/A.res lib/bs/src/A.js
lib/bs/.compiler.log lib/bs/compiler-info.json lib/bs/.sourcedirs.json
lib/bs/build.ninja
lib/ocaml/A.ast lib/ocaml/A.cmi lib/ocaml/A.cmj lib/ocaml/A.cmt lib/ocaml/A.res
lib/build.lock lib/watch.lock
After (text):
lib/rescript/A.ast lib/rescript/A.cmi lib/rescript/A.cmj lib/rescript/A.cmt
lib/rescript/.compiler.log lib/rescript/compiler-info.json lib/rescript/.sourcedirs.json
lib/rescript/build.lock lib/rescript/watch.lock
Before (text): bsc runs in lib/bs with -I ../ocaml; the stdlib is <runtime>/lib/ocaml
After (text): bsc runs in lib/rescript with -I .; the stdlib is <runtime>/lib/rescript
Publication modified (a compiled module's ASTs, interface and typed tree):
Before (text): written to lib/bs by bsc, then copied to lib/ocaml
After (text):
held in the build file store until the request succeeded, then
1. the interface, only when it changed
2. the typed tree, which marks the module compiled
each renamed into place, or written in place when the rename fails
a failed compile: interface forgotten, AST dated back, partial typed tree published
Freshness modified (Build_freshness, Compiler_info, namespace maps):
Before (representation):
source removed or must be parsed again ↦ AST removed
no compiler-info.json, lib/ocaml/.compiler.log exists ↦ clean
Ns.mlmap changed or Ns outputs missing ↦ compile namespace
After (representation):
source must be parsed again ↦ AST dated back to time 1, always parsed again
compiler-info.json written once the clean decision is made
compile namespace ↦ Ns.cmt removed until the compile publishes it
lib/bs or lib/ocaml exists ↦ clean, which removes them
The compiler keeps early cutoff with one copy of each interface: it
replaces an interface it cannot read instead of failing, and a .cmj cut
short after its digest no longer counts as unchanged. Stale public
JavaScript is removed when an AST proves the build generated it; the JS
mirror and the build.ninja marker are gone. Clean empties lib/rescript but
for the lock files.
Review: Why hold ASTs as well as interfaces? A failed parse used to leave its AST in lib/bs only; with one copy it would look current and the next build would skip the parse and lose the error.
Review: Why rename into place, with an in-place write only as a fallback? A build killed during an in-place write leaves a truncated file, and a truncated typed tree with a fresh time counts as compiled for good. On Windows the rename fails while an editor has the file open without delete sharing, so the file is then written in place.
Review: Why date an AST back instead of removing it? A later compile of the same build or watch session may still read it. Time 1 is below any real source time except the epoch, which is why such an AST is always parsed again.
Review: What about a removed module's working .cmi, which cleanup deferred? It went to lib/bs, outside the include path. In lib/rescript it would let dependents compile against a deleted module, so it is removed at once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU
Signed-off-by: Christoph Knittel <ck@cca.io>
* Read compiled files from the flat lib/rescript in analysis and gentype
Why:
The tools found a module's compiled files through the nested lib/bs
mirror of the sources and the source copies in lib/ocaml, which the
previous commit removes.
Each tool now looks a module up by its compiled file name:
- analysis reads <pkg>/lib/rescript/<Module>[-Ns].cmt, the stdlib's compiled
files from <runtime>/lib/rescript and its sources from the runtime package
root, .sourcedirs.json from lib/rescript, and incremental files from
lib/rescript/incremental;
- reanalyze scans each package's lib/rescript, and its -cmt-root walk skips
the editor's incremental directory;
- gentype finds a dependency module's source directory in the header of its
AST, read once per build, and maps a namespace module to its package root;
it looks an imported module of the same package up as <Name>[-Ns].cmt,
trying the compiler's spelling first, and reads typed trees through the
build file store, which holds the one being compiled, without keeping
them.
Review: Why does the reanalyze snapshot move one line? The scan visited the nested source directories first and the build root last; one flat directory is scanned in name order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU
Signed-off-by: Christoph Knittel <ck@cca.io>
* Ship the runtime's lib/rescript and sources, and update CI, build tests and docs
Why:
The runtime package shipped lib/ocaml with copies of its sources; it now
ships lib/rescript and its own sources at the package root, which
analysis reads (#9151).
The release artifact, its CI upload and the playground's cmij extraction
take lib/rescript, its build state stays out of the package, and the
ignore files name lib/rescript. Build tests read the in-source outputs that
the JS mirror used to copy, and look for the debug IR, the belt interfaces
and post-build paths under lib/rescript; the installation test looks for
the watch lock there. The changelog fragment lists the new paths for tools
that read the old ones and says that lib/rescript belongs in .gitignore.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU
Signed-off-by: Christoph Knittel <ck@cca.io>
---------
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent cb4406e commit 827be16
127 files changed
Lines changed: 2539 additions & 2455 deletions
File tree
- .github/workflows
- analysis
- bin
- reanalyze
- src
- src
- changes
- compiler
- core
- platform/native
- ext
- gentype
- ml
- packages
- @rescript
- belt
- runtime
- lib
- playground/scripts
- rewatch-ocaml
- tests
- snapshots/config_acceptance
- rewatch
- tests
- clean
- gentype
- lock
- snapshots
- suffix
- watch
- tests
- analysis_tests
- tests-namespaced-references
- tests-reanalyze/deadcode/expected
- build_tests
- debug_ir
- post-build-out-of-source
- post-build
- source_map
- super_errors
- unicode
- ounit_tests
- package_tests/installation_test
- rewatch_ounit_tests
- syntax_tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
334 | 334 | | |
335 | | - | |
336 | | - | |
337 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
423 | 424 | | |
424 | 425 | | |
425 | 426 | | |
426 | | - | |
| 427 | + | |
427 | 428 | | |
428 | 429 | | |
429 | 430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | | - | |
| 51 | + | |
0 commit comments