Skip to content

Commit 4b45cb3

Browse files
committedDec 12, 2024·
update_zon: port bash to zig
1 parent 9d8abf4 commit 4b45cb3

File tree

2 files changed

+171
-137
lines changed

2 files changed

+171
-137
lines changed
 

‎update_zon.sh

-137
This file was deleted.

‎update_zon.zig

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
const std = @import("std");
2+
const process = std.process;
3+
const fmt = std.fmt;
4+
5+
const boost_version = "boost-1.86.0";
6+
7+
pub fn main() !void {
8+
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
9+
const allocator = gpa.allocator();
10+
defer std.debug.assert(gpa.deinit() == .ok);
11+
12+
for (git_urls) |git_url| {
13+
// Extract package name from URL
14+
const pkg_name = blk: {
15+
var iter = std.mem.splitSequence(u8, git_url, "/");
16+
while (iter.next()) |part| {
17+
if (std.mem.indexOf(u8, part, "#") != null) {
18+
break :blk part[0..std.mem.indexOf(u8, part, "#").?];
19+
}
20+
}
21+
unreachable;
22+
};
23+
24+
const saved_pkg = try fmt.allocPrint(allocator, "--save={s}", .{pkg_name});
25+
defer allocator.free(saved_pkg);
26+
27+
// zig fetch command
28+
const args = [_][]const u8{
29+
"zig",
30+
"fetch",
31+
saved_pkg,
32+
git_url,
33+
};
34+
35+
// Execute command
36+
const result = try process.Child.run(.{
37+
.allocator = allocator,
38+
.argv = &args,
39+
});
40+
defer allocator.free(result.stderr);
41+
42+
if (result.stderr.len > 0) {
43+
std.debug.print("Fetching {s}: {s}", .{
44+
pkg_name,
45+
result.stderr,
46+
});
47+
}
48+
}
49+
}
50+
51+
const git_urls = [_][]const u8{
52+
"git+https://github.com/boostorg/algorithm#" ++ boost_version,
53+
"git+https://github.com/boostorg/asio#" ++ boost_version,
54+
"git+https://github.com/boostorg/assert#" ++ boost_version,
55+
"git+https://github.com/boostorg/bind#" ++ boost_version,
56+
"git+https://github.com/boostorg/config#" ++ boost_version,
57+
"git+https://github.com/boostorg/container#" ++ boost_version,
58+
"git+https://github.com/boostorg/core#" ++ boost_version,
59+
"git+https://github.com/boostorg/detail#" ++ boost_version,
60+
"git+https://github.com/boostorg/describe#" ++ boost_version,
61+
"git+https://github.com/boostorg/endian#" ++ boost_version,
62+
"git+https://github.com/boostorg/container_hash#" ++ boost_version,
63+
"git+https://github.com/boostorg/iterator#" ++ boost_version,
64+
"git+https://github.com/boostorg/intrusive#" ++ boost_version,
65+
"git+https://github.com/boostorg/logic#" ++ boost_version,
66+
"git+https://github.com/boostorg/mp11#" ++ boost_version,
67+
"git+https://github.com/boostorg/mpl#" ++ boost_version,
68+
"git+https://github.com/boostorg/optional#" ++ boost_version,
69+
"git+https://github.com/boostorg/smart_ptr#" ++ boost_version,
70+
"git+https://github.com/boostorg/move#" ++ boost_version,
71+
"git+https://github.com/boostorg/static_assert#" ++ boost_version,
72+
"git+https://github.com/boostorg/static_string#" ++ boost_version,
73+
"git+https://github.com/boostorg/system#" ++ boost_version,
74+
"git+https://github.com/boostorg/throw_exception#" ++ boost_version,
75+
"git+https://github.com/boostorg/tuple#" ++ boost_version,
76+
"git+https://github.com/boostorg/type_traits#" ++ boost_version,
77+
"git+https://github.com/boostorg/utility#" ++ boost_version,
78+
"git+https://github.com/boostorg/winapi#" ++ boost_version,
79+
"git+https://github.com/boostorg/functional#" ++ boost_version,
80+
"git+https://github.com/boostorg/json#" ++ boost_version,
81+
"git+https://github.com/boostorg/io#" ++ boost_version,
82+
"git+https://github.com/boostorg/range#" ++ boost_version,
83+
"git+https://github.com/boostorg/regex#" ++ boost_version,
84+
"git+https://github.com/boostorg/variant#" ++ boost_version,
85+
"git+https://github.com/boostorg/variant2#" ++ boost_version,
86+
"git+https://github.com/boostorg/date_time#" ++ boost_version,
87+
"git+https://github.com/boostorg/outcome#" ++ boost_version,
88+
"git+https://github.com/boostorg/hana#" ++ boost_version,
89+
"git+https://github.com/boostorg/numeric_conversion#" ++ boost_version,
90+
"git+https://github.com/boostorg/concept_check#" ++ boost_version,
91+
"git+https://github.com/boostorg/predef#" ++ boost_version,
92+
"git+https://github.com/boostorg/preprocessor#" ++ boost_version,
93+
"git+https://github.com/boostorg/align#" ++ boost_version,
94+
"git+https://github.com/boostorg/graph#" ++ boost_version,
95+
"git+https://github.com/boostorg/pfr#" ++ boost_version,
96+
"git+https://github.com/boostorg/math#" ++ boost_version,
97+
"git+https://github.com/boostorg/lexical_cast#" ++ boost_version,
98+
"git+https://github.com/boostorg/type_index#" ++ boost_version,
99+
"git+https://github.com/boostorg/beast#" ++ boost_version,
100+
"git+https://github.com/boostorg/chrono#" ++ boost_version,
101+
"git+https://github.com/boostorg/unordered#" ++ boost_version,
102+
"git+https://github.com/boostorg/any#" ++ boost_version,
103+
"git+https://github.com/boostorg/url#" ++ boost_version,
104+
"git+https://github.com/boostorg/multi_array#" ++ boost_version,
105+
"git+https://github.com/boostorg/integer#" ++ boost_version,
106+
"git+https://github.com/boostorg/array#" ++ boost_version,
107+
"git+https://github.com/boostorg/safe_numerics#" ++ boost_version,
108+
"git+https://github.com/boostorg/filesystem#" ++ boost_version,
109+
"git+https://github.com/boostorg/compute#" ++ boost_version,
110+
"git+https://github.com/boostorg/mysql#" ++ boost_version,
111+
"git+https://github.com/boostorg/sort#" ++ boost_version,
112+
"git+https://github.com/boostorg/stacktrace#" ++ boost_version,
113+
"git+https://github.com/boostorg/signals2#" ++ boost_version,
114+
"git+https://github.com/boostorg/interprocess#" ++ boost_version,
115+
"git+https://github.com/boostorg/context#" ++ boost_version,
116+
"git+https://github.com/boostorg/timer#" ++ boost_version,
117+
"git+https://github.com/boostorg/wave#" ++ boost_version,
118+
"git+https://github.com/boostorg/atomic#" ++ boost_version,
119+
"git+https://github.com/boostorg/scope#" ++ boost_version,
120+
"git+https://github.com/boostorg/process#" ++ boost_version,
121+
"git+https://github.com/boostorg/fusion#" ++ boost_version,
122+
"git+https://github.com/boostorg/function#" ++ boost_version,
123+
"git+https://github.com/boostorg/spirit#" ++ boost_version,
124+
"git+https://github.com/boostorg/cobalt#" ++ boost_version,
125+
"git+https://github.com/boostorg/phoenix#" ++ boost_version,
126+
"git+https://github.com/boostorg/locale#" ++ boost_version,
127+
"git+https://github.com/boostorg/uuid#" ++ boost_version,
128+
"git+https://github.com/boostorg/nowide#" ++ boost_version,
129+
"git+https://github.com/boostorg/circular_buffer#" ++ boost_version,
130+
"git+https://github.com/boostorg/leaf#" ++ boost_version,
131+
"git+https://github.com/boostorg/lockfree#" ++ boost_version,
132+
"git+https://github.com/boostorg/redis#" ++ boost_version,
133+
"git+https://github.com/boostorg/geometry#" ++ boost_version,
134+
"git+https://github.com/boostorg/crc#" ++ boost_version,
135+
"git+https://github.com/boostorg/compat#" ++ boost_version,
136+
"git+https://github.com/boostorg/bimap#" ++ boost_version,
137+
"git+https://github.com/boostorg/tokenizer#" ++ boost_version,
138+
"git+https://github.com/boostorg/parameter#" ++ boost_version,
139+
"git+https://github.com/boostorg/callable_traits#" ++ boost_version,
140+
"git+https://github.com/boostorg/odeint#" ++ boost_version,
141+
"git+https://github.com/boostorg/ublas#" ++ boost_version,
142+
"git+https://github.com/boostorg/serialization#" ++ boost_version,
143+
"git+https://github.com/boostorg/iostreams#" ++ boost_version,
144+
"git+https://github.com/boostorg/type_erasure#" ++ boost_version,
145+
"git+https://github.com/boostorg/typeof#" ++ boost_version,
146+
"git+https://github.com/boostorg/units#" ++ boost_version,
147+
"git+https://github.com/boostorg/function_types#" ++ boost_version,
148+
"git+https://github.com/boostorg/hof#" ++ boost_version,
149+
"git+https://github.com/boostorg/interval#" ++ boost_version,
150+
"git+https://github.com/boostorg/local_function#" ++ boost_version,
151+
"git+https://github.com/boostorg/log#" ++ boost_version,
152+
"git+https://github.com/boostorg/charconv#" ++ boost_version,
153+
"git+https://github.com/boostorg/conversion#" ++ boost_version,
154+
"git+https://github.com/boostorg/heap#" ++ boost_version,
155+
"git+https://github.com/boostorg/msm#" ++ boost_version,
156+
"git+https://github.com/boostorg/coroutine2#" ++ boost_version,
157+
"git+https://github.com/boostorg/pool#" ++ boost_version,
158+
"git+https://github.com/boostorg/format#" ++ boost_version,
159+
"git+https://github.com/boostorg/fiber#" ++ boost_version,
160+
"git+https://github.com/boostorg/proto#" ++ boost_version,
161+
"git+https://github.com/boostorg/property_tree#" ++ boost_version,
162+
"git+https://github.com/boostorg/exception#" ++ boost_version,
163+
"git+https://github.com/boostorg/multi_index#" ++ boost_version,
164+
"git+https://github.com/boostorg/random#" ++ boost_version,
165+
"git+https://github.com/boostorg/dll#" ++ boost_version,
166+
"git+https://github.com/boostorg/multiprecision#" ++ boost_version,
167+
"git+https://github.com/boostorg/gil#" ++ boost_version,
168+
"git+https://github.com/boostorg/python#" ++ boost_version,
169+
"git+https://github.com/boostorg/property_map#" ++ boost_version,
170+
"git+https://github.com/boostorg/property_map_parallel#" ++ boost_version,
171+
};

0 commit comments

Comments
 (0)
Please sign in to comment.