| ... | @@ -481,18 +481,21 @@ fn lowerZigArgs( | ... | @@ -481,18 +481,21 @@ fn lowerZigArgs( |
| 481 | const module_index = cli_named_modules.modules.keys()[module_cli_index]; | 481 | const module_index = cli_named_modules.modules.keys()[module_cli_index]; |
| 482 | try appendModuleFlags(module_index, zig_args, compile_index, maker); | 482 | try appendModuleFlags(module_index, zig_args, compile_index, maker); |
| 483 | | 483 | |
| 484 | if (true) @panic("TODO"); | 484 | const imports = mod.import_table.get(conf).imports.mal; |
| 485 | | 485 | |
| 486 | // --dep arguments | 486 | // --dep arguments |
| 487 | try zig_args.ensureUnusedCapacity(gpa, mod.import_table.count() * 2); | 487 | try zig_args.ensureUnusedCapacity(gpa, imports.len * 2); |
| 488 | for (mod.import_table.keys(), mod.import_table.values()) |name, import| { | 488 | for (imports.items(.name), imports.items(.module)) |name, import| { |
| 489 | const import_index = cli_named_modules.modules.getIndex(import).?; | 489 | const import_index = cli_named_modules.modules.getIndex(import).?; |
| 490 | const import_cli_name = cli_named_modules.names.keys()[import_index]; | 490 | const import_cli_name = cli_named_modules.names.keys()[import_index]; |
| 491 | zig_args.appendAssumeCapacity("--dep"); | 491 | zig_args.appendAssumeCapacity("--dep"); |
| 492 | if (std.mem.eql(u8, import_cli_name, name)) { | 492 | const name_slice = name.slice(conf); |
| | 493 | if (std.mem.eql(u8, import_cli_name, name_slice)) { |
| 493 | zig_args.appendAssumeCapacity(import_cli_name); | 494 | zig_args.appendAssumeCapacity(import_cli_name); |
| 494 | } else { | 495 | } else { |
| 495 | zig_args.appendAssumeCapacity(try allocPrint(arena, "{s}={s}", .{ name, import_cli_name })); | 496 | zig_args.appendAssumeCapacity(try allocPrint(arena, "{s}={s}", .{ |
| | 497 | name_slice, import_cli_name, |
| | 498 | })); |
| 496 | } | 499 | } |
| 497 | } | 500 | } |
| 498 | | 501 | |
| ... | @@ -503,11 +506,12 @@ fn lowerZigArgs( | ... | @@ -503,11 +506,12 @@ fn lowerZigArgs( |
| 503 | // perhaps a set of linker objects, or C source files instead. | 506 | // perhaps a set of linker objects, or C source files instead. |
| 504 | // Linker objects are added to the CLI globally, while C source | 507 | // Linker objects are added to the CLI globally, while C source |
| 505 | // files must have a module parent. | 508 | // files must have a module parent. |
| 506 | if (mod.root_source_file) |lp| { | 509 | try zig_args.ensureUnusedCapacity(gpa, 1); |
| 507 | const src = lp.getPath2(mod.owner, step); | 510 | if (mod.root_source_file.unwrap()) |lp| { |
| 508 | try zig_args.append(gpa, try allocPrint(arena, "-M{s}={s}", .{ module_cli_name, src })); | 511 | const src = try maker.resolveLazyPathIndexAbs(arena, lp, compile_index); |
| 509 | } else if (moduleNeedsCliArg(mod)) { | 512 | zig_args.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}", .{ module_cli_name, src })); |
| 510 | try zig_args.append(gpa, try allocPrint(arena, "-M{s}", .{module_cli_name})); | 513 | } else if (moduleNeedsCliArg(&mod, conf)) { |
| | 514 | zig_args.appendAssumeCapacity(try allocPrint(arena, "-M{s}", .{module_cli_name})); |
| 511 | } | 515 | } |
| 512 | } | 516 | } |
| 513 | } | 517 | } |
| ... | @@ -1262,8 +1266,8 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool { | ... | @@ -1262,8 +1266,8 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool { |
| 1262 | return false; | 1266 | return false; |
| 1263 | } | 1267 | } |
| 1264 | | 1268 | |
| 1265 | fn moduleNeedsCliArg(mod: *const Module) bool { | 1269 | fn moduleNeedsCliArg(mod: *const Configuration.Module, conf: *const Configuration) bool { |
| 1266 | return for (mod.link_objects.items) |o| switch (o) { | 1270 | return for (0..mod.link_objects.len) |i| switch (mod.link_objects.tag(conf.extra, i)) { |
| 1267 | .c_source_file, .c_source_files, .assembly_file, .win32_resource_file => break true, | 1271 | .c_source_file, .c_source_files, .assembly_file, .win32_resource_file => break true, |
| 1268 | else => continue, | 1272 | else => continue, |
| 1269 | } else false; | 1273 | } else false; |