| ... | @@ -451,6 +451,24 @@ const Serialize = struct { | ... | @@ -451,6 +451,24 @@ const Serialize = struct { |
| 451 | return result; | 451 | return result; |
| 452 | } | 452 | } |
| 453 | | 453 | |
| | 454 | fn initIncludeDirList( |
| | 455 | s: *Serialize, |
| | 456 | list: []const std.Build.Module.IncludeDir, |
| | 457 | ) ![]const Configuration.Module.IncludeDir { |
| | 458 | const result = try s.arena.alloc(Configuration.Module.IncludeDir, list.len); |
| | 459 | for (result, list) |*dest, src| dest.* = switch (src) { |
| | 460 | .path => |lp| .{ .path = try addLazyPath(s, lp) }, |
| | 461 | .path_system => |lp| .{ .path_system = try addLazyPath(s, lp) }, |
| | 462 | .path_after => |lp| .{ .path_after = try addLazyPath(s, lp) }, |
| | 463 | .framework_path => |lp| .{ .framework_path = try addLazyPath(s, lp) }, |
| | 464 | .framework_path_system => |lp| .{ .framework_path_system = try addLazyPath(s, lp) }, |
| | 465 | .embed_path => |lp| .{ .embed_path = try addLazyPath(s, lp) }, |
| | 466 | .other_step => |cs| .{ .other_step = stepIndex(s, &cs.step) }, |
| | 467 | .config_header_step => |chs| .{ .config_header_step = stepIndex(s, &chs.step) }, |
| | 468 | }; |
| | 469 | return result; |
| | 470 | } |
| | 471 | |
| 454 | fn initLazyPathList(s: *Serialize, list: []const std.Build.LazyPath) ![]const Configuration.LazyPath.Index { | 472 | fn initLazyPathList(s: *Serialize, list: []const std.Build.LazyPath) ![]const Configuration.LazyPath.Index { |
| 455 | const result = try s.arena.alloc(Configuration.LazyPath.Index, list.len); | 473 | const result = try s.arena.alloc(Configuration.LazyPath.Index, list.len); |
| 456 | for (result, list) |*dest, src| dest.* = try addLazyPath(s, src); | 474 | for (result, list) |*dest, src| dest.* = try addLazyPath(s, src); |
| ... | @@ -486,18 +504,6 @@ const Serialize = struct { | ... | @@ -486,18 +504,6 @@ const Serialize = struct { |
| 486 | const wc = s.wc; | 504 | const wc = s.wc; |
| 487 | const arena = s.arena; | 505 | const arena = s.arena; |
| 488 | | 506 | |
| 489 | const include_dirs = try arena.alloc(Configuration.Module.IncludeDir, m.include_dirs.items.len); | | |
| 490 | for (include_dirs, m.include_dirs.items) |*dest, src| dest.* = switch (src) { | | |
| 491 | .path => |lp| .{ .path = try addLazyPath(s, lp) }, | | |
| 492 | .path_system => |lp| .{ .path_system = try addLazyPath(s, lp) }, | | |
| 493 | .path_after => |lp| .{ .path_after = try addLazyPath(s, lp) }, | | |
| 494 | .framework_path => |lp| .{ .framework_path = try addLazyPath(s, lp) }, | | |
| 495 | .framework_path_system => |lp| .{ .framework_path_system = try addLazyPath(s, lp) }, | | |
| 496 | .embed_path => |lp| .{ .embed_path = try addLazyPath(s, lp) }, | | |
| 497 | .other_step => |cs| .{ .other_step = stepIndex(s, &cs.step) }, | | |
| 498 | .config_header_step => |chs| .{ .config_header_step = stepIndex(s, &chs.step) }, | | |
| 499 | }; | | |
| 500 | | | |
| 501 | const rpaths = try arena.alloc(Configuration.Module.RPath, m.rpaths.items.len); | 507 | const rpaths = try arena.alloc(Configuration.Module.RPath, m.rpaths.items.len); |
| 502 | for (rpaths, m.rpaths.items) |*dest, src| dest.* = switch (src) { | 508 | for (rpaths, m.rpaths.items) |*dest, src| dest.* = switch (src) { |
| 503 | .lazy_path => |lp| .{ .lazy_path = try addLazyPath(s, lp) }, | 509 | .lazy_path => |lp| .{ .lazy_path = try addLazyPath(s, lp) }, |
| ... | @@ -542,7 +548,7 @@ const Serialize = struct { | ... | @@ -542,7 +548,7 @@ const Serialize = struct { |
| 542 | .fuzz = .init(m.fuzz), | 548 | .fuzz = .init(m.fuzz), |
| 543 | .code_model = m.code_model, | 549 | .code_model = m.code_model, |
| 544 | .c_macros = c_macros.len != 0, | 550 | .c_macros = c_macros.len != 0, |
| 545 | .include_dirs = include_dirs.len != 0, | 551 | .include_dirs = m.include_dirs.items.len != 0, |
| 546 | .lib_paths = lib_paths.len != 0, | 552 | .lib_paths = lib_paths.len != 0, |
| 547 | .rpaths = rpaths.len != 0, | 553 | .rpaths = rpaths.len != 0, |
| 548 | .frameworks = frameworks.len != 0, | 554 | .frameworks = frameworks.len != 0, |
| ... | @@ -566,7 +572,7 @@ const Serialize = struct { | ... | @@ -566,7 +572,7 @@ const Serialize = struct { |
| 566 | .c_macros = .{ .slice = c_macros }, | 572 | .c_macros = .{ .slice = c_macros }, |
| 567 | .lib_paths = .{ .slice = lib_paths }, | 573 | .lib_paths = .{ .slice = lib_paths }, |
| 568 | .export_symbol_names = .{ .slice = export_symbol_names }, | 574 | .export_symbol_names = .{ .slice = export_symbol_names }, |
| 569 | .include_dirs = .init(include_dirs), | 575 | .include_dirs = .init(try s.initIncludeDirList(m.include_dirs.items)), |
| 570 | .rpaths = .init(rpaths), | 576 | .rpaths = .init(rpaths), |
| 571 | .link_objects = .init(link_objects), | 577 | .link_objects = .init(link_objects), |
| 572 | .frameworks = .{ .slice = frameworks }, | 578 | .frameworks = .{ .slice = frameworks }, |
| ... | @@ -910,7 +916,28 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { | ... | @@ -910,7 +916,28 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { |
| 910 | .exclude_paths = .{ .slice = try s.initLazyPathList(sf.exclude_paths) }, | 916 | .exclude_paths = .{ .slice = try s.initLazyPathList(sf.exclude_paths) }, |
| 911 | }))); | 917 | }))); |
| 912 | }, | 918 | }, |
| 913 | .translate_c => @panic("TODO"), | 919 | .translate_c => e: { |
| | 920 | const tc: *Step.TranslateC = @fieldParentPtr("step", step); |
| | 921 | |
| | 922 | const system_libs = try arena.alloc(Configuration.SystemLib.Index, tc.system_libs.items.len); |
| | 923 | for (system_libs, tc.system_libs.items) |*dest, *src| dest.* = try s.addSystemLib(src); |
| | 924 | |
| | 925 | break :e @enumFromInt(try wc.addExtra(@as(Configuration.Step.TranslateC, .{ |
| | 926 | .flags = .{ |
| | 927 | .include_dirs = tc.include_dirs.items.len != 0, |
| | 928 | .system_libs = system_libs.len != 0, |
| | 929 | .c_macros = tc.c_macros.items.len != 0, |
| | 930 | .link_libc = tc.link_libc, |
| | 931 | .optimize = .init(tc.optimize), |
| | 932 | }, |
| | 933 | .src_path = try s.addLazyPath(tc.source), |
| | 934 | .output_file = tc.output_file, |
| | 935 | .include_dirs = .init(try s.initIncludeDirList(tc.include_dirs.items)), |
| | 936 | .system_libs = .{ .slice = system_libs }, |
| | 937 | .c_macros = .{ .slice = tc.c_macros.items }, |
| | 938 | .target = try addOptionalResolvedTarget(wc, tc.target), |
| | 939 | }))); |
| | 940 | }, |
| 914 | .write_file => e: { | 941 | .write_file => e: { |
| 915 | const wf: *Step.WriteFile = @fieldParentPtr("step", step); | 942 | const wf: *Step.WriteFile = @fieldParentPtr("step", step); |
| 916 | | 943 | |