Browse Source

G-096: zig 0.16.0 adopted - recipe ported to 0.16 build API, suite pin repointed, punk-getzig pin 0.16.0

The build016 experiment port lands in the tracked recipe (root_module/
createModule creation, addLibrary+linkage, .root_module.* method sweep,
linkSystemLibrary options arg, array_list.Managed, Io.Dir dir-walks with
b.graph.io, wrapfiletofile ported to the 0.16 entry/Io idiom). 0.14 support
deprecated per user direction; 0.14.1 remains archived on punkbin. Verified
on the pinned default (bin/tools/zig-x86_64-windows-0.16.0): build PASS,
shells 9.0.5, tcl-test parity 557/357/200/0 identical to the 0.14.1 build.
punk-getzig payload pins -> 0.16.0 (windows zip + linux tarball), re-wrapped
checkfile ERROR-free, ps1 twin refreshed. punkbin commit 54714d7 holds the
0.16.0 archive; push pending gitea recovery (server currently 500s).

Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com
master
Julian Noble 2 weeks ago
parent
commit
4b87720328
  1. 15
      bin/punk-getzig.cmd
  2. 23
      goals/G-096-zig-buildsuite-piperepl.md
  3. 46
      src/buildsuites/suite_tcl90/README.md
  4. 554
      src/buildsuites/suite_tcl90/build905.zig
  5. 101
      src/buildsuites/suite_tcl90/build_libtommath/build_libtommath.zig
  6. 37
      src/buildsuites/suite_tcl90/build_tclthread/build_tclthread.zig
  7. 33
      src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_shared.zig
  8. 31
      src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_static.zig
  9. 108
      src/buildsuites/suite_tcl90/build_zlib/build_zlib.zig
  10. 7
      src/buildsuites/suite_tcl90/suite.tcl
  11. 65
      src/buildsuites/suite_tcl90/tools/wrapfiletofile.zig
  12. 2
      src/scriptapps/bin/punk-getzig.bash
  13. 2
      src/scriptapps/bin/punk-getzig.ps1

15
bin/punk-getzig.cmd

@ -1282,7 +1282,7 @@ fi
#tarball="zig-x86_64-windows-0.15.2.zip" #tarball="zig-x86_64-windows-0.15.2.zip"
#tarball="zig-x86_64-freebsd-0.15.2.tar.xz" #tarball="zig-x86_64-freebsd-0.15.2.tar.xz"
tarball="zig-x86_64-linux-0.15.2.tar.xz" tarball="zig-x86_64-linux-0.16.0.tar.xz"
automation_name="punkshell+julian@precisium.com.au_target_by_latency" automation_name="punkshell+julian@precisium.com.au_target_by_latency"
uristring="https://ziglang.org" uristring="https://ziglang.org"
@ -1612,7 +1612,14 @@ $zigexe = Join-Path $zigfolder -ChildPath "zig.exe"
#$releasearchive = "zig-x86_64-windows-0.15.1.zip" ;#zip on windows, tarball on every other platform #$releasearchive = "zig-x86_64-windows-0.15.1.zip" ;#zip on windows, tarball on every other platform
#$releasearchive = "zig-x86_64-windows-0.16.0-dev.254+6dd0270a1.zip" #$releasearchive = "zig-x86_64-windows-0.16.0-dev.254+6dd0270a1.zip"
#$releasearchive = "zig-x86_64-windows-0.16.0-dev.2193+fc517bd01.zip" #$releasearchive = "zig-x86_64-windows-0.16.0-dev.2193+fc517bd01.zip"
$releasearchive = "zig-x86_64-windows-0.15.2.zip" $releasearchive = "zig-x86_64-windows-0.16.0.zip"
#single-source the pinned version from the archive name (used for ziglang.org release URLs)
if ($releasearchive -match 'zig-x86_64-windows-(.+)\.zip$') {
$releaseversion = $Matches[1]
} else {
Write-Error "cannot derive zig version from releasearchive name '$releasearchive'"
exit 1
}
Write-Output "powershell version: $($PSVersionTable.PSVersion)" Write-Output "powershell version: $($PSVersionTable.PSVersion)"
if (Get-Command $zigexe -ErrorAction SilentlyContinue) { if (Get-Command $zigexe -ErrorAction SilentlyContinue) {
@ -1906,8 +1913,8 @@ if ($mirrors_response.StatusCode -eq 200) {
$uristring = $hostinfo.uri $uristring = $hostinfo.uri
if ($uristring -eq "https://ziglang.org") { if ($uristring -eq "https://ziglang.org") {
#if it's a release #if it's a release
$full_uristring = "${uristring}/download/0.15.1/${releasearchive}?source=${automation_name}" $full_uristring = "${uristring}/download/${releaseversion}/${releasearchive}?source=${automation_name}"
$sig_uristring = "${uristring}/download/0.15.1/${releasearchive}.minisig?source=${automation_name}" $sig_uristring = "${uristring}/download/${releaseversion}/${releasearchive}.minisig?source=${automation_name}"
#if it's a pre-release?? /builds/${prereleasearchive} ? #if it's a pre-release?? /builds/${prereleasearchive} ?
} else { } else {
$full_uristring = "${uristring}/${releasearchive}?source=${automation_name}" $full_uristring = "${uristring}/${releasearchive}?source=${automation_name}"

23
goals/G-096-zig-buildsuite-piperepl.md

@ -242,12 +242,27 @@ future tclkit work references TEMP_REFERENCE/metakit + TEMP_REFERENCE/KitCreator
critcl/testsuite-gating are new scope vs this goal's contract - candidate follow-on critcl/testsuite-gating are new scope vs this goal's contract - candidate follow-on
goal to draft (proposal-first). goal to draft (proposal-first).
### 2026-07-20 increment 5: zig 0.16.0 ADOPTED (user approval "as recommended")
- The build016 port landed into the tracked recipe (7 files; src/main.zig unchanged).
The recipe is now 0.16-API only - 0.14 support deprecated per the user's intent; the
0.14-era recipe remains in git history and zig 0.14.1 stays archived on punkbin.
- suite.tcl pinned default -> bin/tools/zig-x86_64-windows-0.16.0/zig.exe; README pin +
lineage sections updated (0.16 port deltas documented). Verified end-to-end on the
pinned default: build PASS (9.0.5 both shells) + tcl-test parity 557/357/200/0.
- punkbin: zig-x86_64-windows-0.16.0.zip + .minisig added with sha1sums regenerated
(NEW x2, no CHANGED), committed 54714d7 with provenance. PUSH PENDING: the gitea
remote is currently returning Internal Server Error (even ls-remote; the 0.14.1 push
succeeded earlier today) - retry when the server recovers.
- punk-getzig pins updated to 0.16.0 in both payloads (ps1 $releasearchive, bash
tarball zig-x86_64-linux-0.16.0.tar.xz), re-wrapped (checkfile ERROR-free), .ps1
twin refreshed. Its next run will replace bin/tools/zig (active 0.15.2) with 0.16.0.
Remaining for acceptance: Remaining for acceptance:
- punk-getzig per-version fetch argument, so the wrapper itself can materialize the - punk-getzig per-version fetch argument, so the wrapper itself can materialize
suite's pinned zig (pin currently 0.14.1; 0.16.0 adoption decision with the user - arbitrary pinned versions into versioned dirs (payload growth needs the 512-byte
the ported recipe awaits in _build/suite_tcl90/build016). Payload growth needs the spacer check on re-wrap).
512-byte spacer check on re-wrap.
- Rebase the piperepl patch onto current core-9-0-branch sources; build a - Rebase the piperepl patch onto current core-9-0-branch sources; build a
piperepl-enabled variant; behaviour matrix (TCLSH_PIPEREPL unset == stock on piperepl-enabled variant; behaviour matrix (TCLSH_PIPEREPL unset == stock on
tty/piped/script-arg forms; =1 with a script setting ::tclsh(dorepl) 1 -> live tty/piped/script-arg forms; =1 with a script setting ::tclsh(dorepl) 1 -> live

46
src/buildsuites/suite_tcl90/README.md

@ -22,16 +22,15 @@ toolchain at `bin/tools/zig-x86_64-windows-0.14.1/zig.exe` > `zig` on PATH.
## Pinned zig ## Pinned zig
The suite pin is **zig 0.14.1** (first official release in the recipe's 0.14 line; The suite pin is **zig 0.16.0** (current official release; adopted 2026-07-20 -
the recipe is validated against BOTH 0.14.1 and the original 0.14.0-dev.2074 - see the recipe was ported to the 0.16 build API and 0.14 support is deprecated; the
Lineage). The pinned archive `zig-x86_64-windows-0.14.1.zip` (+`.minisig`) is hosted 0.14-era recipe remains in git history and 0.14.1 remains archived on punkbin).
on the punkbin artifact repo (`win32-x86_64/tools/`, sha1sums recorded) - the same The pinned archive `zig-x86_64-windows-0.16.0.zip` (+`.minisig`) is hosted on the
mirror punk-getzig consults - and was minisign-verified against the zig release key punkbin artifact repo (`win32-x86_64/tools/`, sha1sums recorded) - the same mirror
before hosting. To materialize it: download from punkbin (or a ziglang community punk-getzig consults - and was minisign-verified against the zig release key before
mirror), verify the minisig, extract to `bin/tools/zig-x86_64-windows-0.14.1/`. hosting. punk-getzig's own pin is the same 0.16.0 (installed to `bin/tools/zig`);
punk-getzig currently installs only its own single pinned version (0.15.2) to a per-version fetch argument remains the intended enhancement for materializing
`bin/tools/zig`; a per-version fetch argument is the intended enhancement so it can arbitrary pinned versions into versioned dirs.
materialize the suite pin directly.
Zig object caches are kept **per zig version** (`.zig-cache-<version>` inside the Zig object caches are kept **per zig version** (`.zig-cache-<version>` inside the
staged build dir): caches must never be shared across zig versions (observed staged build dir): caches must never be shared across zig versions (observed
@ -93,10 +92,23 @@ tclAppInit's `_tmain` is `wmain` under `-DUNICODE`). Full provenance:
`goals/archive/G-076-tcl9-deadconsole-fix-adoption.md` (2026-07-20 entries). Goal `goals/archive/G-076-tcl9-deadconsole-fix-adoption.md` (2026-07-20 entries). Goal
contract for this suite: `goals/G-096-zig-buildsuite-piperepl.md`. contract for this suite: `goals/G-096-zig-buildsuite-piperepl.md`.
zig 0.14.1 compat deltas (2026-07-20, validated to keep dev.2074 working too): zig 0.14.1 compat deltas (2026-07-20): `b.host` -> `b.graph.host`; the redundant
`b.host` -> `b.graph.host`; the redundant second UNICODE tclMain add into the objs second UNICODE tclMain add into the objs lib removed; the exe's ansi tclMain copy
lib removed (0.14.1 links what dev.2074's archiver left unpulled); the exe's ansi compiles with `-UUNICODE -U_UNICODE -DTCL_ASCII_MAIN` (the zig cc driver can supply
tclMain copy compiles with `-UUNICODE -U_UNICODE -DTCL_ASCII_MAIN` (the zig cc windows-default defines, which made the "ansi" copy a duplicate UNICODE compile -
driver can supply windows-default defines, which made the "ansi" copy a duplicate upstream's TCL_ASCII_MAIN guard is the intended mechanism for the ascii variant).
UNICODE compile under 0.14.1 - upstream's TCL_ASCII_MAIN guard is the intended
mechanism for the ascii variant). zig 0.16.0 port (2026-07-20, adopted - recipe is now 0.16-API only): creation calls
take `.root_module = b.createModule(...)` (addLibrary with `.linkage` replaces
addShared/StaticLibrary); Compile method forwarders are gone - all
addCSourceFile(s)/addIncludePath/addObjectFile/addLibraryPath/linkLibrary/
addWin32ResourceFile calls go through `.root_module.`, `linkLibC()` becomes
`root_module.link_libc = true`, `linkSystemLibrary` takes an options arg
(linkSystemLibrary2 merged); `std.ArrayList(T).init` becomes
`std.array_list.Managed(T).init`; build-script dir walks use
`std.Io.Dir.cwd().openDir(b.graph.io, ...)` / `it.next(b.graph.io)`;
`tools/wrapfiletofile.zig` uses the 0.16 entry idiom (`main(init:
std.process.Init.Minimal)`, `init.args.toSlice`, an `std.Io.Threaded` io instance,
`Io.Dir.readFileAlloc`/`createFile`, `File.writeStreamingAll`, `cleanExit(io)`).
`mingw_unicode_entry_point` is unchanged in 0.16. Verified: full build PASS, shells
report 9.0.5, tcl-test parity identical to the 0.14.1 build (557/357/200/0).

554
src/buildsuites/suite_tcl90/build905.zig

File diff suppressed because it is too large Load Diff

101
src/buildsuites/suite_tcl90/build_libtommath/build_libtommath.zig

@ -6,28 +6,31 @@ const fs = std.fs;
// runner. // runner.
//pub fn build(b: *std.Build) !void {} //pub fn build(b: *std.Build) !void {}
pub fn build_libtommath(comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step.Compile { pub fn build_libtommath(comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.linkage = .static,
.name = "tommath", .name = "tommath",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
var flags = std.ArrayList([]const u8).init(b.allocator); var flags = std.array_list.Managed([]const u8).init(b.allocator);
defer flags.deinit(); defer flags.deinit();
//try flags.appendSlice(&.{ "-Wall", "-O2" }); //try flags.appendSlice(&.{ "-Wall", "-O2" });
try flags.appendSlice(&.{ "-Wall", "-O2", "-Wextra", "-Werror=return-type" }); try flags.appendSlice(&.{ "-Wall", "-O2", "-Wextra", "-Werror=return-type" });
//libtom relies on dead code elimination - see s_mp_rand_platform.c //libtom relies on dead code elimination - see s_mp_rand_platform.c
//The -O2 seems to fix the issue where dead code elimination is not performed (on windows anyway) //The -O2 seems to fix the issue where dead code elimination is not performed (on windows anyway)
var sources = std.ArrayList([]const u8).init(b.allocator); var sources = std.array_list.Managed([]const u8).init(b.allocator);
{ {
var dir = try fs.cwd().openDir(subdir, .{ .iterate = true }); var dir = try std.Io.Dir.cwd().openDir(b.graph.io, subdir, .{ .iterate = true });
defer dir.close(); defer dir.close(b.graph.io);
var it = dir.iterate(); var it = dir.iterate();
const allowed_exts = [_][]const u8{ const allowed_exts = [_][]const u8{
".c", ".c",
}; };
while (try it.next()) |entry| { while (try it.next(b.graph.io)) |entry| {
if (entry.kind == .file) { if (entry.kind == .file) {
const ext = fs.path.extension(entry.name); const ext = fs.path.extension(entry.name);
const include_file = for (allowed_exts) |e| { const include_file = for (allowed_exts) |e| {
@ -45,14 +48,14 @@ pub fn build_libtommath(comptime subdir: []const u8, b: *std.Build, target: std.
} }
//std.debug.print("sources: {any}",.{sources.items}); //std.debug.print("sources: {any}",.{sources.items});
lib.linkLibC(); lib.root_module.link_libc = true;
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
lib.linkSystemLibrary("advapi32"); //crypt lib.root_module.linkSystemLibrary("advapi32", .{}); //crypt
} }
//lib.addIncludePath(.{ .path = subdir }); //lib.root_module.addIncludePath(.{ .path = subdir });
lib.addIncludePath(b.path(subdir)); lib.root_module.addIncludePath(b.path(subdir));
lib.addIncludePath(b.path("../tcl90/generic")); //todo - fix lib.root_module.addIncludePath(b.path("../tcl90/generic")); //todo - fix
lib.addCSourceFiles(.{ lib.root_module.addCSourceFiles(.{
.files = sources.items, .files = sources.items,
.flags = flags.items, .flags = flags.items,
}); });
@ -64,34 +67,36 @@ pub fn build_libtommath(comptime subdir: []const u8, b: *std.Build, target: std.
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "test_libtommath", .name = "test_libtommath",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
exe.step.dependOn(&lib.step); exe.step.dependOn(&lib.step);
exe.linkLibC(); exe.root_module.link_libc = true;
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
//exe.linkSystemLibrary("netapi32"); //exe.root_module.linkSystemLibrary("netapi32", .{});
//exe.linkSystemLibrary("kernel32"); //exe.root_module.linkSystemLibrary("kernel32", .{});
//exe.linkSystemLibrary("user32"); //exe.root_module.linkSystemLibrary("user32", .{});
exe.linkSystemLibrary("advapi32"); //crypt exe.root_module.linkSystemLibrary("advapi32", .{}); //crypt
//exe.linkSystemLibrary("userenv"); //exe.root_module.linkSystemLibrary("userenv", .{});
//exe.linkSystemLibrary("ws2_32"); //exe.root_module.linkSystemLibrary("ws2_32", .{});
} }
//exe.addIncludePath(.{ .path = subdir }); //exe.root_module.addIncludePath(.{ .path = subdir });
exe.addIncludePath(b.path(subdir)); exe.root_module.addIncludePath(b.path(subdir));
//exe.addIncludePath(.{ .path = subdir ++ "/demo" }); //exe.root_module.addIncludePath(.{ .path = subdir ++ "/demo" });
exe.addIncludePath(b.path(subdir ++ "/demo")); exe.root_module.addIncludePath(b.path(subdir ++ "/demo"));
exe.addCSourceFile(.{ exe.root_module.addCSourceFile(.{
//.file = .{ .path = subdir ++ "/demo/test.c" }, //.file = .{ .path = subdir ++ "/demo/test.c" },
.file = b.path(subdir ++ "/demo/test.c"), .file = b.path(subdir ++ "/demo/test.c"),
.flags = flags.items, .flags = flags.items,
}); });
exe.addCSourceFile(.{ exe.root_module.addCSourceFile(.{
//.file = .{ .path = subdir ++ "/demo/shared.c" }, //.file = .{ .path = subdir ++ "/demo/shared.c" },
.file = b.path(subdir ++ "/demo/shared.c"), .file = b.path(subdir ++ "/demo/shared.c"),
.flags = flags.items, .flags = flags.items,
}); });
exe.linkLibrary(lib); exe.root_module.linkLibrary(lib);
// This declares intent for the executable to be installed into the // This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default // standard location when the user invokes the "install" step (the default
@ -107,30 +112,36 @@ pub fn build_libtommath(comptime subdir: []const u8, b: *std.Build, target: std.
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-Wl,--out-implib=libtommath.dll.a", "-Wl,--out-implib=libtommath.dll.a",
}); });
const dll = b.addSharedLibrary(.{ const dll = b.addLibrary(.{
.name = "libtommath", .linkage = .dynamic,
.name = "libtommath",
.root_module = b.createModule(.{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); }),
dll.linkLibC(); });
dll.linkSystemLibrary("advapi32"); //crypt dll.root_module.link_libc = true;
//dll.addIncludePath(.{ .path = subdir }); dll.root_module.linkSystemLibrary("advapi32", .{}); //crypt
dll.addIncludePath(b.path(subdir)); //dll.root_module.addIncludePath(.{ .path = subdir });
dll.addCSourceFiles(.{ dll.root_module.addIncludePath(b.path(subdir));
dll.root_module.addCSourceFiles(.{
.files = sources.items, .files = sources.items,
.flags = flags.items, .flags = flags.items,
}); });
b.installArtifact(dll); b.installArtifact(dll);
} else { } else {
const shlib_tom = b.addSharedLibrary(.{ const shlib_tom = b.addLibrary(.{
.name = "tommath", .linkage = .dynamic,
.name = "tommath",
.root_module = b.createModule(.{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); }),
shlib_tom.linkLibC(); });
//shlib_tom.addIncludePath(.{ .path = subdir }); shlib_tom.root_module.link_libc = true;
shlib_tom.addIncludePath(b.path(subdir)); //shlib_tom.root_module.addIncludePath(.{ .path = subdir });
shlib_tom.addCSourceFiles(.{ shlib_tom.root_module.addIncludePath(b.path(subdir));
shlib_tom.root_module.addCSourceFiles(.{
.files = sources.items, .files = sources.items,
.flags = flags.items, .flags = flags.items,
}); });

37
src/buildsuites/suite_tcl90/build_tclthread/build_tclthread.zig

@ -15,8 +15,10 @@ const mkvar_pkg_lib_file = "tcl9thread301.dll";
pub fn build_tclthread(comptime tcldir: []const u8, comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, stublib: *std.Build.Step.Compile) !*std.Build.Step.Compile { pub fn build_tclthread(comptime tcldir: []const u8, comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, stublib: *std.Build.Step.Compile) !*std.Build.Step.Compile {
const wrapfilecmd = b.addExecutable(.{ const wrapfilecmd = b.addExecutable(.{
.name = "wrapfiletofile", .name = "wrapfiletofile",
.root_source_file = b.path("tools/wrapfiletofile.zig"), .root_module = b.createModule(.{
.target = b.graph.host, .root_source_file = b.path("tools/wrapfiletofile.zig"),
.target = b.graph.host,
}),
}); });
const uuidcmd_step = b.addRunArtifact(wrapfilecmd); const uuidcmd_step = b.addRunArtifact(wrapfilecmd);
uuidcmd_step.addArgs(&.{ uuidcmd_step.addArgs(&.{
@ -66,13 +68,16 @@ pub fn build_tclthread(comptime tcldir: []const u8, comptime subdir: []const u8,
wf_uuidh.step.dependOn(&uuidcmd_step.step); wf_uuidh.step.dependOn(&uuidcmd_step.step);
b.getInstallStep().dependOn(&wf_uuidh.step); b.getInstallStep().dependOn(&wf_uuidh.step);
const lib = b.addSharedLibrary(.{ const lib = b.addLibrary(.{
.linkage = .dynamic,
.name = "tcl9thread301", .name = "tcl9thread301",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
//lib.step.dependOn(&wf_uuidh.step); //lib.step.dependOn(&wf_uuidh.step);
var flags = std.ArrayList([]const u8).init(b.allocator); var flags = std.array_list.Managed([]const u8).init(b.allocator);
defer flags.deinit(); defer flags.deinit();
//try flags.appendSlice(&.{ "-Wall", "-O2", "-fomit-frame-pointer", "-DNDEBUG" }); //try flags.appendSlice(&.{ "-Wall", "-O2", "-fomit-frame-pointer", "-DNDEBUG" });
try flags.appendSlice(&.{ "-Wall", "-O3", "-fomit-frame-pointer" }); try flags.appendSlice(&.{ "-Wall", "-O3", "-fomit-frame-pointer" });
@ -109,7 +114,7 @@ pub fn build_tclthread(comptime tcldir: []const u8, comptime subdir: []const u8,
}); });
} }
var tclthread_sources = std.ArrayList([]const u8).init(b.allocator); var tclthread_sources = std.array_list.Managed([]const u8).init(b.allocator);
try tclthread_sources.append(subdir ++ "/generic/threadNs.c"); try tclthread_sources.append(subdir ++ "/generic/threadNs.c");
try tclthread_sources.append(subdir ++ "/generic/threadCmd.c"); try tclthread_sources.append(subdir ++ "/generic/threadCmd.c");
try tclthread_sources.append(subdir ++ "/generic/threadSvCmd.c"); try tclthread_sources.append(subdir ++ "/generic/threadSvCmd.c");
@ -122,23 +127,23 @@ pub fn build_tclthread(comptime tcldir: []const u8, comptime subdir: []const u8,
try tclthread_sources.append(subdir ++ "/generic/tclXkeylist.c"); try tclthread_sources.append(subdir ++ "/generic/tclXkeylist.c");
//if (target.result.os.tag == .windows) { //if (target.result.os.tag == .windows) {
// lib.linkSystemLibrary("advapi32"); //crypt // lib.root_module.linkSystemLibrary("advapi32", .{}); //crypt
//} //}
lib.addIncludePath(b.path(subdir)); lib.root_module.addIncludePath(b.path(subdir));
lib.addIncludePath(b.path(subdir ++ "/generic")); lib.root_module.addIncludePath(b.path(subdir ++ "/generic"));
//generated threadUuid.h: current thread trunk #includes it (upstream makefiles //generated threadUuid.h: current thread trunk #includes it (upstream makefiles
//generate it into their build dir); using the generator's output dir as an include //generate it into their build dir); using the generator's output dir as an include
//path also gives the compile its dependency on the generation step. //path also gives the compile its dependency on the generation step.
lib.addIncludePath(threaduuid_file.dirname()); lib.root_module.addIncludePath(threaduuid_file.dirname());
lib.addIncludePath(b.path(tcldir ++ "/generic")); //todo - fix lib.root_module.addIncludePath(b.path(tcldir ++ "/generic")); //todo - fix
lib.addCSourceFiles(.{ lib.root_module.addCSourceFiles(.{
.files = tclthread_sources.items, .files = tclthread_sources.items,
.flags = flags.items, .flags = flags.items,
}); });
lib.linkLibrary(stublib); lib.root_module.linkLibrary(stublib);
lib.linkLibC(); lib.root_module.link_libc = true;
lib.addWin32ResourceFile(.{ lib.root_module.addWin32ResourceFile(.{
.file = b.path(subdir ++ "/win/thread.rc"), .file = b.path(subdir ++ "/win/thread.rc"),
.flags = &.{ .flags = &.{
"-DPACKAGE_MAJOR=3", "-DPACKAGE_MAJOR=3",

33
src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_shared.zig

@ -15,13 +15,16 @@ pub fn vfsadd_tclvfs_files(comptime tcldir: []const u8, comptime subdir: []const
} }
pub fn build_tclvfs(comptime tcldir: []const u8, comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, stublib: *std.Build.Step.Compile) !*std.Build.Step.Compile { pub fn build_tclvfs(comptime tcldir: []const u8, comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, stublib: *std.Build.Step.Compile) !*std.Build.Step.Compile {
//review - libname Vfs vs vfs??? //review - libname Vfs vs vfs???
const lib = b.addSharedLibrary(.{ const lib = b.addLibrary(.{
.linkage = .dynamic,
.name = "tcl9vfs142", .name = "tcl9vfs142",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
//_ = stublib; //_ = stublib;
var flags = std.ArrayList([]const u8).init(b.allocator); var flags = std.array_list.Managed([]const u8).init(b.allocator);
defer flags.deinit(); defer flags.deinit();
//try flags.appendSlice(&.{ "-Wall", "-O3" }); //try flags.appendSlice(&.{ "-Wall", "-O3" });
try flags.appendSlice(&.{ "-Wall", "-O3", "-fomit-frame-pointer" }); try flags.appendSlice(&.{ "-Wall", "-O3", "-fomit-frame-pointer" });
@ -45,25 +48,25 @@ pub fn build_tclvfs(comptime tcldir: []const u8, comptime subdir: []const u8, b:
} }
//-DBUILD_VFS only on windows? value? //-DBUILD_VFS only on windows? value?
var sources = std.ArrayList([]const u8).init(b.allocator); var sources = std.array_list.Managed([]const u8).init(b.allocator);
try sources.append(subdir ++ "/generic/vfs.c"); try sources.append(subdir ++ "/generic/vfs.c");
lib.addIncludePath(b.path(subdir)); lib.root_module.addIncludePath(b.path(subdir));
lib.addIncludePath(b.path(subdir ++ "/generic")); lib.root_module.addIncludePath(b.path(subdir ++ "/generic"));
lib.addIncludePath(b.path(tcldir ++ "/generic")); lib.root_module.addIncludePath(b.path(tcldir ++ "/generic"));
lib.addIncludePath(b.path(tcldir ++ "/generic")); lib.root_module.addIncludePath(b.path(tcldir ++ "/generic"));
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
lib.addIncludePath(b.path(tcldir ++ "/win")); lib.root_module.addIncludePath(b.path(tcldir ++ "/win"));
} else { } else {
lib.addIncludePath(b.path(tcldir ++ "/unix")); lib.root_module.addIncludePath(b.path(tcldir ++ "/unix"));
} }
lib.addCSourceFiles(.{ lib.root_module.addCSourceFiles(.{
.files = sources.items, .files = sources.items,
.flags = flags.items, .flags = flags.items,
}); });
lib.linkLibrary(stublib); lib.root_module.linkLibrary(stublib);
lib.linkLibC(); lib.root_module.link_libc = true;
lib.addWin32ResourceFile(.{ lib.root_module.addWin32ResourceFile(.{
.file = b.path(subdir ++ "/win/tclvfs.rc"), .file = b.path(subdir ++ "/win/tclvfs.rc"),
.flags = &.{ .flags = &.{
"-DPACKAGE_MAJOR=1", "-DPACKAGE_MAJOR=1",

31
src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_static.zig

@ -15,14 +15,17 @@ pub fn vfsadd_tclvfs_files(comptime tcldir: []const u8, comptime subdir: []const
} }
pub fn build_tclvfs(comptime tcldir: []const u8, comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, stublib: *std.Build.Step.Compile) !*std.Build.Step.Compile { pub fn build_tclvfs(comptime tcldir: []const u8, comptime subdir: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, stublib: *std.Build.Step.Compile) !*std.Build.Step.Compile {
//review - libname Vfs vs vfs??? //review - libname Vfs vs vfs???
const slib = b.addStaticLibrary(.{ const slib = b.addLibrary(.{
.linkage = .static,
.name = "Vfs", .name = "Vfs",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
_ = stublib; _ = stublib;
var flags = std.ArrayList([]const u8).init(b.allocator); var flags = std.array_list.Managed([]const u8).init(b.allocator);
defer flags.deinit(); defer flags.deinit();
//try flags.appendSlice(&.{ "-Wall", "-O3" }); //try flags.appendSlice(&.{ "-Wall", "-O3" });
try flags.appendSlice(&.{ "-Wall", "-O2", "-fomit-frame-pointer" }); try flags.appendSlice(&.{ "-Wall", "-O2", "-fomit-frame-pointer" });
@ -44,21 +47,21 @@ pub fn build_tclvfs(comptime tcldir: []const u8, comptime subdir: []const u8, b:
}); });
//-DBUILD_VFS only on windows? value? //-DBUILD_VFS only on windows? value?
var sources = std.ArrayList([]const u8).init(b.allocator); var sources = std.array_list.Managed([]const u8).init(b.allocator);
try sources.append(subdir ++ "/generic/vfs.c"); try sources.append(subdir ++ "/generic/vfs.c");
slib.addIncludePath(b.path(subdir)); slib.root_module.addIncludePath(b.path(subdir));
slib.addIncludePath(b.path(subdir ++ "/generic")); slib.root_module.addIncludePath(b.path(subdir ++ "/generic"));
slib.addIncludePath(b.path(tcldir ++ "/generic")); slib.root_module.addIncludePath(b.path(tcldir ++ "/generic"));
slib.addIncludePath(b.path(tcldir ++ "/generic")); slib.root_module.addIncludePath(b.path(tcldir ++ "/generic"));
slib.addIncludePath(b.path(tcldir ++ "/win")); slib.root_module.addIncludePath(b.path(tcldir ++ "/win"));
slib.addCSourceFiles(.{ slib.root_module.addCSourceFiles(.{
.files = sources.items, .files = sources.items,
.flags = flags.items, .flags = flags.items,
}); });
//slib.linkLibrary(stublib); //slib.root_module.linkLibrary(stublib);
slib.linkLibC(); slib.root_module.link_libc = true;
slib.addWin32ResourceFile(.{ slib.root_module.addWin32ResourceFile(.{
.file = b.path(subdir ++ "/win/tclvfs.rc"), .file = b.path(subdir ++ "/win/tclvfs.rc"),
.flags = &.{ .flags = &.{
"-DPACKAGE_MAJOR=1", "-DPACKAGE_MAJOR=1",

108
src/buildsuites/suite_tcl90/build_zlib/build_zlib.zig

@ -9,12 +9,15 @@ pub fn build_zlib(comptime subdir: []const u8, b: *std.Build, target: std.Build.
statlibname = "z"; statlibname = "z";
} }
const statlib = b.addStaticLibrary(.{ const statlib = b.addLibrary(.{
.linkage = .static,
.name = statlibname, .name = statlibname,
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
var zlib_flags = std.ArrayList([]const u8).init(b.allocator); var zlib_flags = std.array_list.Managed([]const u8).init(b.allocator);
defer zlib_flags.deinit(); defer zlib_flags.deinit();
//try zlib_flags.appendSlice(&.{ "-Wall", "-static-libgcc", "-Wno-error=implicit-function-declaration", "-O3" }); //DL_info undeclared //try zlib_flags.appendSlice(&.{ "-Wall", "-static-libgcc", "-Wno-error=implicit-function-declaration", "-O3" }); //DL_info undeclared
//try zlib_flags.appendSlice(&.{ "-Wall", "-static-libgcc", "-O3" }); //DL_info undeclared //try zlib_flags.appendSlice(&.{ "-Wall", "-static-libgcc", "-O3" }); //DL_info undeclared
@ -32,10 +35,10 @@ pub fn build_zlib(comptime subdir: []const u8, b: *std.Build, target: std.Build.
//try zlib_flags.appendSlice(&.{"-O"}); //C99 and later do not support implicit function declarations //try zlib_flags.appendSlice(&.{"-O"}); //C99 and later do not support implicit function declarations
//try zlib_flags.appendSlice(&.{ "-O3", "-Wall", "-Wwrite-strings", "-Wpointer-arith", "-Wconversion", "-Wstrict-prototypes", "-Wmissing-prototypes" }); //try zlib_flags.appendSlice(&.{ "-O3", "-Wall", "-Wwrite-strings", "-Wpointer-arith", "-Wconversion", "-Wstrict-prototypes", "-Wmissing-prototypes" });
var zlib_sources = std.ArrayList([]const u8).init(b.allocator); var zlib_sources = std.array_list.Managed([]const u8).init(b.allocator);
{ {
var dir = try fs.cwd().openDir(subdir, .{ .iterate = true }); var dir = try std.Io.Dir.cwd().openDir(b.graph.io, subdir, .{ .iterate = true });
defer dir.close(); defer dir.close(b.graph.io);
//var walker = try dir.walk(b.allocator); //var walker = try dir.walk(b.allocator);
//defer walker.deinit(); //defer walker.deinit();
@ -44,7 +47,7 @@ pub fn build_zlib(comptime subdir: []const u8, b: *std.Build, target: std.Build.
const allowed_exts = [_][]const u8{ const allowed_exts = [_][]const u8{
".c", ".c",
}; };
while (try it.next()) |entry| { while (try it.next(b.graph.io)) |entry| {
if (entry.kind == .file) { if (entry.kind == .file) {
const ext = fs.path.extension(entry.name); const ext = fs.path.extension(entry.name);
const include_file = for (allowed_exts) |e| { const include_file = for (allowed_exts) |e| {
@ -59,15 +62,15 @@ pub fn build_zlib(comptime subdir: []const u8, b: *std.Build, target: std.Build.
} }
} }
} }
statlib.linkLibC(); statlib.root_module.link_libc = true;
statlib.addIncludePath(b.path(subdir)); statlib.root_module.addIncludePath(b.path(subdir));
statlib.addIncludePath(b.path(subdir ++ "/contrib/minzip")); statlib.root_module.addIncludePath(b.path(subdir ++ "/contrib/minzip"));
statlib.addCSourceFiles(.{ statlib.root_module.addCSourceFiles(.{
.files = zlib_sources.items, .files = zlib_sources.items,
.flags = zlib_flags.items, .flags = zlib_flags.items,
}); });
b.installArtifact(statlib); b.installArtifact(statlib);
var dylib_flags = std.ArrayList([]const u8).init(b.allocator); var dylib_flags = std.array_list.Managed([]const u8).init(b.allocator);
try dylib_flags.appendSlice(zlib_flags.items); try dylib_flags.appendSlice(zlib_flags.items);
//trial //trial
@ -79,82 +82,95 @@ pub fn build_zlib(comptime subdir: []const u8, b: *std.Build, target: std.Build.
//"-Wl,-out-implib,libz.dll.a", //seems to have no effect. zig always creates a .lib //"-Wl,-out-implib,libz.dll.a", //seems to have no effect. zig always creates a .lib
//"-DZLIB_WINAPI", //"-DZLIB_WINAPI",
//"-Wl,-exclude-libs=ALL", //"-Wl,-exclude-libs=ALL",
std.debug.print("build_zlib.zig flags {s}\n", .{dylib_flags.items}); std.debug.print("build_zlib.zig flags:", .{});
const dylib = b.addSharedLibrary(.{ for (dylib_flags.items) |f| std.debug.print(" {s}", .{f});
std.debug.print("\n", .{});
const dylib = b.addLibrary(.{
.linkage = .dynamic,
.name = "zlib1", .name = "zlib1",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
dylib.linkLibC(); dylib.root_module.link_libc = true;
dylib.addIncludePath(b.path(subdir)); dylib.root_module.addIncludePath(b.path(subdir));
dylib.addIncludePath(b.path(subdir ++ "/contrib/minizip")); dylib.root_module.addIncludePath(b.path(subdir ++ "/contrib/minizip"));
dylib.addCSourceFiles(.{ dylib.root_module.addCSourceFiles(.{
.files = zlib_sources.items, .files = zlib_sources.items,
.flags = dylib_flags.items, .flags = dylib_flags.items,
}); });
//dylib.addWin32ResourceFile(.{ .file = .{ .path = "zlib/win32/zlib1.rc" } }); //ignored for non-windows targets //dylib.root_module.addWin32ResourceFile(.{ .file = .{ .path = "zlib/win32/zlib1.rc" } }); //ignored for non-windows targets
dylib.addWin32ResourceFile(.{ .file = b.path(subdir ++ "/win32/zlib1.rc") }); //ignored for non-windows targets dylib.root_module.addWin32ResourceFile(.{ .file = b.path(subdir ++ "/win32/zlib1.rc") }); //ignored for non-windows targets
b.installArtifact(dylib); b.installArtifact(dylib);
const mgz_exe = b.addExecutable(.{ const mgz_exe = b.addExecutable(.{
.name = "minigzip", .name = "minigzip",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
mgz_exe.step.dependOn(&statlib.step); mgz_exe.step.dependOn(&statlib.step);
mgz_exe.addIncludePath(b.path(subdir)); mgz_exe.root_module.addIncludePath(b.path(subdir));
mgz_exe.addCSourceFile(.{ mgz_exe.root_module.addCSourceFile(.{
.file = b.path(subdir ++ "/test/minigzip.c"), .file = b.path(subdir ++ "/test/minigzip.c"),
.flags = zlib_flags.items, .flags = zlib_flags.items,
}); });
mgz_exe.linkLibC(); mgz_exe.root_module.link_libc = true;
mgz_exe.linkLibrary(statlib); mgz_exe.root_module.linkLibrary(statlib);
b.installArtifact(mgz_exe); b.installArtifact(mgz_exe);
const eg_exe = b.addExecutable(.{ const eg_exe = b.addExecutable(.{
.name = "zlib_example", .name = "zlib_example",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
eg_exe.step.dependOn(&statlib.step); eg_exe.step.dependOn(&statlib.step);
eg_exe.addIncludePath(b.path(subdir)); eg_exe.root_module.addIncludePath(b.path(subdir));
eg_exe.addCSourceFile(.{ eg_exe.root_module.addCSourceFile(.{
.file = b.path(subdir ++ "/test/example.c"), .file = b.path(subdir ++ "/test/example.c"),
.flags = zlib_flags.items, .flags = zlib_flags.items,
}); });
eg_exe.linkLibC(); eg_exe.root_module.link_libc = true;
eg_exe.linkLibrary(statlib); eg_exe.root_module.linkLibrary(statlib);
b.installArtifact(eg_exe); b.installArtifact(eg_exe);
const egd_exe = b.addExecutable(.{ const egd_exe = b.addExecutable(.{
.name = "zlib_example_d", .name = "zlib_example_d",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
egd_exe.step.dependOn(&statlib.step); egd_exe.step.dependOn(&statlib.step);
egd_exe.addIncludePath(b.path(subdir)); egd_exe.root_module.addIncludePath(b.path(subdir));
egd_exe.addCSourceFile(.{ egd_exe.root_module.addCSourceFile(.{
.file = b.path(subdir ++ "/test/example.c"), .file = b.path(subdir ++ "/test/example.c"),
.flags = dylib_flags.items, .flags = dylib_flags.items,
}); });
egd_exe.linkLibrary(dylib); egd_exe.root_module.linkLibrary(dylib);
egd_exe.root_module.addRPathSpecial("$ORIGIN/../lib"); egd_exe.root_module.addRPathSpecial("$ORIGIN/../lib");
egd_exe.linkLibC(); egd_exe.root_module.link_libc = true;
b.installArtifact(egd_exe); b.installArtifact(egd_exe);
const mgzd_exe = b.addExecutable(.{ const mgzd_exe = b.addExecutable(.{
.name = "minigzip_d", .name = "minigzip_d",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
mgzd_exe.step.dependOn(&statlib.step); mgzd_exe.step.dependOn(&statlib.step);
mgzd_exe.addIncludePath(b.path(subdir)); mgzd_exe.root_module.addIncludePath(b.path(subdir));
mgzd_exe.addCSourceFile(.{ mgzd_exe.root_module.addCSourceFile(.{
.file = b.path(subdir ++ "/test/minigzip.c"), .file = b.path(subdir ++ "/test/minigzip.c"),
.flags = dylib_flags.items, .flags = dylib_flags.items,
}); });
mgzd_exe.root_module.addRPathSpecial("$ORIGIN/../lib"); mgzd_exe.root_module.addRPathSpecial("$ORIGIN/../lib");
mgzd_exe.linkLibrary(dylib); mgzd_exe.root_module.linkLibrary(dylib);
b.installArtifact(mgzd_exe); b.installArtifact(mgzd_exe);
return statlib; return statlib;

7
src/buildsuites/suite_tcl90/suite.tcl

@ -50,9 +50,10 @@ array set opt {
-testargs {} -testargs {}
} }
#zig resolution: -zig option > PUNK_ZIG env > the suite's pinned toolchain under #zig resolution: -zig option > PUNK_ZIG env > the suite's pinned toolchain under
#bin/tools (zig 0.14.1 official release - hosted on punkbin, minisign-verified; #bin/tools (zig 0.16.0 official release - hosted on punkbin, minisign-verified;
#recipe also validated against the original 0.14.0-dev.2074) > 'zig' on PATH. #the recipe is 0.16-API and does NOT build under 0.14/0.15 - see README Lineage)
set pinned_zig [file normalize [file join $suiteroot .. .. .. bin tools zig-x86_64-windows-0.14.1 zig.exe]] #> 'zig' on PATH.
set pinned_zig [file normalize [file join $suiteroot .. .. .. bin tools zig-x86_64-windows-0.16.0 zig.exe]]
if {[info exists env(PUNK_ZIG)]} { if {[info exists env(PUNK_ZIG)]} {
set opt(-zig) $env(PUNK_ZIG) set opt(-zig) $env(PUNK_ZIG)
} elseif {[file exists $pinned_zig]} { } elseif {[file exists $pinned_zig]} {

65
src/buildsuites/suite_tcl90/tools/wrapfiletofile.zig

@ -10,13 +10,20 @@ const usage =
\\ -outut OUTPUTFILENAME \\ -outut OUTPUTFILENAME
; ;
pub fn main() !void { pub fn main(init: std.process.Init.Minimal) !void {
var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator); var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena_state.deinit(); defer arena_state.deinit();
const arena = arena_state.allocator(); const arena = arena_state.allocator();
const args = try std.process.argsAlloc(arena); var threaded: std.Io.Threaded = .init(arena, .{
.environ = init.environ,
.argv0 = .init(init.args),
});
defer threaded.deinit();
const io = threaded.io();
const args = try init.args.toSlice(arena);
var opt_input_file_path: ?[]const u8 = null; var opt_input_file_path: ?[]const u8 = null;
var opt_output_file_path: ?[]const u8 = null; var opt_output_file_path: ?[]const u8 = null;
var opt_prefix: ?[]const u8 = null; var opt_prefix: ?[]const u8 = null;
@ -26,28 +33,27 @@ pub fn main() !void {
var i: usize = 1; var i: usize = 1;
while (i < args.len) : (i += 1) { while (i < args.len) : (i += 1) {
const arg = args[i]; const arg = args[i];
if (std.mem.eql(u8, "-h",arg) or std.mem.eql(u8, "-help",arg)) { if (std.mem.eql(u8, "-h", arg) or std.mem.eql(u8, "-help", arg)) {
try std.io.getStdOut().writeAll(usage); std.debug.print("{s}\n", .{usage});
return std.process.cleanExit(); return std.process.cleanExit(io);
} else if (std.mem.eql(u8,"-prefix",arg)) { } else if (std.mem.eql(u8, "-prefix", arg)) {
i += 1; i += 1;
if (i > args.len) fatal("expected arg after '{s}'", .{arg}); if (i > args.len) fatal("expected arg after '{s}'", .{arg});
opt_prefix = args[i]; opt_prefix = args[i];
} else if (std.mem.eql(u8,"-input",arg)) { } else if (std.mem.eql(u8, "-input", arg)) {
i += 1; i += 1;
if (i > args.len) fatal("expected arg after '{s}'", .{arg}); if (i > args.len) fatal("expected arg after '{s}'", .{arg});
if (opt_input_file_path != null) fatal("duplicated {s} argument", .{arg}); if (opt_input_file_path != null) fatal("duplicated {s} argument", .{arg});
opt_input_file_path = args[i]; opt_input_file_path = args[i];
} else if (std.mem.eql(u8,"-output",arg)) { } else if (std.mem.eql(u8, "-output", arg)) {
i += 1; i += 1;
if (i > args.len) fatal("expected arg after '{s}'", .{arg}); if (i > args.len) fatal("expected arg after '{s}'", .{arg});
if (opt_output_file_path != null) fatal("duplicated {s} argument", .{arg}); if (opt_output_file_path != null) fatal("duplicated {s} argument", .{arg});
opt_output_file_path = args[i]; opt_output_file_path = args[i];
} else if (std.mem.eql(u8,"-prefixnl",arg)) { } else if (std.mem.eql(u8, "-prefixnl", arg)) {
i+= 1; i += 1;
if (i > args.len) fatal("expected arg after '{s}'", .{arg}); if (i > args.len) fatal("expected arg after '{s}'", .{arg});
//cast? review if (std.mem.eql(u8, "1", args[i])) {
if (std.mem.eql(u8,"1",args[i])) {
opt_prefixnl = true; opt_prefixnl = true;
} else { } else {
opt_prefixnl = false; opt_prefixnl = false;
@ -56,30 +62,29 @@ pub fn main() !void {
} }
} }
const input_file_path = opt_input_file_path orelse fatal("missing -input file", .{}); const input_file_path = opt_input_file_path orelse fatal("missing -input file", .{});
const output_file_path = opt_output_file_path orelse fatal("missing -output file", .{}); const output_file_path = opt_output_file_path orelse fatal("missing -output file", .{});
const prefix = opt_prefix orelse fatal("missing -prefix string",.{}); const prefix = opt_prefix orelse fatal("missing -prefix string", .{});
var input_file = std.fs.cwd().openFile(input_file_path,.{ .mode = .read_only}) catch |err| {
fatal("Unable to open '{s}': {s}",. { input_file_path, @errorName(err) }); const input_data = std.Io.Dir.cwd().readFileAlloc(io, input_file_path, arena, .unlimited) catch |err| {
fatal("Unable to read '{s}': {s}", .{ input_file_path, @errorName(err) });
}; };
defer input_file.close(); defer arena.free(input_data);
const input_data = try input_file.readToEndAlloc(arena, std.math.maxInt(usize));
defer arena.free(input_data);
std.debug.print("inputfile - Read {d} octets.\n", .{input_data.len}); std.debug.print("inputfile - Read {d} octets.\n", .{input_data.len});
var output_file = std.fs.cwd().createFile(output_file_path, .{}) catch |err| { var output_file = std.Io.Dir.cwd().createFile(io, output_file_path, .{}) catch |err| {
fatal("Unable to open '{s}': {s}", .{ output_file_path, @errorName(err)}); fatal("Unable to open '{s}': {s}", .{ output_file_path, @errorName(err) });
}; };
defer output_file.close(); defer output_file.close(io);
_ = try output_file.write(prefix); try output_file.writeStreamingAll(io, prefix);
if (opt_prefixnl) { if (opt_prefixnl) {
_ = try output_file.write("\n"); try output_file.writeStreamingAll(io, "\n");
} }
try output_file.writeAll(input_data); try output_file.writeStreamingAll(io, input_data);
return std.process.cleanExit(); return std.process.cleanExit(io);
} }
fn fatal(comptime format: []const u8, args: anytype) noreturn { fn fatal(comptime format: []const u8, args: anytype) noreturn {
std.debug.print(format,args); std.debug.print(format, args);
std.process.exit(1); std.process.exit(1);
} }

2
src/scriptapps/bin/punk-getzig.bash

@ -2,7 +2,7 @@
#tarball="zig-x86_64-windows-0.15.2.zip" #tarball="zig-x86_64-windows-0.15.2.zip"
#tarball="zig-x86_64-freebsd-0.15.2.tar.xz" #tarball="zig-x86_64-freebsd-0.15.2.tar.xz"
tarball="zig-x86_64-linux-0.15.2.tar.xz" tarball="zig-x86_64-linux-0.16.0.tar.xz"
automation_name="punkshell+julian@precisium.com.au_target_by_latency" automation_name="punkshell+julian@precisium.com.au_target_by_latency"
uristring="https://ziglang.org" uristring="https://ziglang.org"

2
src/scriptapps/bin/punk-getzig.ps1

@ -18,7 +18,7 @@ $zigexe = Join-Path $zigfolder -ChildPath "zig.exe"
#$releasearchive = "zig-x86_64-windows-0.15.1.zip" ;#zip on windows, tarball on every other platform #$releasearchive = "zig-x86_64-windows-0.15.1.zip" ;#zip on windows, tarball on every other platform
#$releasearchive = "zig-x86_64-windows-0.16.0-dev.254+6dd0270a1.zip" #$releasearchive = "zig-x86_64-windows-0.16.0-dev.254+6dd0270a1.zip"
#$releasearchive = "zig-x86_64-windows-0.16.0-dev.2193+fc517bd01.zip" #$releasearchive = "zig-x86_64-windows-0.16.0-dev.2193+fc517bd01.zip"
$releasearchive = "zig-x86_64-windows-0.15.2.zip" $releasearchive = "zig-x86_64-windows-0.16.0.zip"
#single-source the pinned version from the archive name (used for ziglang.org release URLs) #single-source the pinned version from the archive name (used for ziglang.org release URLs)
if ($releasearchive -match 'zig-x86_64-windows-(.+)\.zip$') { if ($releasearchive -match 'zig-x86_64-windows-(.+)\.zip$') {
$releaseversion = $Matches[1] $releaseversion = $Matches[1]

Loading…
Cancel
Save