stdlib: relocate modules under library/

- examples/modules/ -> library/modules/ (top-level, no more
  symlink hacks in consumer projects)
- compiler discovers stdlib via _NSGetExecutablePath / readlink
  /proc/self/exe; searches dev layout (../../library), install
  layout (../library), and alongside-binary fallback
- SX_STDLIB_PATH env var overrides for tests / dev convenience
- SX_DEBUG_STDLIB env var dumps the discovery results
- build.zig installs library/ alongside the binary
- Compilation gains stdlib_paths field threaded through resolveImports
- 50 tests pass; consumer projects can now build from any cwd
This commit is contained in:
agra
2026-05-17 13:49:25 +03:00
parent 535e7b9c24
commit c027e1969b
26 changed files with 130 additions and 35 deletions

View File

@@ -158,6 +158,16 @@ pub fn build(b: *std.Build) void {
b.installArtifact(exe);
// Install the stdlib alongside the binary so `<prefix>/bin/sx` finds
// `<prefix>/library/modules/...` via the install-layout fallback in
// `src/imports.zig::discoverStdlibPaths`.
const install_library = b.addInstallDirectory(.{
.source_dir = b.path("library"),
.install_dir = .prefix,
.install_subdir = "library",
});
b.getInstallStep().dependOn(&install_library.step);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);