| | @@ -4,6 +4,55 @@ |
| 4 | 4 | None is built while the freeze holds; each waits for a later thaw, by |
| 5 | 5 | the owner's word, and goes into the report before any code. |
| 6 | 6 | |
| 7 | +## Installed source libraries and RAZ_PATH |
| 8 | + |
| 9 | +**Status.** Approved by the owner on 2026-10-19, to be implemented |
| 10 | +after this proposal is committed and pushed. This changes the compiler's |
| 11 | +module search paths and documents an installation convention; it adds |
| 12 | +no language syntax or package manager. |
| 13 | + |
| 14 | +A library should be usable by several programs without adding it as a |
| 15 | +Git submodule to each. Install its source modules directly in |
| 16 | +`$HOME/.raz/lib`, including any target-specific siblings. The compiler |
| 17 | +searches that directory automatically. It does not search subdirectories |
| 18 | +or create the directory itself. |
| 19 | + |
| 20 | +`RAZ_PATH` replaces that default with a colon-separated list of module |
| 21 | +directories. An unset variable means `$HOME/.raz/lib`; an explicitly |
| 22 | +empty value disables user library directories. Empty entries in a list |
| 23 | +are ignored, rather than standing for the working directory. Relative |
| 24 | +paths are relative to the compiler's working directory. The compiler |
| 25 | +does not expand `~` or environment variables inside a path: the shell |
| 26 | +can expand them when setting `RAZ_PATH`. If `HOME` is unset or empty, |
| 27 | +there is no default user library directory. |
| 28 | + |
| 29 | +The search is the main module's directory, each `-I` directory, the user |
| 30 | +library directories, and finally `lib/` beside the compiler. The standard |
| 31 | +library is always searched, even with an empty `RAZ_PATH`. Existing |
| 32 | +target suffixes, interface checks, duplicate-module errors and the |
| 33 | +symbolic-link exception apply to the new directories too. `-I` does not |
| 34 | +silently override an installed module. |
| 35 | + |
| 36 | +For example: |
| 37 | + |
| 38 | +```sh |
| 39 | +mkdir -p "$HOME/.raz/lib" |
| 40 | +install -m644 Json.raz "$HOME/.raz/lib/Json.raz" |
| 41 | +raz Main.raz # import Json; needs no -I |
| 42 | +export RAZ_PATH="$HOME/.raz/lib:$HOME/work/raz-libs" |
| 43 | +RAZ_PATH= raz -I deps/json Main.raz # an isolated dependency selection |
| 44 | +``` |
| 45 | + |
| 46 | +A library's build file may provide install and uninstall tasks for its |
| 47 | +own source files. Robbie can run those tasks, as make or a shell can; |
| 48 | +the convention belongs to raz and needs no special robbie feature. |
| 49 | +Dependency versions and downloads remain the project's or user's choice. |
| 50 | + |
| 51 | +Document this in the report's module lookup, raz(1), the README and the |
| 52 | +compiler guide. Test the unset and empty cases, lists of directories, |
| 53 | +paths with spaces, target-specific files and interface checks, duplicate |
| 54 | +modules and symbolic links, and use with both compilation and `raz run`. |
| 55 | + |
| 7 | 56 | ## What a call does with its arguments, written at the call |
| 8 | 57 | |
| 9 | 58 | **Status.** Not approved. Drafted 2026-10-16 and reviewed twice on |