Skip to content

Commit

Permalink
[update #38] 1.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tiawl authored May 1, 2024
2 parents 8280b78 + 81bdb07 commit b6fce92
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion DOC.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Documentation

**This documentation describes the 1.9.4 release of this repository.**
**This documentation describes the 1.9.5 release**

The package is divided into 4 submodules:
* `build/command.zig` gathers files or processes manipulation utilities used during the updating step,
Expand Down
9 changes: 9 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ pub fn build (builder: *std.Build) !void
{
_ = builder.addModule ("toolbox",
.{ .root_source_file = builder.addWriteFiles ().add ("empty.zig", ""), });

const clean_step = builder.step ("clean", "Clean up");

clean_step.dependOn (&builder.addRemoveDirTree (builder.install_path).step);
if (@import ("builtin").os.tag != .windows)
{
clean_step.dependOn (&builder.addRemoveDirTree (
builder.pathFromRoot ("zig-cache")).step);
}
}
59 changes: 26 additions & 33 deletions build/dependencies.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub const Repository = struct
fn getUrl (self: @This ()) [] const u8 { return self.__url; }
fn getLatest (self: @This ()) [] const u8 { return self.__latest; }

// mandatory new function
// mandatory init function
fn new (builder: *std.Build, name: [] const u8, url: [] const u8, latest: ?[] const u8) @This ()
{
var self = @This () {
Expand Down Expand Up @@ -139,7 +139,9 @@ pub const Dependencies = struct
pub fn getInterns (self: @This ()) std.StringHashMap (Repository).KeyIterator { return self.__intern.keyIterator (); }
pub fn getExterns (self: @This ()) std.StringHashMap (Repository).KeyIterator { return self.__extern.keyIterator (); }

pub fn init (builder: *std.Build, name: [] const u8, intern_proto: anytype,
// mandatory init function
pub fn init (builder: *std.Build, name: [] const u8,
paths: [] const [] const u8, intern_proto: anytype,
extern_proto: anytype) !@This ()
{
var self = @This () {
Expand Down Expand Up @@ -167,7 +169,7 @@ pub const Dependencies = struct
if (fetch)
{
try self.fetchExtern (builder);
try self.fetchIntern (builder, name);
try self.fetchIntern (builder, name, paths);
try fetchSubmodules (builder);
std.process.exit (0);
}
Expand Down Expand Up @@ -200,7 +202,7 @@ pub const Dependencies = struct
}

fn fetchIntern (self: @This (), builder: *std.Build,
name: [] const u8) !void
name: [] const u8, additional_paths: [] const [] const u8) !void
{
var buffer = std.ArrayList (u8).init (builder.allocator);
const writer = buffer.writer ();
Expand All @@ -219,39 +221,30 @@ pub const Dependencies = struct
.{ .iterate = true, });
defer build_dir.close ();

{
var it = build_dir.iterate ();
while (try it.next ()) |*entry|
{
if (!std.mem.startsWith (u8, entry.name, ".") and
!std.mem.eql (u8, entry.name, "zig-cache") and
!std.mem.eql (u8, entry.name, "zig-out") and
!try isSubmodule (builder, entry.name))
try writer.print ("\"{s}\",\n", .{ entry.name, });
}
}
try writer.print ("\"build.zig\",\n\"build.zig.zon\",\n", .{});

for (additional_paths) |path|
try writer.print ("\"{s}\",\n", .{ path, });

try writer.print ("{c},\n.dependencies = .{c}\n", .{ '}', '{', });

var it = self.getInterns ();
while (it.next ()) |key|
{
var it = self.getInterns ();
while (it.next ()) |key|
{
const url = try std.fmt.allocPrint (builder.allocator,
"{s}/archive/refs/tags/{s}.tar.gz",
.{ self.getIntern (key.*).getUrl (),
self.getIntern (key.*).getLatest (), });
var hash: [] u8 = undefined;
try run (builder, .{ .argv = &[_][] const u8 { "zig", "fetch", url, },
.stdout = &hash, });
try writer.print (
\\.{s} = .{c}
\\ .url = "{s}",
\\ .hash = "{s}",
\\{c},
\\
, .{ key.*, '{', url, hash, '}', });
}
const url = try std.fmt.allocPrint (builder.allocator,
"{s}/archive/refs/tags/{s}.tar.gz",
.{ self.getIntern (key.*).getUrl (),
self.getIntern (key.*).getLatest (), });
var hash: [] u8 = undefined;
try run (builder, .{ .argv = &[_][] const u8 { "zig", "fetch", url, },
.stdout = &hash, });
try writer.print (
\\.{s} = .{c}
\\ .url = "{s}",
\\ .hash = "{s}",
\\{c},
\\
, .{ key.*, '{', url, hash, '}', });
}

try writer.print ("{c},\n{c}\n", .{ '}', '}', });
Expand Down

0 comments on commit b6fce92

Please sign in to comment.