| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const Step = std.Build.Step; | 2 | const Step = std.Build.Step; |
| | 3 | const LazyPath = std.Build.LazyPath; |
| 3 | const fs = std.fs; | 4 | const fs = std.fs; |
| 4 | const mem = std.mem; | 5 | const mem = std.mem; |
| 5 | | 6 | |
| ... | @@ -9,7 +10,7 @@ pub const base_id: Step.Id = .translate_c; | ... | @@ -9,7 +10,7 @@ pub const base_id: Step.Id = .translate_c; |
| 9 | | 10 | |
| 10 | step: Step, | 11 | step: Step, |
| 11 | source: std.Build.LazyPath, | 12 | source: std.Build.LazyPath, |
| 12 | include_dirs: std.ArrayList([]const u8), | 13 | include_dirs: std.ArrayList(std.Build.Module.IncludeDir), |
| 13 | c_macros: std.ArrayList([]const u8), | 14 | c_macros: std.ArrayList([]const u8), |
| 14 | out_basename: []const u8, | 15 | out_basename: []const u8, |
| 15 | target: std.Build.ResolvedTarget, | 16 | target: std.Build.ResolvedTarget, |
| ... | @@ -37,7 +38,7 @@ pub fn create(owner: *std.Build, options: Options) *TranslateC { | ... | @@ -37,7 +38,7 @@ pub fn create(owner: *std.Build, options: Options) *TranslateC { |
| 37 | .makeFn = make, | 38 | .makeFn = make, |
| 38 | }), | 39 | }), |
| 39 | .source = source, | 40 | .source = source, |
| 40 | .include_dirs = std.ArrayList([]const u8).init(owner.allocator), | 41 | .include_dirs = std.ArrayList(std.Build.Module.IncludeDir).init(owner.allocator), |
| 41 | .c_macros = std.ArrayList([]const u8).init(owner.allocator), | 42 | .c_macros = std.ArrayList([]const u8).init(owner.allocator), |
| 42 | .out_basename = undefined, | 43 | .out_basename = undefined, |
| 43 | .target = options.target, | 44 | .target = options.target, |
| ... | @@ -95,8 +96,45 @@ pub fn createModule(translate_c: *TranslateC) *std.Build.Module { | ... | @@ -95,8 +96,45 @@ pub fn createModule(translate_c: *TranslateC) *std.Build.Module { |
| 95 | }); | 96 | }); |
| 96 | } | 97 | } |
| 97 | | 98 | |
| 98 | pub fn addIncludeDir(translate_c: *TranslateC, include_dir: []const u8) void { | 99 | pub fn addAfterIncludePath(translate_c: *TranslateC, lazy_path: LazyPath) void { |
| 99 | translate_c.include_dirs.append(translate_c.step.owner.dupePath(include_dir)) catch @panic("OOM"); | 100 | const b = translate_c.step.owner; |
| | 101 | translate_c.include_dirs.append(.{ .path_after = lazy_path.dupe(b) }) catch |
| | 102 | @panic("OOM"); |
| | 103 | lazy_path.addStepDependencies(&translate_c.step); |
| | 104 | } |
| | 105 | |
| | 106 | pub fn addSystemIncludePath(translate_c: *TranslateC, lazy_path: LazyPath) void { |
| | 107 | const b = translate_c.step.owner; |
| | 108 | translate_c.include_dirs.append(.{ .path_system = lazy_path.dupe(b) }) catch |
| | 109 | @panic("OOM"); |
| | 110 | lazy_path.addStepDependencies(&translate_c.step); |
| | 111 | } |
| | 112 | |
| | 113 | pub fn addIncludePath(translate_c: *TranslateC, lazy_path: LazyPath) void { |
| | 114 | const b = translate_c.step.owner; |
| | 115 | translate_c.include_dirs.append(.{ .path = lazy_path.dupe(b) }) catch |
| | 116 | @panic("OOM"); |
| | 117 | lazy_path.addStepDependencies(&translate_c.step); |
| | 118 | } |
| | 119 | |
| | 120 | pub fn addConfigHeader(translate_c: *TranslateC, config_header: *Step.ConfigHeader) void { |
| | 121 | translate_c.include_dirs.append(.{ .config_header_step = config_header }) catch |
| | 122 | @panic("OOM"); |
| | 123 | translate_c.step.dependOn(&config_header.step); |
| | 124 | } |
| | 125 | |
| | 126 | pub fn addSystemFrameworkPath(translate_c: *TranslateC, directory_path: LazyPath) void { |
| | 127 | const b = translate_c.step.owner; |
| | 128 | translate_c.include_dirs.append(.{ .framework_path_system = directory_path.dupe(b) }) catch |
| | 129 | @panic("OOM"); |
| | 130 | directory_path.addStepDependencies(&translate_c.step); |
| | 131 | } |
| | 132 | |
| | 133 | pub fn addFrameworkPath(translate_c: *TranslateC, directory_path: LazyPath) void { |
| | 134 | const b = translate_c.step.owner; |
| | 135 | translate_c.include_dirs.append(.{ .framework_path = directory_path.dupe(b) }) catch |
| | 136 | @panic("OOM"); |
| | 137 | directory_path.addStepDependencies(&translate_c.step); |
| 100 | } | 138 | } |
| 101 | | 139 | |
| 102 | pub fn addCheckFile(translate_c: *TranslateC, expected_matches: []const []const u8) *Step.CheckFile { | 140 | pub fn addCheckFile(translate_c: *TranslateC, expected_matches: []const []const u8) *Step.CheckFile { |
| ... | @@ -147,8 +185,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -147,8 +185,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 147 | } | 185 | } |
| 148 | | 186 | |
| 149 | for (translate_c.include_dirs.items) |include_dir| { | 187 | for (translate_c.include_dirs.items) |include_dir| { |
| 150 | try argv_list.append("-I"); | 188 | try include_dir.appendZigProcessFlags(b, &argv_list, step); |
| 151 | try argv_list.append(include_dir); | | |
| 152 | } | 189 | } |
| 153 | | 190 | |
| 154 | for (translate_c.c_macros.items) |c_macro| { | 191 | for (translate_c.c_macros.items) |c_macro| { |