| ... | ... | @@ -36,8 +36,8 @@ pub fn execute(args: [][]u8) !void { |
| 36 | 36 | \\ for (c_include_dirs) |dir| { |
| 37 | 37 | \\ exe.addIncludeDir(dir); |
| 38 | 38 | \\ } |
| 39 | | \\ for (c_source_files) |fpath| { |
| 40 | | \\ exe.addCSourceFile(fpath, &[_][]const u8{}); |
| 39 | \\ inline for (c_source_files) |fpath| { |
| 40 | \\ exe.addCSourceFile(fpath[1], @field(c_source_flags, fpath[0])); |
| 41 | 41 | \\ } |
| 42 | 42 | \\} |
| 43 | 43 | }); |
| ... | ... | @@ -50,7 +50,11 @@ pub fn execute(args: [][]u8) !void { |
| 50 | 50 | try print_incl_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true); |
| 51 | 51 | try w.print("{};\n", .{"}"}); |
| 52 | 52 | try w.print("\n", .{}); |
| 53 | | try w.print("{}\n", .{"pub const c_source_files = &[_][]const u8{"}); |
| 53 | try w.print("{}\n", .{"pub const c_source_flags = struct {"}); |
| 54 | try print_csrc_flags_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true); |
| 55 | try w.print("{};\n", .{"}"}); |
| 56 | try w.print("\n", .{}); |
| 57 | try w.print("{}\n", .{"pub const c_source_files = &[_][2][]const u8{"}); |
| 54 | 58 | try print_csrc_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true); |
| 55 | 59 | try w.print("{};\n", .{"}"}); |
| 56 | 60 | } |
| ... | ... | @@ -92,6 +96,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 92 | 96 | .name = m.name, |
| 93 | 97 | .main = m.main, |
| 94 | 98 | .c_include_dirs = m.c_include_dirs, |
| 99 | .c_source_flags = m.c_source_flags, |
| 95 | 100 | .c_source_files = m.c_source_files, |
| 96 | 101 | .deps = moduledeps.items, |
| 97 | 102 | .clean_path = "", |
| ... | ... | @@ -151,12 +156,32 @@ fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList |
| 151 | 156 | try list.append(mod.clean_path); |
| 152 | 157 | for (mod.c_source_files) |it| { |
| 153 | 158 | if (!local) { |
| 154 | | try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it}); |
| 159 | try w.print(" {}\"{}\", cache ++ \"/{}/{}\"{},\n", .{"[_][]const u8{", mod.clean_path, mod.clean_path, it, "}"}); |
| 155 | 160 | } else { |
| 156 | | try w.print(" \".{}/{}\",\n", .{mod.clean_path, it}); |
| 161 | try w.print(" {}\"{}\", \".{}/{}\"{},\n", .{"[_][]const u8{", mod.clean_path, mod.clean_path, it, "}"}); |
| 157 | 162 | } |
| 158 | 163 | } |
| 159 | 164 | for (mod.deps) |d| { |
| 160 | 165 | try print_csrc_dirs_to(w, d, list, false); |
| 161 | 166 | } |
| 162 | 167 | } |
| 168 | |
| 169 | fn print_csrc_flags_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void { |
| 170 | if (u.list_contains(list, mod.clean_path)) { |
| 171 | return; |
| 172 | } |
| 173 | try list.append(mod.clean_path); |
| 174 | if (local) { |
| 175 | try w.print(" pub const @\"{}\" = {};\n", .{"", "&[_][]const u8{}"}); |
| 176 | } |
| 177 | else { |
| 178 | try w.print(" pub const @\"{}\" = {}", .{mod.clean_path, "&[_][]const u8{"}); |
| 179 | for (mod.c_source_flags) |it| { |
| 180 | try w.print("\"{Z}\",", .{it}); |
| 181 | } |
| 182 | try w.print("{};\n", .{"}"}); |
| 183 | } |
| 184 | for (mod.deps) |d| { |
| 185 | try print_csrc_flags_to(w, d, list, false); |
| 186 | } |
| 187 | } |