|
| 1 | +Internal Structure of Stdlib |
| 2 | +============================ |
| 3 | + |
| 4 | +For historical reasons, the internal dependency structure of the |
| 5 | +Stdlib library does not match its directory structure. That is, one |
| 6 | +can find many exmaples of files in some directory `A` that depends |
| 7 | +from files in another directory `B`, whereas other files in `B` |
| 8 | +depends from files in `A`. This makes it difficult to understand what |
| 9 | +are the acceptable dependencies in a given file, with developers left |
| 10 | +trying adding dependencies until a circular dependency appears, |
| 11 | +further worsening the current mess. |
| 12 | + |
| 13 | +For backward compatibility reasons, that unfortunate state of affairs |
| 14 | +cannot be easily fixed. However, to better understand the current |
| 15 | +dependencies and mitigate the issue, we document here current tools to |
| 16 | +help somewhat master that situation. |
| 17 | + |
| 18 | +Documentation |
| 19 | +------------- |
| 20 | + |
| 21 | +One can find a graph of dependencies in file |
| 22 | +`doc/stdlib/depends`. This graph is included in the documentation |
| 23 | +built by `make stdlib-html` in directory |
| 24 | +`_build/default/doc/stdlib/html/`. To find the exact files contained |
| 25 | +in each node `<n>` of this graph, one can look at the corresponding |
| 26 | +`theories/Make.<n>` file. |
| 27 | + |
| 28 | +CI testing |
| 29 | +---------- |
| 30 | + |
| 31 | +A CI job `stdlib-subcomponents` checks that the above documented |
| 32 | +structure remains valid. |
| 33 | + |
| 34 | +How to Modify the Structure |
| 35 | +--------------------------- |
| 36 | + |
| 37 | +When adding a file, it is enough to list it in the appropriate |
| 38 | +`theories/Make.*` file. Note that, for historical reasons, some |
| 39 | +directories are split between different subcomponents. In this case, a |
| 40 | +symlink must be added in the appropriate `_SubComponent` subdirectory |
| 41 | +and only the symlink must be listed in `theories/Make.*`. Look at |
| 42 | +`theories/Make.lists` for an example. |
| 43 | + |
| 44 | +To add or remove a subcomponent, just add or remove the corresponding |
| 45 | +`theories/Make.*` file and adapt `doc/stdlib/depends` and |
| 46 | +`.nix/coq-overlays/stdlib-subcomponents/default.nix`. One can use the |
| 47 | +`dev/tools/make-depends.sh` script to help update the graph. |
0 commit comments