| ... | ... | @@ -481,18 +481,21 @@ fn lowerZigArgs( |
| 481 | 481 | const module_index = cli_named_modules.modules.keys()[module_cli_index]; |
| 482 | 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 | 486 | // --dep arguments |
| 487 | | try zig_args.ensureUnusedCapacity(gpa, mod.import_table.count() * 2); |
| 488 | | for (mod.import_table.keys(), mod.import_table.values()) |name, import| { |
| 487 | try zig_args.ensureUnusedCapacity(gpa, imports.len * 2); |
| 488 | for (imports.items(.name), imports.items(.module)) |name, import| { |
| 489 | 489 | const import_index = cli_named_modules.modules.getIndex(import).?; |
| 490 | 490 | const import_cli_name = cli_named_modules.names.keys()[import_index]; |
| 491 | 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 | 494 | zig_args.appendAssumeCapacity(import_cli_name); |
| 494 | 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 | 506 | // perhaps a set of linker objects, or C source files instead. |
| 504 | 507 | // Linker objects are added to the CLI globally, while C source |
| 505 | 508 | // files must have a module parent. |
| 506 | | if (mod.root_source_file) |lp| { |
| 507 | | const src = lp.getPath2(mod.owner, step); |
| 508 | | try zig_args.append(gpa, try allocPrint(arena, "-M{s}={s}", .{ module_cli_name, src })); |
| 509 | | } else if (moduleNeedsCliArg(mod)) { |
| 510 | | try zig_args.append(gpa, try allocPrint(arena, "-M{s}", .{module_cli_name})); |
| 509 | try zig_args.ensureUnusedCapacity(gpa, 1); |
| 510 | if (mod.root_source_file.unwrap()) |lp| { |
| 511 | const src = try maker.resolveLazyPathIndexAbs(arena, lp, compile_index); |
| 512 | zig_args.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}", .{ module_cli_name, src })); |
| 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 | 1266 | return false; |
| 1263 | 1267 | } |
| 1264 | 1268 | |
| 1265 | | fn moduleNeedsCliArg(mod: *const Module) bool { |
| 1266 | | return for (mod.link_objects.items) |o| switch (o) { |
| 1269 | fn moduleNeedsCliArg(mod: *const Configuration.Module, conf: *const Configuration) bool { |
| 1270 | return for (0..mod.link_objects.len) |i| switch (mod.link_objects.tag(conf.extra, i)) { |
| 1267 | 1271 | .c_source_file, .c_source_files, .assembly_file, .win32_resource_file => break true, |
| 1268 | 1272 | else => continue, |
| 1269 | 1273 | } else false; |