| ... | ... | @@ -1,20 +1,15 @@ |
| 1 | 1 | const Step = @This(); |
| 2 | | const builtin = @import("builtin"); |
| 3 | 2 | |
| 4 | 3 | const std = @import("../std.zig"); |
| 5 | | const Io = std.Io; |
| 6 | 4 | const Build = std.Build; |
| 7 | | const Allocator = std.mem.Allocator; |
| 8 | 5 | const assert = std.debug.assert; |
| 9 | | const Cache = Build.Cache; |
| 10 | | const Path = Cache.Path; |
| 11 | | const ArrayList = std.ArrayList; |
| 6 | const Configuration = std.Build.Configuration; |
| 12 | 7 | |
| 13 | | tag: std.Build.Configuration.Step.Tag, |
| 8 | tag: Configuration.Step.Tag, |
| 14 | 9 | name: []const u8, |
| 15 | 10 | owner: *Build, |
| 16 | 11 | |
| 17 | | dependencies: ArrayList(*Step), |
| 12 | dependencies: std.ArrayList(*Step), |
| 18 | 13 | |
| 19 | 14 | /// Set this field to declare an upper bound on the amount of bytes of memory it will |
| 20 | 15 | /// take to run the step. Zero means no limit. |
| ... | ... | @@ -37,43 +32,30 @@ dependencies: ArrayList(*Step), |
| 37 | 32 | /// total system memory available. |
| 38 | 33 | max_rss: usize, |
| 39 | 34 | |
| 40 | | state: State, |
| 41 | | |
| 42 | 35 | /// The return address associated with creation of this step that can be useful |
| 43 | 36 | /// to print along with debugging messages. |
| 44 | 37 | debug_stack_trace: std.debug.StackTrace, |
| 45 | 38 | |
| 46 | | pub const State = enum { |
| 47 | | precheck_unstarted, |
| 48 | | precheck_started, |
| 49 | | /// This is also used to indicate "dirty" steps that have been modified |
| 50 | | /// after a previous build completed, in which case, the step may or may |
| 51 | | /// not have been completed before. Either way, one or more of its direct |
| 52 | | /// file system inputs have been modified, meaning that the step needs to |
| 53 | | /// be re-evaluated. |
| 54 | | precheck_done, |
| 55 | | dependency_failure, |
| 56 | | }; |
| 57 | | |
| 58 | | pub const Tag = std.Build.Configuration.Step.Tag; |
| 39 | pub const Tag = Configuration.Step.Tag; |
| 59 | 40 | |
| 60 | 41 | pub fn Type(comptime tag: Tag) type { |
| 61 | 42 | return switch (tag) { |
| 62 | | .top_level => Build.TopLevelStep, |
| 43 | .check_file => CheckFile, |
| 63 | 44 | .compile => Compile, |
| 64 | | .install_artifact => InstallArtifact, |
| 65 | | .install_file => InstallFile, |
| 66 | | .install_dir => InstallDir, |
| 45 | .config_header => ConfigHeader, |
| 67 | 46 | .fail => Fail, |
| 47 | .find_program => FindProgram, |
| 68 | 48 | .fmt => Fmt, |
| 69 | | .translate_c => TranslateC, |
| 70 | | .write_file => WriteFile, |
| 71 | | .update_source_files => UpdateSourceFiles, |
| 72 | | .run => Run, |
| 73 | | .check_file => CheckFile, |
| 74 | | .config_header => ConfigHeader, |
| 49 | .install_artifact => InstallArtifact, |
| 50 | .install_dir => InstallDir, |
| 51 | .install_file => InstallFile, |
| 75 | 52 | .obj_copy => ObjCopy, |
| 76 | 53 | .options => Options, |
| 54 | .run => Run, |
| 55 | .top_level => TopLevel, |
| 56 | .translate_c => TranslateC, |
| 57 | .update_source_files => UpdateSourceFiles, |
| 58 | .write_file => WriteFile, |
| 77 | 59 | }; |
| 78 | 60 | } |
| 79 | 61 | |
| ... | ... | @@ -116,7 +98,6 @@ pub fn init(options: StepOptions) Step { |
| 116 | 98 | .name = arena.dupe(u8, options.name) catch @panic("OOM"), |
| 117 | 99 | .owner = options.owner, |
| 118 | 100 | .dependencies = .empty, |
| 119 | | .state = .precheck_unstarted, |
| 120 | 101 | .max_rss = options.max_rss, |
| 121 | 102 | .debug_stack_trace = blk: { |
| 122 | 103 | const addr_buf = arena.alloc(usize, options.owner.debug_stack_frames_count) catch @panic("OOM"); |
| ... | ... | @@ -132,14 +113,12 @@ pub fn dependOn(step: *Step, other: *Step) void { |
| 132 | 113 | } |
| 133 | 114 | |
| 134 | 115 | pub fn cast(step: *Step, comptime T: type) ?*T { |
| 135 | | if (step.tag == T.base_tag) { |
| 136 | | return @fieldParentPtr("step", step); |
| 137 | | } |
| 116 | if (step.tag == T.base_tag) return @fieldParentPtr("step", step); |
| 138 | 117 | return null; |
| 139 | 118 | } |
| 140 | 119 | |
| 141 | 120 | /// For debugging purposes, prints identifying information about this Step. |
| 142 | | pub fn dump(step: *Step, t: Io.Terminal) void { |
| 121 | pub fn dump(step: *Step, t: std.Io.Terminal) void { |
| 143 | 122 | const w = t.writer; |
| 144 | 123 | if (step.debug_stack_trace.return_addresses.len > 0) { |
| 145 | 124 | w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {}; |
| ... | ... | @@ -155,16 +134,18 @@ pub fn dump(step: *Step, t: Io.Terminal) void { |
| 155 | 134 | |
| 156 | 135 | test { |
| 157 | 136 | _ = CheckFile; |
| 137 | _ = Compile; |
| 138 | _ = ConfigHeader; |
| 158 | 139 | _ = Fail; |
| 140 | _ = FindProgram; |
| 159 | 141 | _ = Fmt; |
| 160 | 142 | _ = InstallArtifact; |
| 161 | 143 | _ = InstallDir; |
| 162 | 144 | _ = InstallFile; |
| 163 | 145 | _ = ObjCopy; |
| 164 | | _ = Compile; |
| 165 | 146 | _ = Options; |
| 166 | 147 | _ = Run; |
| 167 | 148 | _ = TranslateC; |
| 168 | | _ = WriteFile; |
| 169 | 149 | _ = UpdateSourceFiles; |
| 150 | _ = WriteFile; |
| 170 | 151 | } |