From 1788561fa7d3570b07e06b4cb52bacd2d5e120f6 Mon Sep 17 00:00:00 2001 From: Meghan Date: Tue, 17 Nov 2020 01:27:20 -0800 Subject: [PATCH] fetch: use relative path in deps.zig for local c/h files --- src/cmd_fetch.zig | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/cmd_fetch.zig b/src/cmd_fetch.zig index d78384beabae8e7bc2514502a17fa47f513b72ea..cb7d15d39973ab403bdad1d6d54204d56777fd7e 100644 --- a/src/cmd_fetch.zig +++ b/src/cmd_fetch.zig @@ -47,11 +47,11 @@ pub fn execute(args: [][]u8) !void { try w.print(";\n", .{}); try w.print("\n", .{}); try w.print("{}\n", .{"pub const c_include_dirs = &[_][]const u8{"}); - try print_incl_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa)); + try print_incl_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true); try w.print("{};\n", .{"}"}); try w.print("\n", .{}); try w.print("{}\n", .{"pub const c_source_files = &[_][]const u8{"}); - try print_csrc_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa)); + try print_csrc_dirs_to(w, top_module, &std.ArrayList([]const u8).init(gpa), true); try w.print("{};\n", .{"}"}); } @@ -119,28 +119,36 @@ fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) an try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})}); } -fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8)) anyerror!void { +fn print_incl_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void { if (u.list_contains(list, mod.clean_path)) { return; } try list.append(mod.clean_path); for (mod.c_include_dirs) |it| { - try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it}); + if (!local) { + try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it}); + } else { + try w.print(" \".{}/{}\",\n", .{mod.clean_path, it}); + } } for (mod.deps) |d| { - try print_incl_dirs_to(w, d, list); + try print_incl_dirs_to(w, d, list, false); } } -fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8)) anyerror!void { +fn print_csrc_dirs_to(w: std.fs.File.Writer, mod: u.Module, list: *std.ArrayList([]const u8), local: bool) anyerror!void { if (u.list_contains(list, mod.clean_path)) { return; } try list.append(mod.clean_path); for (mod.c_source_files) |it| { - try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it}); + if (!local) { + try w.print(" cache ++ \"/{}/{}\",\n", .{mod.clean_path, it}); + } else { + try w.print(" \".{}/{}\",\n", .{mod.clean_path, it}); + } } for (mod.deps) |d| { - try print_csrc_dirs_to(w, d, list); + try print_csrc_dirs_to(w, d, list, false); } } -- 2.54.0