| author | |
| committer | |
| log | 1a83b4d8fa4b631b6cabf06af8321a8d98eccb94 |
| tree | e5fb8268d4cf4f667f27538987cc62c052d719b8 |
| parent | 3d785897658fd8b61660649b24d8943bda545982 |
trying to eliminate this can be a followup6 files changed, 18 insertions(+), 13 deletions(-)
BRANCH_TODO+4| ... | ... | @@ -65,3 +65,7 @@ closes #31397 |
| 65 | 65 | + const fmt_include_paths = b.pathList(&.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" }); |
| 66 | 66 | + const fmt_exclude_paths = b.pathList(&.{ "test/cases", "test/behavior/zon" }); |
| 67 | 67 | ``` |
| 68 | ||
| 69 | ### std.Build API | |
| 70 | ||
| 71 | * `b.build_root` (Directory) -> `b.root` (Path) |
lib/compiler/configurer.zig+6-4| ... | ... | @@ -39,6 +39,11 @@ pub fn main(init: process.Init.Minimal) !void { |
| 39 | 39 | |
| 40 | 40 | const args = try init.args.toSlice(arena); |
| 41 | 41 | |
| 42 | var arg_i: usize = 1; // Skip own executable name. | |
| 43 | ||
| 44 | const zig_exe = expectArgOrFatal(args, &arg_i, "--zig"); | |
| 45 | const build_root_sub_path = expectArgOrFatal(args, &arg_i, "--build-root"); | |
| 46 | ||
| 42 | 47 | var graph: std.Build.Graph = .{ |
| 43 | 48 | .io = io, |
| 44 | 49 | .arena = arena, |
| ... | ... | @@ -49,6 +54,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 49 | 54 | .result = try std.zig.system.resolveTargetQuery(io, .{}), |
| 50 | 55 | }, |
| 51 | 56 | .generated_files = .empty, |
| 57 | .zig_exe = zig_exe, | |
| 52 | 58 | |
| 53 | 59 | // Created before running the user's configure script so that some things |
| 54 | 60 | // can be added during script execution such as strings. |
| ... | ... | @@ -62,10 +68,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 62 | 68 | assert(try graph.wip_configuration.addString("") == .empty); |
| 63 | 69 | assert(try graph.wip_configuration.addString("root") == .root); |
| 64 | 70 | |
| 65 | var arg_i: usize = 1; // Skip own executable name. | |
| 66 | ||
| 67 | const build_root_sub_path = expectArgOrFatal(args, &arg_i, "--build-root"); | |
| 68 | ||
| 69 | 71 | const cwd: Io.Dir = .cwd(); |
| 70 | 72 | |
| 71 | 73 | const build_root: std.Build.Cache.Path = .{ |
lib/std/Build.zig+2-4| ... | ... | @@ -80,6 +80,7 @@ pub const Graph = struct { |
| 80 | 80 | arena: Allocator, |
| 81 | 81 | system_integration_options: std.StringArrayHashMapUnmanaged(SystemLibraryMode) = .empty, |
| 82 | 82 | system_package_mode: bool = false, |
| 83 | zig_exe: []const u8, | |
| 83 | 84 | environ_map: process.Environ.Map, |
| 84 | 85 | needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .empty, |
| 85 | 86 | /// Information about the native target. Computed before build() is invoked. |
| ... | ... | @@ -143,10 +144,7 @@ pub const Graph = struct { |
| 143 | 144 | /// Allocates using the global process arena, failing the build on |
| 144 | 145 | /// allocation failure. |
| 145 | 146 | pub fn create(graph: *const Graph, comptime T: type) *T { |
| 146 | return if (@sizeOf(T) == 0) | |
| 147 | comptime @ptrFromInt(mem.alignBackward(usize, std.math.maxInt(usize), @alignOf(T))) | |
| 148 | else | |
| 149 | @ptrCast(graph.arena.allocBytesWithAlignment(.of(T), @sizeOf(T), @returnAddress()) catch @panic("OOM")); | |
| 147 | return @ptrCast(graph.arena.allocBytesAligned(.of(T), @sizeOf(T), @returnAddress()) catch @panic("OOM")); | |
| 150 | 148 | } |
| 151 | 149 | }; |
| 152 | 150 |
lib/std/mem/Allocator.zig+3-3| ... | ... | @@ -169,7 +169,7 @@ pub fn create(a: Allocator, comptime T: type) Error!*T { |
| 169 | 169 | const ptr = comptime std.mem.alignBackward(usize, math.maxInt(usize), @alignOf(T)); |
| 170 | 170 | return @ptrFromInt(ptr); |
| 171 | 171 | } |
| 172 | const ptr: *T = @ptrCast(try a.allocBytesWithAlignment(.of(T), @sizeOf(T), @returnAddress())); | |
| 172 | const ptr: *T = @ptrCast(try a.allocBytesAligned(.of(T), @sizeOf(T), @returnAddress())); | |
| 173 | 173 | return ptr; |
| 174 | 174 | } |
| 175 | 175 | |
| ... | ... | @@ -285,10 +285,10 @@ fn allocWithSizeAndAlignment( |
| 285 | 285 | return_address: usize, |
| 286 | 286 | ) Error![*]align(alignment.toByteUnits()) u8 { |
| 287 | 287 | const byte_count = math.mul(usize, size, n) catch return error.OutOfMemory; |
| 288 | return self.allocBytesWithAlignment(alignment, byte_count, return_address); | |
| 288 | return self.allocBytesAligned(alignment, byte_count, return_address); | |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | fn allocBytesWithAlignment( | |
| 291 | pub fn allocBytesAligned( | |
| 292 | 292 | self: Allocator, |
| 293 | 293 | comptime alignment: Alignment, |
| 294 | 294 | byte_count: usize, |
src/main.zig+1| ... | ... | @@ -4982,6 +4982,7 @@ fn cmdBuild( |
| 4982 | 4982 | _ = make_argv.addOneAssumeCapacity(); // maker executable |
| 4983 | 4983 | |
| 4984 | 4984 | make_argv.addManyAsArrayAssumeCapacity(2).* = .{ "--zig", self_exe_path }; |
| 4985 | configure_argv.addManyAsArrayAssumeCapacity(2).* = .{ "--zig", self_exe_path }; | |
| 4985 | 4986 | |
| 4986 | 4987 | make_argv.addManyAsArrayAssumeCapacity(2).* = .{ "--zig-lib-dir", undefined }; |
| 4987 | 4988 | const argv_index_zig_lib_dir = make_argv.items.len - 1; |
test/tests.zig+2-2| ... | ... | @@ -2890,7 +2890,7 @@ pub fn addCases( |
| 2890 | 2890 | |
| 2891 | 2891 | var cases = @import("src/Cases.zig").init(gpa, arena, io); |
| 2892 | 2892 | |
| 2893 | var dir = try b.build_root.handle.openDir(io, "test/cases", .{ .iterate = true }); | |
| 2893 | var dir = try b.root.openDir(io, "test/cases", .{ .iterate = true }); | |
| 2894 | 2894 | defer dir.close(io); |
| 2895 | 2895 | |
| 2896 | 2896 | cases.addFromDir(dir, b); |
| ... | ... | @@ -2948,7 +2948,7 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons |
| 2948 | 2948 | }), |
| 2949 | 2949 | }); |
| 2950 | 2950 | |
| 2951 | var dir = try b.build_root.handle.openDir(io, "test/incremental", .{ .iterate = true }); | |
| 2951 | var dir = try b.root.openDir(io, "test/incremental", .{ .iterate = true }); | |
| 2952 | 2952 | defer dir.close(io); |
| 2953 | 2953 | |
| 2954 | 2954 | var it = try dir.walk(b.graph.arena); |