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:
@@ -18,6 +18,7 @@ pub const Compilation = struct {
|
||||
source: [:0]const u8,
|
||||
diagnostics: errors.DiagnosticList,
|
||||
target_config: TargetConfig,
|
||||
stdlib_paths: []const []const u8 = &.{},
|
||||
|
||||
// Pipeline results
|
||||
root: ?*Node = null,
|
||||
@@ -27,7 +28,7 @@ pub const Compilation = struct {
|
||||
sema_result: ?sema.SemaResult = null,
|
||||
ir_emitter: ?ir.LLVMEmitter = null,
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, io: std.Io, file_path: []const u8, source: [:0]const u8, target_config: TargetConfig) Compilation {
|
||||
pub fn init(allocator: std.mem.Allocator, io: std.Io, file_path: []const u8, source: [:0]const u8, target_config: TargetConfig, stdlib_paths: []const []const u8) Compilation {
|
||||
return .{
|
||||
.allocator = allocator,
|
||||
.io = io,
|
||||
@@ -37,6 +38,7 @@ pub const Compilation = struct {
|
||||
.import_sources = std.StringHashMap([:0]const u8).init(allocator),
|
||||
.module_scopes = std.StringHashMap(std.StringHashMap(void)).init(allocator),
|
||||
.target_config = target_config,
|
||||
.stdlib_paths = stdlib_paths,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,6 +68,7 @@ pub const Compilation = struct {
|
||||
&cache,
|
||||
&self.import_sources,
|
||||
&self.diagnostics,
|
||||
self.stdlib_paths,
|
||||
) catch return error.CompileError;
|
||||
|
||||
// Preserve per-module visibility scopes for C import access checking
|
||||
|
||||
Reference in New Issue
Block a user