From 4b877203282568b9e9086aa1bcecc7eb67b48c3e Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Mon, 20 Jul 2026 05:54:58 +1000 Subject: [PATCH] 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 --- bin/punk-getzig.cmd | 15 +- goals/G-096-zig-buildsuite-piperepl.md | 23 +- src/buildsuites/suite_tcl90/README.md | 46 +- src/buildsuites/suite_tcl90/build905.zig | 554 +++++++++--------- .../build_libtommath/build_libtommath.zig | 101 ++-- .../build_tclthread/build_tclthread.zig | 37 +- .../build_tclvfs/build_tclvfs_shared.zig | 33 +- .../build_tclvfs/build_tclvfs_static.zig | 31 +- .../suite_tcl90/build_zlib/build_zlib.zig | 108 ++-- src/buildsuites/suite_tcl90/suite.tcl | 7 +- .../suite_tcl90/tools/wrapfiletofile.zig | 65 +- src/scriptapps/bin/punk-getzig.bash | 2 +- src/scriptapps/bin/punk-getzig.ps1 | 2 +- 13 files changed, 564 insertions(+), 460 deletions(-) diff --git a/bin/punk-getzig.cmd b/bin/punk-getzig.cmd index 68093e4e..b7280d4d 100644 --- a/bin/punk-getzig.cmd +++ b/bin/punk-getzig.cmd @@ -1282,7 +1282,7 @@ fi #tarball="zig-x86_64-windows-0.15.2.zip" #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" 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.16.0-dev.254+6dd0270a1.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)" if (Get-Command $zigexe -ErrorAction SilentlyContinue) { @@ -1906,8 +1913,8 @@ if ($mirrors_response.StatusCode -eq 200) { $uristring = $hostinfo.uri if ($uristring -eq "https://ziglang.org") { #if it's a release - $full_uristring = "${uristring}/download/0.15.1/${releasearchive}?source=${automation_name}" - $sig_uristring = "${uristring}/download/0.15.1/${releasearchive}.minisig?source=${automation_name}" + $full_uristring = "${uristring}/download/${releaseversion}/${releasearchive}?source=${automation_name}" + $sig_uristring = "${uristring}/download/${releaseversion}/${releasearchive}.minisig?source=${automation_name}" #if it's a pre-release?? /builds/${prereleasearchive} ? } else { $full_uristring = "${uristring}/${releasearchive}?source=${automation_name}" diff --git a/goals/G-096-zig-buildsuite-piperepl.md b/goals/G-096-zig-buildsuite-piperepl.md index ddd9cbcc..36977733 100644 --- a/goals/G-096-zig-buildsuite-piperepl.md +++ b/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 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: -- punk-getzig per-version fetch argument, so the wrapper itself can materialize the - suite's pinned zig (pin currently 0.14.1; 0.16.0 adoption decision with the user - - the ported recipe awaits in _build/suite_tcl90/build016). Payload growth needs the - 512-byte spacer check on re-wrap. +- punk-getzig per-version fetch argument, so the wrapper itself can materialize + arbitrary pinned versions into versioned dirs (payload growth needs the 512-byte + spacer check on re-wrap). - Rebase the piperepl patch onto current core-9-0-branch sources; build a piperepl-enabled variant; behaviour matrix (TCLSH_PIPEREPL unset == stock on tty/piped/script-arg forms; =1 with a script setting ::tclsh(dorepl) 1 -> live diff --git a/src/buildsuites/suite_tcl90/README.md b/src/buildsuites/suite_tcl90/README.md index 8821438c..374438fd 100644 --- a/src/buildsuites/suite_tcl90/README.md +++ b/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 -The suite pin is **zig 0.14.1** (first official release in the recipe's 0.14 line; -the recipe is validated against BOTH 0.14.1 and the original 0.14.0-dev.2074 - see -Lineage). The pinned archive `zig-x86_64-windows-0.14.1.zip` (+`.minisig`) is hosted -on the punkbin artifact repo (`win32-x86_64/tools/`, sha1sums recorded) - the same -mirror punk-getzig consults - and was minisign-verified against the zig release key -before hosting. To materialize it: download from punkbin (or a ziglang community -mirror), verify the minisig, extract to `bin/tools/zig-x86_64-windows-0.14.1/`. -punk-getzig currently installs only its own single pinned version (0.15.2) to -`bin/tools/zig`; a per-version fetch argument is the intended enhancement so it can -materialize the suite pin directly. +The suite pin is **zig 0.16.0** (current official release; adopted 2026-07-20 - +the recipe was ported to the 0.16 build API and 0.14 support is deprecated; the +0.14-era recipe remains in git history and 0.14.1 remains archived on punkbin). +The pinned archive `zig-x86_64-windows-0.16.0.zip` (+`.minisig`) is hosted on the +punkbin artifact repo (`win32-x86_64/tools/`, sha1sums recorded) - the same mirror +punk-getzig consults - and was minisign-verified against the zig release key before +hosting. punk-getzig's own pin is the same 0.16.0 (installed to `bin/tools/zig`); +a per-version fetch argument remains the intended enhancement for materializing +arbitrary pinned versions into versioned dirs. Zig object caches are kept **per zig version** (`.zig-cache-` inside the 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 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): -`b.host` -> `b.graph.host`; the redundant second UNICODE tclMain add into the objs -lib removed (0.14.1 links what dev.2074's archiver left unpulled); the exe's ansi -tclMain copy compiles with `-UUNICODE -U_UNICODE -DTCL_ASCII_MAIN` (the zig cc -driver can supply windows-default defines, which made the "ansi" copy a duplicate -UNICODE compile under 0.14.1 - upstream's TCL_ASCII_MAIN guard is the intended -mechanism for the ascii variant). +zig 0.14.1 compat deltas (2026-07-20): `b.host` -> `b.graph.host`; the redundant +second UNICODE tclMain add into the objs lib removed; the exe's ansi tclMain copy +compiles with `-UUNICODE -U_UNICODE -DTCL_ASCII_MAIN` (the zig cc driver can supply +windows-default defines, which made the "ansi" copy a duplicate UNICODE compile - +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). diff --git a/src/buildsuites/suite_tcl90/build905.zig b/src/buildsuites/suite_tcl90/build905.zig index e1967367..b54debe6 100644 --- a/src/buildsuites/suite_tcl90/build905.zig +++ b/src/buildsuites/suite_tcl90/build905.zig @@ -236,8 +236,10 @@ pub fn build(b: *std.Build) !void { const prepare_source = b.step("prepare-source", "patch and prep source"); const wrap_exe = b.addExecutable(.{ .name = "wrapfiletofile", - .root_source_file = b.path("tools/wrapfiletofile.zig"), - .target = b.graph.host, + .root_module = b.createModule(.{ + .root_source_file = b.path("tools/wrapfiletofile.zig"), + .target = b.graph.host, + }), }); //const tool_step = b.addRunArtifact(tool); const wrap_run = b.addRunArtifact(wrap_exe); @@ -273,7 +275,7 @@ pub fn build(b: *std.Build) !void { //b.getInstallStep().dependOn(©_uuid.step); // ================================================ - var ac_flags = std.ArrayList([]const u8).init(b.allocator); + var ac_flags = std.array_list.Managed([]const u8).init(b.allocator); defer ac_flags.deinit(); try ac_flags.appendSlice(&.{ "-pipe", @@ -482,7 +484,7 @@ pub fn build(b: *std.Build) !void { //"-Wl,-input-charset=UTF-8", //"-finput-charset=UTF-8" - var warning_flags = std.ArrayList([]const u8).init(b.allocator); + var warning_flags = std.array_list.Managed([]const u8).init(b.allocator); defer warning_flags.deinit(); try warning_flags.appendSlice(&.{ "-Wall", @@ -495,7 +497,7 @@ pub fn build(b: *std.Build) !void { "-fextended-identifiers", }); //"-Werror=return-type", - var optimize_flags = std.ArrayList([]const u8).init(b.allocator); + var optimize_flags = std.array_list.Managed([]const u8).init(b.allocator); defer optimize_flags.deinit(); //windows? @@ -518,7 +520,7 @@ pub fn build(b: *std.Build) !void { }); //"-fomit-frame-pointer", - var c_flags = std.ArrayList([]const u8).init(b.allocator); + var c_flags = std.array_list.Managed([]const u8).init(b.allocator); defer c_flags.deinit(); try c_flags.appendSlice(optimize_flags.items); try c_flags.appendSlice(&.{ @@ -540,7 +542,7 @@ pub fn build(b: *std.Build) !void { //332 while (*w != '\0') { } - var config_flags = std.ArrayList([]const u8).init(b.allocator); + var config_flags = std.array_list.Managed([]const u8).init(b.allocator); defer config_flags.deinit(); //try config_flags.appendSlice(base_flags.items); //can't use ++ for non comptime values such as libdir,bindir... @@ -577,7 +579,7 @@ pub fn build(b: *std.Build) !void { //-I"${ZLIB_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" \ //${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} -DMP_PREC=4 \ //${AC_FLAGS} ${COMPILE_DEBUG_FLAGS} ${NO_DEPRECATED_FLAGS} - var cc_flags = std.ArrayList([]const u8).init(b.allocator); + var cc_flags = std.array_list.Managed([]const u8).init(b.allocator); defer cc_flags.deinit(); try cc_flags.appendSlice(c_flags.items); try cc_flags.appendSlice(warning_flags.items); @@ -588,7 +590,7 @@ pub fn build(b: *std.Build) !void { }); try cc_flags.appendSlice(ac_flags.items); - var base_flags = std.ArrayList([]const u8).init(b.allocator); + var base_flags = std.array_list.Managed([]const u8).init(b.allocator); defer base_flags.deinit(); try base_flags.appendSlice(&.{ "-municode", @@ -623,41 +625,44 @@ pub fn build(b: *std.Build) !void { //tclOOStubLib.$(OBJEXT) //tclWinPanic.$(OBJEXT) - const finalstublib = b.addStaticLibrary(.{ + const finalstublib = b.addLibrary(.{ + .linkage = .static, .name = if (target.result.os.tag == .windows) "libtclstub" else "tclstub", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); - var stublib_flags = std.ArrayList([]const u8).init(b.allocator); + var stublib_flags = std.array_list.Managed([]const u8).init(b.allocator); try stublib_flags.appendSlice(cc_flags.items); try stublib_flags.appendSlice(&.{ "-DSTATIC_BUILD", "-fno-lto", }); - //finalstublib.addIncludePath(.{ .path = tcl_source_folder ++ "/generic" }); - //finalstublib.addIncludePath(.{ .src_path = tcl_source_folder ++ "/generic" }); - finalstublib.addIncludePath(b.path(tcl_source_folder ++ "/generic")); + //finalstublib.root_module.addIncludePath(.{ .path = tcl_source_folder ++ "/generic" }); + //finalstublib.root_module.addIncludePath(.{ .src_path = tcl_source_folder ++ "/generic" }); + finalstublib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic")); if (target.result.os.tag == .windows) { - //finalstublib.addIncludePath(.{ .path = tcl_source_folder ++ "/win" }); - finalstublib.addIncludePath(b.path(tcl_source_folder ++ "/win")); + //finalstublib.root_module.addIncludePath(.{ .path = tcl_source_folder ++ "/win" }); + finalstublib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win")); } else { - //finalstublib.addIncludePath(.{ .path = tcl_source_folder ++ "/unix" }); - finalstublib.addIncludePath(b.path(tcl_source_folder ++ "/unix")); + //finalstublib.root_module.addIncludePath(.{ .path = tcl_source_folder ++ "/unix" }); + finalstublib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/unix")); } if (target.result.os.tag == .windows) { - finalstublib.addIncludePath(b.path(tcl_source_folder ++ "/libtommath")); - finalstublib.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); + finalstublib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/libtommath")); + finalstublib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); } else { - finalstublib.addIncludePath(b.path(tommath_sourcedir)); - finalstublib.addIncludePath(b.path(zlib_sourcedir)); + finalstublib.root_module.addIncludePath(b.path(tommath_sourcedir)); + finalstublib.root_module.addIncludePath(b.path(zlib_sourcedir)); } - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclStubLib.c"), .flags = stublib_flags.items, }); //tcl9 - var stublib_call_flags = std.ArrayList([]const u8).init(b.allocator); + var stublib_call_flags = std.array_list.Managed([]const u8).init(b.allocator); try stublib_call_flags.appendSlice(cc_flags.items); try stublib_call_flags.appendSlice(config_flags.items); try stublib_call_flags.appendSlice(&.{ @@ -670,71 +675,71 @@ pub fn build(b: *std.Build) !void { // }); //} - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclStubCall.c"), .flags = stublib_call_flags.items, }); //tcl9 - var stublib_tbl_flags = std.ArrayList([]const u8).init(b.allocator); + var stublib_tbl_flags = std.array_list.Managed([]const u8).init(b.allocator); try stublib_tbl_flags.appendSlice(cc_flags.items); try stublib_tbl_flags.appendSlice(&.{ "-DSTATIC_BUILD", }); - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclStubLibTbl.c"), .flags = stublib_tbl_flags.items, }); - var stublib_tom_flags = std.ArrayList([]const u8).init(b.allocator); + var stublib_tom_flags = std.array_list.Managed([]const u8).init(b.allocator); try stublib_tom_flags.appendSlice(cc_flags.items); try stublib_tom_flags.appendSlice(&.{ "-fno-lto", }); - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclTomMathStubLib.c"), .flags = stublib_tom_flags.items, }); - var stublib_oo_flags = std.ArrayList([]const u8).init(b.allocator); + var stublib_oo_flags = std.array_list.Managed([]const u8).init(b.allocator); try stublib_oo_flags.appendSlice(cc_flags.items); try stublib_oo_flags.appendSlice(&.{ "-fno-lto", }); - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclOOStubLib.c"), .flags = stublib_oo_flags.items, }); - var winpaniclib_flags = std.ArrayList([]const u8).init(b.allocator); + var winpaniclib_flags = std.array_list.Managed([]const u8).init(b.allocator); try winpaniclib_flags.appendSlice(cc_flags.items); try winpaniclib_flags.appendSlice(&.{ "-DSTATIC_BUILD", }); if (target.result.os.tag == .windows) { - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinPanic.c"), .flags = winpaniclib_flags.items, }); } - var windde_obj_flags = std.ArrayList([]const u8).init(b.allocator); + var windde_obj_flags = std.array_list.Managed([]const u8).init(b.allocator); defer windde_obj_flags.deinit(); try windde_obj_flags.appendSlice(cc_flags.items); try windde_obj_flags.appendSlice(&.{}); - var winreg_obj_flags = std.ArrayList([]const u8).init(b.allocator); + var winreg_obj_flags = std.array_list.Managed([]const u8).init(b.allocator); defer winreg_obj_flags.deinit(); try winreg_obj_flags.appendSlice(cc_flags.items); try winreg_obj_flags.appendSlice(&.{}); if (target.result.os.tag == .windows) { - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinDde.c"), .flags = windde_obj_flags.items, }); - finalstublib.addCSourceFile(.{ + finalstublib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinReg.c"), .flags = winreg_obj_flags.items, }); } - finalstublib.linkLibC(); + finalstublib.root_module.link_libc = true; b.installArtifact(finalstublib); @@ -744,52 +749,58 @@ pub fn build(b: *std.Build) !void { const winpaniclib = b.addObject(.{ .name = "tclWinPanic", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); if (target.result.os.tag == .windows) { - winpaniclib.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); - winpaniclib.addIncludePath(b.path(tcl_source_folder ++ "/win/")); - winpaniclib.addIncludePath(b.path(tcl_source_folder ++ "/libtommath/")); - winpaniclib.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/")); - winpaniclib.addCSourceFile(.{ + winpaniclib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); + winpaniclib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win/")); + winpaniclib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/libtommath/")); + winpaniclib.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/")); + winpaniclib.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinPanic.c"), .flags = winpaniclib_flags.items, }); - winpaniclib.linkLibC(); + winpaniclib.root_module.link_libc = true; } if (target.result.os.tag == .windows) { const winreg_obj = b.addObject(.{ - .name = "tclWinReg", + .name = "tclWinReg", + .root_module = b.createModule(.{ .target = target, .optimize = optimize, - }); - winreg_obj.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); - winreg_obj.addIncludePath(b.path(tcl_source_folder ++ "/win/")); - winreg_obj.addIncludePath(b.path(tcl_source_folder ++ "/libtommath/")); - winreg_obj.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/")); - winreg_obj.addCSourceFile(.{ + }), + }); + winreg_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); + winreg_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win/")); + winreg_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/libtommath/")); + winreg_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/")); + winreg_obj.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinReg.c"), .flags = winreg_obj_flags.items, }); - winreg_obj.linkLibC(); + winreg_obj.root_module.link_libc = true; // const windde_obj = b.addObject(.{ - .name = "tclWinDde", + .name = "tclWinDde", + .root_module = b.createModule(.{ .target = target, .optimize = optimize, - }); - windde_obj.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); - windde_obj.addIncludePath(b.path(tcl_source_folder ++ "/win/")); - windde_obj.addIncludePath(b.path(tcl_source_folder ++ "/libtommath/")); - windde_obj.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/")); - windde_obj.addCSourceFile(.{ + }), + }); + windde_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); + windde_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win/")); + windde_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/libtommath/")); + windde_obj.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/")); + windde_obj.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinDde.c"), .flags = windde_obj_flags.items, }); - windde_obj.linkLibC(); + windde_obj.root_module.link_libc = true; //DDE_OBJS } @@ -833,7 +844,7 @@ pub fn build(b: *std.Build) !void { //b.getInstallStep().dependOn(&stublib_archive.step); //dde_dll_file and reg_dll_file need to be added to the zip file - var dll_flags = std.ArrayList([]const u8).init(b.allocator); + var dll_flags = std.array_list.Managed([]const u8).init(b.allocator); //try dll_flags.appendSlice(base_flags.items); try dll_flags.appendSlice(&.{ "-pipe", @@ -850,43 +861,46 @@ pub fn build(b: *std.Build) !void { //std.fs.path.stem(dde_dll_file) ;// tcl9dde14.dll - tcl9 //std.fs.path.stem(dde_dll_file8) ;// tcldde14.dll - tcl8 - const dde_dll = b.addSharedLibrary(.{ + const dde_dll = b.addLibrary(.{ + .linkage = .dynamic, .name = std.fs.path.stem(dde_dll_file), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); dde_dll.step.dependOn(&installed_stublib_archive.step); dde_dll.step.dependOn(&finalstublib.step); var install_dde_dll: *std.Build.Step.InstallArtifact = undefined; if (target.result.os.tag == .windows) { - dde_dll.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); - dde_dll.addIncludePath(b.path(tcl_source_folder ++ "/win/")); - dde_dll.addCSourceFile(.{ + dde_dll.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); + dde_dll.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win/")); + dde_dll.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/TclWinDde.c"), .flags = dll_flags.items, }); //LIBS - //dde_dll.addLibraryPath(stublib_archive.source.dirname()); - dde_dll.addObjectFile(finalstublib.getEmittedBin()); - //dde_dll.addObjectFile(installed_stublib_archive.source); - //dde_lib.linkSystemLibrary("tclstub" ++ tcl_nodot_version); //libtclstubXX.a - //dde_lib.linkSystemLibrary("tclstub"); //tcl9 - dde_dll.linkSystemLibrary("netapi32"); - dde_dll.linkSystemLibrary("kernel32"); - dde_dll.linkSystemLibrary("user32"); - dde_dll.linkSystemLibrary("advapi32"); - dde_dll.linkSystemLibrary("userenv"); - dde_dll.linkSystemLibrary("ws2_32"); - //dde_dll.addObjectFile(.{ .path = tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a" }); - //dde_dll.addObjectFile(.{ .path = tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a" }); - dde_dll.addLibraryPath(b.path(tcl_source_folder ++ "/compat/zlib/win64")); - dde_dll.addLibraryPath(b.path(tcl_source_folder ++ "/libtommath/win64")); - //dde_dll.linkSystemLibrary("zlib1"); + //dde_dll.root_module.addLibraryPath(stublib_archive.source.dirname()); + dde_dll.root_module.addObjectFile(finalstublib.getEmittedBin()); + //dde_dll.root_module.addObjectFile(installed_stublib_archive.source); + //dde_lib.root_module.linkSystemLibrary("tclstub" ++ tcl_nodot_version); //libtclstubXX.a + //dde_lib.root_module.linkSystemLibrary("tclstub", .{}); //tcl9 + dde_dll.root_module.linkSystemLibrary("netapi32", .{}); + dde_dll.root_module.linkSystemLibrary("kernel32", .{}); + dde_dll.root_module.linkSystemLibrary("user32", .{}); + dde_dll.root_module.linkSystemLibrary("advapi32", .{}); + dde_dll.root_module.linkSystemLibrary("userenv", .{}); + dde_dll.root_module.linkSystemLibrary("ws2_32", .{}); + //dde_dll.root_module.addObjectFile(.{ .path = tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a" }); + //dde_dll.root_module.addObjectFile(.{ .path = tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a" }); + dde_dll.root_module.addLibraryPath(b.path(tcl_source_folder ++ "/compat/zlib/win64")); + dde_dll.root_module.addLibraryPath(b.path(tcl_source_folder ++ "/libtommath/win64")); + //dde_dll.root_module.linkSystemLibrary("zlib1", .{}); //### JMN - dde_dll.linkLibrary(zlib_lib_compile); - dde_dll.linkSystemLibrary("tommath"); - dde_dll.linkLibC(); + dde_dll.root_module.linkLibrary(zlib_lib_compile); + dde_dll.root_module.linkSystemLibrary("tommath", .{}); + dde_dll.root_module.link_libc = true; //b.installArtifact(dde_dll); install_dde_dll = b.addInstallArtifact( dde_dll, @@ -901,41 +915,44 @@ pub fn build(b: *std.Build) !void { //tcl9registry13.dll - tcl9 //tclregistry13.dll - tcl8 - const reg_dll = b.addSharedLibrary(.{ + const reg_dll = b.addLibrary(.{ + .linkage = .dynamic, .name = std.fs.path.stem(reg_dll_file), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); //reg_lib.step.dependOn(&stublib_archive.step); reg_dll.step.dependOn(&finalstublib.step); var install_reg_dll: *std.Build.Step.InstallArtifact = undefined; if (target.result.os.tag == .windows) { - reg_dll.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); - reg_dll.addIncludePath(b.path(tcl_source_folder ++ "/win/")); - reg_dll.addCSourceFile(.{ + reg_dll.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic/")); + reg_dll.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win/")); + reg_dll.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/TclWinReg.c"), .flags = dll_flags.items, }); //LIBS - //reg_dll.addLibraryPath(stublib_archive.source.dirname()); - reg_dll.addObjectFile(finalstublib.getEmittedBin()); - //reg_dll.linkSystemLibrary("tclstub" ++ tcl_nodot_version); //libtclstubXX.a - //reg_dll.linkSystemLibrary("tclstub"); //tcl9 - reg_dll.linkSystemLibrary("netapi32"); - reg_dll.linkSystemLibrary("kernel32"); - reg_dll.linkSystemLibrary("user32"); - reg_dll.linkSystemLibrary("advapi32"); - reg_dll.linkSystemLibrary("userenv"); - reg_dll.linkSystemLibrary("ws2_32"); - //reg_dll.addObjectFile(.{ .path = tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a" }); - //reg_dll.addObjectFile(.{ .path = tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a" }); - reg_dll.addLibraryPath(b.path(tcl_source_folder ++ "/compat/zlib/win64")); - reg_dll.addLibraryPath(b.path(tcl_source_folder ++ "/libtommath/win64")); - //reg_dll.linkSystemLibrary("zlib1"); + //reg_dll.root_module.addLibraryPath(stublib_archive.source.dirname()); + reg_dll.root_module.addObjectFile(finalstublib.getEmittedBin()); + //reg_dll.root_module.linkSystemLibrary("tclstub" ++ tcl_nodot_version); //libtclstubXX.a + //reg_dll.root_module.linkSystemLibrary("tclstub", .{}); //tcl9 + reg_dll.root_module.linkSystemLibrary("netapi32", .{}); + reg_dll.root_module.linkSystemLibrary("kernel32", .{}); + reg_dll.root_module.linkSystemLibrary("user32", .{}); + reg_dll.root_module.linkSystemLibrary("advapi32", .{}); + reg_dll.root_module.linkSystemLibrary("userenv", .{}); + reg_dll.root_module.linkSystemLibrary("ws2_32", .{}); + //reg_dll.root_module.addObjectFile(.{ .path = tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a" }); + //reg_dll.root_module.addObjectFile(.{ .path = tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a" }); + reg_dll.root_module.addLibraryPath(b.path(tcl_source_folder ++ "/compat/zlib/win64")); + reg_dll.root_module.addLibraryPath(b.path(tcl_source_folder ++ "/libtommath/win64")); + //reg_dll.root_module.linkSystemLibrary("zlib1", .{}); //### JMN - reg_dll.linkLibrary(zlib_lib_compile); - reg_dll.linkSystemLibrary("tommath"); - reg_dll.linkLibC(); + reg_dll.root_module.linkLibrary(zlib_lib_compile); + reg_dll.root_module.linkSystemLibrary("tommath", .{}); + reg_dll.root_module.link_libc = true; //b.installArtifact(reg_dll); //https://www.reddit.com/r/Zig/comments/1cxn08x/question_how_do_i_setup_a_custom_install_location/ @@ -951,7 +968,7 @@ pub fn build(b: *std.Build) !void { } //COREOBJS - var generic_sources = std.ArrayList([]const u8).init(b.allocator); + var generic_sources = std.array_list.Managed([]const u8).init(b.allocator); defer generic_sources.deinit(); try generic_sources.append(tcl_source_folder ++ "/generic/regcomp.c"); try generic_sources.append(tcl_source_folder ++ "/generic/regexec.c"); @@ -1065,9 +1082,9 @@ pub fn build(b: *std.Build) !void { try generic_sources.append(tcl_source_folder ++ "/generic/tclZlib.c"); //PLATFORMOBJS - win_source or unix_sources - var win_sources = std.ArrayList([]const u8).init(b.allocator); + var win_sources = std.array_list.Managed([]const u8).init(b.allocator); defer win_sources.deinit(); - var unix_sources = std.ArrayList([]const u8).init(b.allocator); + var unix_sources = std.array_list.Managed([]const u8).init(b.allocator); defer unix_sources.deinit(); switch (target.result.os.tag) { @@ -1119,7 +1136,7 @@ pub fn build(b: *std.Build) !void { }, } - var tommath_sources = std.ArrayList([]const u8).init(b.allocator); + var tommath_sources = std.array_list.Managed([]const u8).init(b.allocator); //{ // //const subdir = "../libtommath"; // //const subdir = tcl_source_folder ++ "/libtommath"; @@ -1227,7 +1244,7 @@ pub fn build(b: *std.Build) !void { try tommath_sources.append(tommath_sourcedir ++ "/bn_s_mp_toom_sqr.c"); // larger set - var tcl_objs_static_sources = std.ArrayList([]const u8).init(b.allocator); + var tcl_objs_static_sources = std.array_list.Managed([]const u8).init(b.allocator); defer tcl_objs_static_sources.deinit(); try tcl_objs_static_sources.appendSlice(generic_sources.items); if (target.result.os.tag == .windows) { @@ -1237,7 +1254,7 @@ pub fn build(b: *std.Build) !void { } try tcl_objs_static_sources.appendSlice(tommath_sources.items); if (target.result.os.tag == .windows) { - var panic_dde_reg_sources = std.ArrayList([]const u8).init(b.allocator); + var panic_dde_reg_sources = std.array_list.Managed([]const u8).init(b.allocator); defer panic_dde_reg_sources.deinit(); try panic_dde_reg_sources.append(tcl_source_folder ++ "/win/tclWinPanic.c"); try panic_dde_reg_sources.append(tcl_source_folder ++ "/win/tclWinReg.c"); @@ -1246,7 +1263,7 @@ pub fn build(b: *std.Build) !void { } //smaller set - var tcl_objs_shared_sources = std.ArrayList([]const u8).init(b.allocator); + var tcl_objs_shared_sources = std.array_list.Managed([]const u8).init(b.allocator); defer tcl_objs_shared_sources.deinit(); try tcl_objs_shared_sources.appendSlice(generic_sources.items); if (target.result.os.tag == .windows) { @@ -1258,25 +1275,25 @@ pub fn build(b: *std.Build) !void { //shouldn't need to be added ?? try tcl_objs_shared_sources.appendSlice(tommath_sources.items); - var tclobjs_flags = std.ArrayList([]const u8).init(b.allocator); + var tclobjs_flags = std.array_list.Managed([]const u8).init(b.allocator); try tclobjs_flags.appendSlice(cc_flags.items); try tclobjs_flags.appendSlice(&.{ "-DBUILD_tcl", }); // ============================================================================================================== - const Flaginfo = struct { flags: std.ArrayList([]const u8) }; + const Flaginfo = struct { flags: std.array_list.Managed([]const u8) }; var build_specials = std.StringHashMap(Flaginfo).init(b.allocator); defer build_specials.deinit(); // -------------------------------------------------------------------------------------------------------------- - var mainw_flags = std.ArrayList([]const u8).init(b.allocator); + var mainw_flags = std.array_list.Managed([]const u8).init(b.allocator); defer mainw_flags.deinit(); try build_specials.put("tclWinPanic", .{ .flags = winpaniclib_flags }); try build_specials.put("tclWinReg", .{ .flags = winreg_obj_flags }); try build_specials.put("tclWinDde", .{ .flags = windde_obj_flags }); - var appinit_flags = std.ArrayList([]const u8).init(b.allocator); + var appinit_flags = std.array_list.Managed([]const u8).init(b.allocator); defer appinit_flags.deinit(); try appinit_flags.appendSlice(cc_flags.items); try appinit_flags.appendSlice(&.{ @@ -1293,7 +1310,7 @@ pub fn build(b: *std.Build) !void { }); try build_specials.put("tclMain", .{ .flags = mainw_flags }); - var wininit_obj_flags = std.ArrayList([]const u8).init(b.allocator); + var wininit_obj_flags = std.array_list.Managed([]const u8).init(b.allocator); defer wininit_obj_flags.deinit(); try wininit_obj_flags.appendSlice(cc_flags.items); try wininit_obj_flags.appendSlice(&.{ @@ -1304,16 +1321,16 @@ pub fn build(b: *std.Build) !void { //try build_specials.put("tclPkgConfig",.{ .flags = config_flags}); try build_specials.put("tclPkgConfig", .{ .flags = cc_flags }); //cc_flags includes config_flags - var zipfs_flags = std.ArrayList([]const u8).init(b.allocator); + var zipfs_flags = std.array_list.Managed([]const u8).init(b.allocator); defer zipfs_flags.deinit(); try zipfs_flags.appendSlice(cc_flags.items); try zipfs_flags.appendSlice(&.{ "-DBUILD_tcl", }); try build_specials.put("tclZipfs", .{ .flags = zipfs_flags }); - //zipfs_obj.addIncludePath(.{ .path = tcl_source_folder ++ "/compat/zlib/contrib/minizip" }); + //zipfs_obj.root_module.addIncludePath(.{ .path = tcl_source_folder ++ "/compat/zlib/contrib/minizip" }); - var pipe_obj_flags = std.ArrayList([]const u8).init(b.allocator); + var pipe_obj_flags = std.array_list.Managed([]const u8).init(b.allocator); defer pipe_obj_flags.deinit(); try pipe_obj_flags.appendSlice(cc_flags.items); try pipe_obj_flags.appendSlice(&.{ @@ -1323,21 +1340,24 @@ pub fn build(b: *std.Build) !void { // ============================================================================================================== - const tcl_objs_static = b.addStaticLibrary(.{ + const tcl_objs_static = b.addLibrary(.{ + .linkage = .static, .name = "tclobjs" ++ tcl_nodot_version, - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); - tcl_objs_static.addIncludePath(b.path(tcl_source_folder ++ "/generic")); + tcl_objs_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic")); if (target.result.os.tag == .windows) { - tcl_objs_static.addIncludePath(b.path(tcl_source_folder ++ "/win")); + tcl_objs_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win")); } else { - tcl_objs_static.addIncludePath(b.path(tcl_source_folder ++ "/unix")); + tcl_objs_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/unix")); } - tcl_objs_static.addIncludePath(b.path(tommath_sourcedir)); - tcl_objs_static.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); - tcl_objs_static.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); //only required by tclZipfs - but ok for all? + tcl_objs_static.root_module.addIncludePath(b.path(tommath_sourcedir)); + tcl_objs_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); + tcl_objs_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); //only required by tclZipfs - but ok for all? //tclMain.c needs to be built twice on windows - with and without unicode flags. //The UNICODE copy is already produced by the generic sources loop (build_specials @@ -1345,12 +1365,12 @@ pub fn build(b: *std.Build) !void { //explicit UNICODE add here was harmless under zig 0.14.0-dev.2074 (the duplicate //archive member was never extracted) but zig 0.14.1 links it -> duplicate symbols. //if (target.result.os.tag == .windows) { - // tcl_objs_static.addCSourceFile(.{ + // tcl_objs_static.root_module.addCSourceFile(.{ // .file = b.path(tcl_source_folder ++ "/generic/tclMain.c"), // .flags = mainw_flags.items, // }); //} - var current_flagset: std.ArrayList([]const u8) = undefined; + var current_flagset: std.array_list.Managed([]const u8) = undefined; for (tcl_objs_static_sources.items) |src| { if (build_specials.get(std.fs.path.stem(src))) |val| { //std.debug.print(">>> {s}\n", .{ std.fs.path.stem(src)}); @@ -1359,35 +1379,35 @@ pub fn build(b: *std.Build) !void { //std.debug.print("--- {s}", .{ std.fs.path.stem(src)}); current_flagset = tclobjs_flags; } - tcl_objs_static.addCSourceFile(.{ + tcl_objs_static.root_module.addCSourceFile(.{ .file = b.path(src), .flags = current_flagset.items, }); } - tcl_objs_static.linkLibC(); + tcl_objs_static.root_module.link_libc = true; //b.installArtifact(tcl_objs); - //const tcl_objs_shared = b.addStaticLibrary(.{ + //const tcl_objs_shared = b.addLibrary(.{ + // .linkage = .static, // .name = "tclobjsshared" ++ tcl_nodot_version, - // .target = target, - // .optimize = optimize, + // .root_module = b.createModule(.{ .target = target, .optimize = optimize }), //}); - //tcl_objs_shared.addIncludePath(b.path(tcl_source_folder ++ "/generic")); + //tcl_objs_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic")); //if (target.result.os.tag == .windows) { - // tcl_objs_shared.addIncludePath(b.path(tcl_source_folder ++ "/win")); + // tcl_objs_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win")); //} else { - // tcl_objs_shared.addIncludePath(b.path(tcl_source_folder ++ "/unix")); + // tcl_objs_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/unix")); //} - //tcl_objs_shared.addIncludePath(b.path(tommath_sourcedir)); - //tcl_objs_shared.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); - //tcl_objs_shared.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); //only required by tclZipfs - but ok for all? + //tcl_objs_shared.root_module.addIncludePath(b.path(tommath_sourcedir)); + //tcl_objs_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); + //tcl_objs_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); //only required by tclZipfs - but ok for all? //if (target.result.os.tag == .windows) { - // tcl_objs_shared.addCSourceFile(.{ + // tcl_objs_shared.root_module.addCSourceFile(.{ // .file = b.path(tcl_source_folder ++ "/generic/tclMain.c"), // .flags = mainw_flags.items, // }); //} - //var current_flagset_obj_shared: std.ArrayList([]const u8) = undefined; + //var current_flagset_obj_shared: std.array_list.Managed([]const u8) = undefined; //for (tcl_objs_shared_sources.items) |src| { // if (build_specials.get(std.fs.path.stem(src))) |val| { // //std.debug.print(">>> {s}\n", .{ std.fs.path.stem(src)}); @@ -1396,24 +1416,24 @@ pub fn build(b: *std.Build) !void { // //std.debug.print("--- {s}", .{ std.fs.path.stem(src)}); // current_flagset_obj_shared = tclobjs_flags; // } - // tcl_objs_shared.addCSourceFile(.{ + // tcl_objs_shared.root_module.addCSourceFile(.{ // .file = b.path(src), // .flags = current_flagset_obj_shared.items, // }); //} - ////tcl_objs_shared.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a")); - //tcl_objs_shared.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/tommath.lib")); - ////tcl_objs_shared.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a")); - //tcl_objs_shared.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/zdll.lib")); - //tcl_objs_shared.linkLibC(); + ////tcl_objs_shared.root_module.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a")); + //tcl_objs_shared.root_module.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/tommath.lib")); + ////tcl_objs_shared.root_module.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a")); + //tcl_objs_shared.root_module.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/zdll.lib")); + //tcl_objs_shared.root_module.link_libc = true; //-- --- --- - //const tcl_lib_static = b.addStaticLibrary(.{ - // //libtcl90.dll.a ? - // .name = if (target.result.os.tag == .windows) "libtcl" ++ tcl_nodot_version ++ ".dll" else "libtcl" ++ tcl_nodot_version ++ ".so", //zig will append .lib or .a? - // .target = target, - // .optimize = optimize, + //const tcl_lib_static = b.addLibrary(.{ + // .linkage = .static, + // //libtcl90.dll.a ? - zig will append .lib or .a? + // .name = if (target.result.os.tag == .windows) "libtcl" ++ tcl_nodot_version ++ ".dll" else "libtcl" ++ tcl_nodot_version ++ ".so", + // .root_module = b.createModule(.{ .target = target, .optimize = optimize }), //}); ////jmn3 -test @@ -1421,21 +1441,21 @@ pub fn build(b: *std.Build) !void { ////tcl_lib_static.step.dependOn(&tommath_lib_compile.step); //tcl_lib_static.step.dependOn(&wf_uuidh.step); - //tcl_lib_static.addIncludePath(b.path(tcl_source_folder ++ "/generic")); + //tcl_lib_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic")); //if (target.result.os.tag == .windows) { - // tcl_lib_static.addIncludePath(b.path(tcl_source_folder ++ "/win")); + // tcl_lib_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win")); //} else { - // tcl_lib_static.addIncludePath(b.path(tcl_source_folder ++ "/unix")); + // tcl_lib_static.root_module.addIncludePath(b.path(tcl_source_folder ++ "/unix")); //} - //tcl_lib_static.addIncludePath(b.path(tommath_sourcedir)); + //tcl_lib_static.root_module.addIncludePath(b.path(tommath_sourcedir)); //if (target.result.os.tag == .windows) { - // tcl_lib_static.addIncludePath(b.path(zlib_sourcedir)); - // tcl_lib_static.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); //only required by tclZipfs - but ok for all? + // tcl_lib_static.root_module.addIncludePath(b.path(zlib_sourcedir)); + // tcl_lib_static.root_module.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); //only required by tclZipfs - but ok for all? //} else { - // //tcl_lib_static.addIncludePath(b.path("../zlib")); - // //tcl_lib_static.addIncludePath(b.path("../zlib/contrib/minizip")); - // tcl_lib_static.addIncludePath(b.path(zlib_sourcedir)); - // tcl_lib_static.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); //only required by tclZipfs - but ok for all? + // //tcl_lib_static.root_module.addIncludePath(b.path("../zlib")); + // //tcl_lib_static.root_module.addIncludePath(b.path("../zlib/contrib/minizip")); + // tcl_lib_static.root_module.addIncludePath(b.path(zlib_sourcedir)); + // tcl_lib_static.root_module.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); //only required by tclZipfs - but ok for all? //} //for (tcl_lib_sources.items) |src| { @@ -1446,24 +1466,24 @@ pub fn build(b: *std.Build) !void { // //std.debug.print("--- {s}", .{ std.fs.path.stem(src)}); // current_flagset = tclobjs_flags; // } - // tcl_lib_static.addCSourceFile(.{ + // tcl_lib_static.root_module.addCSourceFile(.{ // .file = b.path(src), // .flags = current_flagset.items, // }); //} //jmn3 - //tcl_lib_static.linkLibrary(zlib_lib_compile); - //tcl_lib_static.linkLibrary(tommath_lib_compile); + //tcl_lib_static.root_module.linkLibrary(zlib_lib_compile); + //tcl_lib_static.root_module.linkLibrary(tommath_lib_compile); - //tcl_lib_static.linkLibC(); + //tcl_lib_static.root_module.link_libc = true; //b.installArtifact(tcl_lib_static); // ============================================================================================================== // ============================================================================================================== //tclXX.dll or .so - var tcl_lib_shared_flags = std.ArrayList([]const u8).init(b.allocator); + var tcl_lib_shared_flags = std.array_list.Managed([]const u8).init(b.allocator); try tcl_lib_shared_flags.appendSlice(base_flags.items); try tcl_lib_shared_flags.appendSlice(&.{ "-pipe", @@ -1485,10 +1505,13 @@ pub fn build(b: *std.Build) !void { //}); try tcl_lib_shared_flags.appendSlice(c_flags.items); - const tcl_lib_shared = b.addSharedLibrary(.{ + const tcl_lib_shared = b.addLibrary(.{ + .linkage = .dynamic, .name = "tcl" ++ tcl_nodot_version, - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); //tcl_lib_shared.verbose_link = true; @@ -1500,22 +1523,22 @@ pub fn build(b: *std.Build) !void { // tcl_slib.step.dependOn(&zlib_lib_compile.step); //} - tcl_lib_shared.addIncludePath(b.path(tcl_source_folder ++ "/generic")); + tcl_lib_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic")); if (target.result.os.tag == .windows) { - tcl_lib_shared.addIncludePath(b.path(tcl_source_folder ++ "/win")); - tcl_lib_shared.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); - tcl_lib_shared.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); + tcl_lib_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win")); + tcl_lib_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); + tcl_lib_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); } else { - tcl_lib_shared.addIncludePath(b.path(tcl_source_folder ++ "/unix")); - tcl_lib_shared.addIncludePath(b.path(zlib_sourcedir)); - tcl_lib_shared.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); //only required by tclZipfs - but ok for all? + tcl_lib_shared.root_module.addIncludePath(b.path(tcl_source_folder ++ "/unix")); + tcl_lib_shared.root_module.addIncludePath(b.path(zlib_sourcedir)); + tcl_lib_shared.root_module.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); //only required by tclZipfs - but ok for all? } - tcl_lib_shared.addIncludePath(b.path(tommath_sourcedir)); + tcl_lib_shared.root_module.addIncludePath(b.path(tommath_sourcedir)); // --- // ?? needed for shared lib? //if (target.result.os.tag == .windows) { - // tcl_lib_shared.addCSourceFile(.{ + // tcl_lib_shared.root_module.addCSourceFile(.{ // .file = b.path(tcl_source_folder ++ "/generic/tclMain.c"), // .flags = mainw_flags.items, // }); @@ -1529,46 +1552,46 @@ pub fn build(b: *std.Build) !void { //std.debug.print("--- {s}", .{ std.fs.path.stem(src)}); current_flagset = tclobjs_flags; } - tcl_lib_shared.addCSourceFile(.{ + tcl_lib_shared.root_module.addCSourceFile(.{ .file = b.path(src), .flags = current_flagset.items, }); } if (target.result.os.tag == .windows) { - tcl_lib_shared.addLibraryPath(b.path(tcl_source_folder ++ "/compat/zlib/win64")); - tcl_lib_shared.addLibraryPath(b.path(tcl_source_folder ++ "/libtommath/win64")); + tcl_lib_shared.root_module.addLibraryPath(b.path(tcl_source_folder ++ "/compat/zlib/win64")); + tcl_lib_shared.root_module.addLibraryPath(b.path(tcl_source_folder ++ "/libtommath/win64")); } if (target.result.os.tag == .windows) { - //tcl_lib_shared.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a")); - //tcl_lib_shared.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a")); - tcl_lib_shared.linkSystemLibrary2("tommath", .{ .preferred_link_mode = .dynamic }); - //tcl_lib_shared.linkSystemLibrary2("zlib1", .{ .preferred_link_mode = .dynamic }); - tcl_lib_shared.linkLibrary(zlib_lib_compile); - //tcl_lib_shared.linkSystemLibrary("tommath"); - //tcl_lib_shared.linkSystemLibrary("zlib1"); + //tcl_lib_shared.root_module.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a")); + //tcl_lib_shared.root_module.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a")); + tcl_lib_shared.root_module.linkSystemLibrary("tommath", .{ .preferred_link_mode = .dynamic }); + //tcl_lib_shared.root_module.linkSystemLibrary("zlib1", .{ .preferred_link_mode = .dynamic }); + tcl_lib_shared.root_module.linkLibrary(zlib_lib_compile); + //tcl_lib_shared.root_module.linkSystemLibrary("tommath", .{}); + //tcl_lib_shared.root_module.linkSystemLibrary("zlib1", .{}); } else { - //tcl_lib_shared.linkLibrary(tommath_lib_compile); - tcl_lib_shared.linkLibrary(zlib_lib_compile); - //tcl_lib_shared.linkSystemLibrary("zlib1"); + //tcl_lib_shared.root_module.linkLibrary(tommath_lib_compile); + tcl_lib_shared.root_module.linkLibrary(zlib_lib_compile); + //tcl_lib_shared.root_module.linkSystemLibrary("zlib1", .{}); } //JMN2024 install_path problem (sub_path is expected to be relative to the build root) - //tcl_lib_shared.addLibraryPath(b.path( b.pathJoin(&.{ b.install_path, "" }) )); - tcl_lib_shared.linkLibC(); + //tcl_lib_shared.root_module.addLibraryPath(b.path( b.pathJoin(&.{ b.install_path, "" }) )); + tcl_lib_shared.root_module.link_libc = true; //SHLIB_LD_LIBS (LIBS) if (target.result.os.tag == .windows) { - tcl_lib_shared.linkSystemLibrary("netapi32"); - tcl_lib_shared.linkSystemLibrary("kernel32"); - tcl_lib_shared.linkSystemLibrary("user32"); - tcl_lib_shared.linkSystemLibrary("advapi32"); - tcl_lib_shared.linkSystemLibrary("userenv"); - tcl_lib_shared.linkSystemLibrary("ws2_32"); + tcl_lib_shared.root_module.linkSystemLibrary("netapi32", .{}); + tcl_lib_shared.root_module.linkSystemLibrary("kernel32", .{}); + tcl_lib_shared.root_module.linkSystemLibrary("user32", .{}); + tcl_lib_shared.root_module.linkSystemLibrary("advapi32", .{}); + tcl_lib_shared.root_module.linkSystemLibrary("userenv", .{}); + tcl_lib_shared.root_module.linkSystemLibrary("ws2_32", .{}); } - //tclshlib.linkSystemLibrary("libtommath"); - //tclshlib.linkSystemLibrary("zlib1"); - tcl_lib_shared.addWin32ResourceFile(.{ + //tclshlib.root_module.linkSystemLibrary("libtommath", .{}); + //tclshlib.root_module.linkSystemLibrary("zlib1", .{}); + tcl_lib_shared.root_module.addWin32ResourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tcl.rc"), .flags = &.{ "/I", @@ -1577,7 +1600,7 @@ pub fn build(b: *std.Build) !void { }); b.installArtifact(tcl_lib_shared); - var ldflags_console = std.ArrayList([]const u8).init(b.allocator); + var ldflags_console = std.array_list.Managed([]const u8).init(b.allocator); if (target.result.os.tag == .windows) { try ldflags_console.appendSlice(&.{ "-mconsole", @@ -1594,17 +1617,20 @@ pub fn build(b: *std.Build) !void { }); //"-DTCL_MEM_DEBUG", - var tclsh_flags = std.ArrayList([]const u8).init(b.allocator); + var tclsh_flags = std.array_list.Managed([]const u8).init(b.allocator); try tclsh_flags.appendSlice(c_flags.items); try tclsh_flags.appendSlice(appinit_flags.items); try tclsh_flags.appendSlice(ldflags_console.items); const tclsh_exe = b.addExecutable(.{ - .name = tclsh_static, //e.g tclsh90s (becomes tclsh90s.exe on windows) + .name = tclsh_static, + //e.g tclsh90s (becomes tclsh90s.exe on windows) //.root_source_file = .{ .path = appinit_path}, - .root_source_file = b.path("src/main.zig"), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }), }); //9.0.5 sources dropped TCL_BROKEN_MAINARGS: tclAppInit.c now provides _tmain, which is //wmain under -DUNICODE, so the mingw CRT must use the unicode entry (zig's -municode). @@ -1622,17 +1648,17 @@ pub fn build(b: *std.Build) !void { // tclsh_exe.step.dependOn(&zlib_lib_compile.step); //} - tclsh_exe.addIncludePath(b.path(tcl_source_folder ++ "/generic")); + tclsh_exe.root_module.addIncludePath(b.path(tcl_source_folder ++ "/generic")); if (target.result.os.tag == .windows) { - tclsh_exe.addIncludePath(b.path(tcl_source_folder ++ "/win")); - tclsh_exe.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); - tclsh_exe.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); + tclsh_exe.root_module.addIncludePath(b.path(tcl_source_folder ++ "/win")); + tclsh_exe.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib")); + tclsh_exe.root_module.addIncludePath(b.path(tcl_source_folder ++ "/compat/zlib/contrib/minizip")); } else { - tclsh_exe.addIncludePath(b.path(tcl_source_folder ++ "/unix")); - tclsh_exe.addIncludePath(b.path(zlib_sourcedir)); - tclsh_exe.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); + tclsh_exe.root_module.addIncludePath(b.path(tcl_source_folder ++ "/unix")); + tclsh_exe.root_module.addIncludePath(b.path(zlib_sourcedir)); + tclsh_exe.root_module.addIncludePath(b.path(zlib_sourcedir ++ "/contrib/minizip")); } - tclsh_exe.addIncludePath(b.path(tommath_sourcedir)); + tclsh_exe.root_module.addIncludePath(b.path(tommath_sourcedir)); //tclMain needs to be compiled twice on windows - with and without unicode //we have already configured the one in the sources list to compile with mainw_flags (DUNICODE etc) @@ -1641,7 +1667,7 @@ pub fn build(b: *std.Build) !void { //supply windows-default defines - observed with zig 0.14.1 as duplicate //Tcl_MainExW/common symbols vs the mainw copy) and use upstream's //TCL_ASCII_MAIN guard so only the ascii Tcl_MainEx variant is emitted. - var mainansi_flags = std.ArrayList([]const u8).init(b.allocator); + var mainansi_flags = std.array_list.Managed([]const u8).init(b.allocator); defer mainansi_flags.deinit(); try mainansi_flags.appendSlice(tclobjs_flags.items); try mainansi_flags.appendSlice(&.{ @@ -1649,19 +1675,19 @@ pub fn build(b: *std.Build) !void { "-U_UNICODE", "-DTCL_ASCII_MAIN", }); - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclMain.c"), .flags = mainansi_flags.items, }); } - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(appinit_path), .flags = tclsh_flags.items, }); // TCL_LIB_FILE libtclxx.dll.a (not the implib which is tclxx.dll.a) // -- - //tclsh_exe.addObjectFile(install_tcl_lib_file.source); - //tclsh_exe.addObjectFile(tcl_lib_static.getEmittedBin()); + //tclsh_exe.root_module.addObjectFile(install_tcl_lib_file.source); + //tclsh_exe.root_module.addObjectFile(tcl_lib_static.getEmittedBin()); for (tcl_objs_static_sources.items) |src| { if (build_specials.get(std.fs.path.stem(src))) |val| { std.debug.print(">>> {s}\n", .{std.fs.path.stem(src)}); @@ -1670,18 +1696,18 @@ pub fn build(b: *std.Build) !void { //std.debug.print("--- {s}", .{ std.fs.path.stem(src)}); current_flagset = tclobjs_flags; } - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(src), .flags = current_flagset.items, }); } - //tclsh_exe.addObjectFile(finalstublib.getEmittedBin()); - tclsh_exe.addCSourceFile(.{ + //tclsh_exe.root_module.addObjectFile(finalstublib.getEmittedBin()); + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclStubLib.c"), .flags = stublib_flags.items, }); //experiment - //tclsh_exe.addCSourceFiles(.{ + //tclsh_exe.root_module.addCSourceFiles(.{ // .files = &.{ // "generic/tclStubCall.c", // "tclStubLibTbl.c", @@ -1690,59 +1716,59 @@ pub fn build(b: *std.Build) !void { //}); //tcl9 - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclStubCall.c"), .flags = stublib_call_flags.items, }); //tcl9 - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclStubLibTbl.c"), .flags = stublib_tbl_flags.items, }); - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclTomMathStubLib.c"), .flags = stublib_tom_flags.items, }); - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/generic/tclOOStubLib.c"), .flags = stublib_oo_flags.items, }); if (target.result.os.tag == .windows) { - tclsh_exe.addCSourceFile(.{ + tclsh_exe.root_module.addCSourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclWinPanic.c"), .flags = winpaniclib_flags.items, }); } if (target.result.os.tag == .windows) { - tclsh_exe.linkSystemLibrary("netapi32"); - tclsh_exe.linkSystemLibrary("kernel32"); - tclsh_exe.linkSystemLibrary("user32"); - tclsh_exe.linkSystemLibrary("advapi32"); - tclsh_exe.linkSystemLibrary("userenv"); - tclsh_exe.linkSystemLibrary("ws2_32"); + tclsh_exe.root_module.linkSystemLibrary("netapi32", .{}); + tclsh_exe.root_module.linkSystemLibrary("kernel32", .{}); + tclsh_exe.root_module.linkSystemLibrary("user32", .{}); + tclsh_exe.root_module.linkSystemLibrary("advapi32", .{}); + tclsh_exe.root_module.linkSystemLibrary("userenv", .{}); + tclsh_exe.root_module.linkSystemLibrary("ws2_32", .{}); } if (target.result.os.tag == .windows) { - tclsh_exe.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a")); + tclsh_exe.root_module.addObjectFile(b.path(tcl_source_folder ++ "/libtommath/win64/libtommath.dll.a")); //### jmn - //tclsh_exe.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a")); + //tclsh_exe.root_module.addObjectFile(b.path(tcl_source_folder ++ "/compat/zlib/win64/libz.dll.a")); } else { - //tclsh_exe.linkLibrary(tommath_lib_compile); - //tclsh_exe.linkLibrary(zlib_lib_compile); + //tclsh_exe.root_module.linkLibrary(tommath_lib_compile); + //tclsh_exe.root_module.linkLibrary(zlib_lib_compile); } //### jmn tclsh_exe.step.dependOn(&zlib_lib_compile.step); - tclsh_exe.linkLibrary(zlib_lib_compile); - //tclsh.addLibraryPath(.{ .path = tcl_source_folder ++ "/compat/zlib/win64"}); - //tclsh.addLibraryPath(.{ .path = tcl_source_folder ++ "/libtommath/win64"}); - //tclsh.linkSystemLibrary("zlib1"); - //tclsh.linkSystemLibrary("tommath"); + tclsh_exe.root_module.linkLibrary(zlib_lib_compile); + //tclsh.root_module.addLibraryPath(.{ .path = tcl_source_folder ++ "/compat/zlib/win64"}); + //tclsh.root_module.addLibraryPath(.{ .path = tcl_source_folder ++ "/libtommath/win64"}); + //tclsh.root_module.linkSystemLibrary("zlib1", .{}); + //tclsh.root_module.linkSystemLibrary("tommath", .{}); //////////////////// tclvfs //const tclvfs_compile = try tclvfs_static.build_tclvfs(tcl_source_folder, "../tclvfs", b, target, optimize, finalstublib); //const build_tclvfs_step = b.step("build-tclvfs", "build tclvfs static library"); //build_tclvfs_step.dependOn(&tclvfs_compile.step); //tclsh_exe.step.dependOn(&tclvfs_compile.step); - //tclsh_exe.linkLibrary(tclvfs_compile); + //tclsh_exe.root_module.linkLibrary(tclvfs_compile); //////////////////// const tclvfs_compile = try tclvfs_shared.build_tclvfs(tcl_source_folder, "../tclvfs", b, target, optimize, finalstublib); const build_tclvfs_step = b.step("build-tclvfs", "build tclvfs shared library"); @@ -1755,10 +1781,10 @@ pub fn build(b: *std.Build) !void { //builds are investigated, TEMP_REFERENCE/metakit and TEMP_REFERENCE/KitCreator //in the punkshell repo are the reference material. - tclsh_exe.linkLibC(); + tclsh_exe.root_module.link_libc = true; //LDFLAGS_CONSOLE= -mconsole -pipe -static-libgcc -municode -Wl,--enable-auto-image-base - tclsh_exe.addWin32ResourceFile(.{ + tclsh_exe.root_module.addWin32ResourceFile(.{ .file = b.path(tcl_source_folder ++ "/win/tclsh.rc"), .flags = &.{ "/I", @@ -1792,8 +1818,8 @@ pub fn build(b: *std.Build) !void { } //Install library files - non recursive - var library_dir = try fs.cwd().openDir(tcl_source_folder ++ "/library", .{ .iterate = true }); - defer library_dir.close(); + var library_dir = try std.Io.Dir.cwd().openDir(b.graph.io, tcl_source_folder ++ "/library", .{ .iterate = true }); + defer library_dir.close(b.graph.io); const allowed_exts = [_][]const u8{ ".tcl", "", @@ -1802,7 +1828,7 @@ pub fn build(b: *std.Build) !void { //var copy_libfile: []const u8 = undefined; //var copy_libfile_step: *std.Build.Step = undefined; var install_libfile: *std.Build.Step.InstallFile = undefined; - while (try it.next()) |entry| { + while (try it.next(b.graph.io)) |entry| { if (entry.kind == .file) { const ext = fs.path.extension(entry.name); const include_file = for (allowed_exts) |e| { diff --git a/src/buildsuites/suite_tcl90/build_libtommath/build_libtommath.zig b/src/buildsuites/suite_tcl90/build_libtommath/build_libtommath.zig index 4dcd110c..33a049ff 100644 --- a/src/buildsuites/suite_tcl90/build_libtommath/build_libtommath.zig +++ b/src/buildsuites/suite_tcl90/build_libtommath/build_libtommath.zig @@ -6,28 +6,31 @@ const fs = std.fs; // runner. //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 { - const lib = b.addStaticLibrary(.{ + const lib = b.addLibrary(.{ + .linkage = .static, .name = "tommath", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .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(); //try flags.appendSlice(&.{ "-Wall", "-O2" }); try flags.appendSlice(&.{ "-Wall", "-O2", "-Wextra", "-Werror=return-type" }); //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) - 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 }); - defer dir.close(); + var dir = try std.Io.Dir.cwd().openDir(b.graph.io, subdir, .{ .iterate = true }); + defer dir.close(b.graph.io); var it = dir.iterate(); const allowed_exts = [_][]const u8{ ".c", }; - while (try it.next()) |entry| { + while (try it.next(b.graph.io)) |entry| { if (entry.kind == .file) { const ext = fs.path.extension(entry.name); 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}); - lib.linkLibC(); + lib.root_module.link_libc = true; if (target.result.os.tag == .windows) { - lib.linkSystemLibrary("advapi32"); //crypt + lib.root_module.linkSystemLibrary("advapi32", .{}); //crypt } - //lib.addIncludePath(.{ .path = subdir }); - lib.addIncludePath(b.path(subdir)); - lib.addIncludePath(b.path("../tcl90/generic")); //todo - fix - lib.addCSourceFiles(.{ + //lib.root_module.addIncludePath(.{ .path = subdir }); + lib.root_module.addIncludePath(b.path(subdir)); + lib.root_module.addIncludePath(b.path("../tcl90/generic")); //todo - fix + lib.root_module.addCSourceFiles(.{ .files = sources.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(.{ .name = "test_libtommath", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); exe.step.dependOn(&lib.step); - exe.linkLibC(); + exe.root_module.link_libc = true; if (target.result.os.tag == .windows) { - //exe.linkSystemLibrary("netapi32"); - //exe.linkSystemLibrary("kernel32"); - //exe.linkSystemLibrary("user32"); - exe.linkSystemLibrary("advapi32"); //crypt - //exe.linkSystemLibrary("userenv"); - //exe.linkSystemLibrary("ws2_32"); + //exe.root_module.linkSystemLibrary("netapi32", .{}); + //exe.root_module.linkSystemLibrary("kernel32", .{}); + //exe.root_module.linkSystemLibrary("user32", .{}); + exe.root_module.linkSystemLibrary("advapi32", .{}); //crypt + //exe.root_module.linkSystemLibrary("userenv", .{}); + //exe.root_module.linkSystemLibrary("ws2_32", .{}); } - //exe.addIncludePath(.{ .path = subdir }); - exe.addIncludePath(b.path(subdir)); - //exe.addIncludePath(.{ .path = subdir ++ "/demo" }); - exe.addIncludePath(b.path(subdir ++ "/demo")); - exe.addCSourceFile(.{ + //exe.root_module.addIncludePath(.{ .path = subdir }); + exe.root_module.addIncludePath(b.path(subdir)); + //exe.root_module.addIncludePath(.{ .path = subdir ++ "/demo" }); + exe.root_module.addIncludePath(b.path(subdir ++ "/demo")); + exe.root_module.addCSourceFile(.{ //.file = .{ .path = subdir ++ "/demo/test.c" }, .file = b.path(subdir ++ "/demo/test.c"), .flags = flags.items, }); - exe.addCSourceFile(.{ + exe.root_module.addCSourceFile(.{ //.file = .{ .path = subdir ++ "/demo/shared.c" }, .file = b.path(subdir ++ "/demo/shared.c"), .flags = flags.items, }); - exe.linkLibrary(lib); + exe.root_module.linkLibrary(lib); // This declares intent for the executable to be installed into the // 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(&.{ "-Wl,--out-implib=libtommath.dll.a", }); - const dll = b.addSharedLibrary(.{ - .name = "libtommath", + const dll = b.addLibrary(.{ + .linkage = .dynamic, + .name = "libtommath", + .root_module = b.createModule(.{ .target = target, .optimize = optimize, - }); - dll.linkLibC(); - dll.linkSystemLibrary("advapi32"); //crypt - //dll.addIncludePath(.{ .path = subdir }); - dll.addIncludePath(b.path(subdir)); - dll.addCSourceFiles(.{ + }), + }); + dll.root_module.link_libc = true; + dll.root_module.linkSystemLibrary("advapi32", .{}); //crypt + //dll.root_module.addIncludePath(.{ .path = subdir }); + dll.root_module.addIncludePath(b.path(subdir)); + dll.root_module.addCSourceFiles(.{ .files = sources.items, .flags = flags.items, }); b.installArtifact(dll); } else { - const shlib_tom = b.addSharedLibrary(.{ - .name = "tommath", + const shlib_tom = b.addLibrary(.{ + .linkage = .dynamic, + .name = "tommath", + .root_module = b.createModule(.{ .target = target, .optimize = optimize, - }); - shlib_tom.linkLibC(); - //shlib_tom.addIncludePath(.{ .path = subdir }); - shlib_tom.addIncludePath(b.path(subdir)); - shlib_tom.addCSourceFiles(.{ + }), + }); + shlib_tom.root_module.link_libc = true; + //shlib_tom.root_module.addIncludePath(.{ .path = subdir }); + shlib_tom.root_module.addIncludePath(b.path(subdir)); + shlib_tom.root_module.addCSourceFiles(.{ .files = sources.items, .flags = flags.items, }); diff --git a/src/buildsuites/suite_tcl90/build_tclthread/build_tclthread.zig b/src/buildsuites/suite_tcl90/build_tclthread/build_tclthread.zig index da58c456..f2522ef7 100644 --- a/src/buildsuites/suite_tcl90/build_tclthread/build_tclthread.zig +++ b/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 { const wrapfilecmd = b.addExecutable(.{ .name = "wrapfiletofile", - .root_source_file = b.path("tools/wrapfiletofile.zig"), - .target = b.graph.host, + .root_module = b.createModule(.{ + .root_source_file = b.path("tools/wrapfiletofile.zig"), + .target = b.graph.host, + }), }); const uuidcmd_step = b.addRunArtifact(wrapfilecmd); 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); b.getInstallStep().dependOn(&wf_uuidh.step); - const lib = b.addSharedLibrary(.{ + const lib = b.addLibrary(.{ + .linkage = .dynamic, .name = "tcl9thread301", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); //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(); //try flags.appendSlice(&.{ "-Wall", "-O2", "-fomit-frame-pointer", "-DNDEBUG" }); 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/threadCmd.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"); //if (target.result.os.tag == .windows) { - // lib.linkSystemLibrary("advapi32"); //crypt + // lib.root_module.linkSystemLibrary("advapi32", .{}); //crypt //} - lib.addIncludePath(b.path(subdir)); - lib.addIncludePath(b.path(subdir ++ "/generic")); + lib.root_module.addIncludePath(b.path(subdir)); + lib.root_module.addIncludePath(b.path(subdir ++ "/generic")); //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 //path also gives the compile its dependency on the generation step. - lib.addIncludePath(threaduuid_file.dirname()); - lib.addIncludePath(b.path(tcldir ++ "/generic")); //todo - fix - lib.addCSourceFiles(.{ + lib.root_module.addIncludePath(threaduuid_file.dirname()); + lib.root_module.addIncludePath(b.path(tcldir ++ "/generic")); //todo - fix + lib.root_module.addCSourceFiles(.{ .files = tclthread_sources.items, .flags = flags.items, }); - lib.linkLibrary(stublib); - lib.linkLibC(); - lib.addWin32ResourceFile(.{ + lib.root_module.linkLibrary(stublib); + lib.root_module.link_libc = true; + lib.root_module.addWin32ResourceFile(.{ .file = b.path(subdir ++ "/win/thread.rc"), .flags = &.{ "-DPACKAGE_MAJOR=3", diff --git a/src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_shared.zig b/src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_shared.zig index 4ec3ee8c..13248199 100644 --- a/src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_shared.zig +++ b/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 { //review - libname Vfs vs vfs??? - const lib = b.addSharedLibrary(.{ + const lib = b.addLibrary(.{ + .linkage = .dynamic, .name = "tcl9vfs142", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); //_ = stublib; - var flags = std.ArrayList([]const u8).init(b.allocator); + var flags = std.array_list.Managed([]const u8).init(b.allocator); defer flags.deinit(); //try flags.appendSlice(&.{ "-Wall", "-O3" }); 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? - 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"); - lib.addIncludePath(b.path(subdir)); - lib.addIncludePath(b.path(subdir ++ "/generic")); - lib.addIncludePath(b.path(tcldir ++ "/generic")); - lib.addIncludePath(b.path(tcldir ++ "/generic")); + lib.root_module.addIncludePath(b.path(subdir)); + lib.root_module.addIncludePath(b.path(subdir ++ "/generic")); + lib.root_module.addIncludePath(b.path(tcldir ++ "/generic")); + lib.root_module.addIncludePath(b.path(tcldir ++ "/generic")); if (target.result.os.tag == .windows) { - lib.addIncludePath(b.path(tcldir ++ "/win")); + lib.root_module.addIncludePath(b.path(tcldir ++ "/win")); } else { - lib.addIncludePath(b.path(tcldir ++ "/unix")); + lib.root_module.addIncludePath(b.path(tcldir ++ "/unix")); } - lib.addCSourceFiles(.{ + lib.root_module.addCSourceFiles(.{ .files = sources.items, .flags = flags.items, }); - lib.linkLibrary(stublib); - lib.linkLibC(); - lib.addWin32ResourceFile(.{ + lib.root_module.linkLibrary(stublib); + lib.root_module.link_libc = true; + lib.root_module.addWin32ResourceFile(.{ .file = b.path(subdir ++ "/win/tclvfs.rc"), .flags = &.{ "-DPACKAGE_MAJOR=1", diff --git a/src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_static.zig b/src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_static.zig index 77faae8a..43cd549b 100644 --- a/src/buildsuites/suite_tcl90/build_tclvfs/build_tclvfs_static.zig +++ b/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 { //review - libname Vfs vs vfs??? - const slib = b.addStaticLibrary(.{ + const slib = b.addLibrary(.{ + .linkage = .static, .name = "Vfs", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); _ = stublib; - var flags = std.ArrayList([]const u8).init(b.allocator); + var flags = std.array_list.Managed([]const u8).init(b.allocator); defer flags.deinit(); //try flags.appendSlice(&.{ "-Wall", "-O3" }); 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? - 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"); - slib.addIncludePath(b.path(subdir)); - slib.addIncludePath(b.path(subdir ++ "/generic")); - slib.addIncludePath(b.path(tcldir ++ "/generic")); - slib.addIncludePath(b.path(tcldir ++ "/generic")); - slib.addIncludePath(b.path(tcldir ++ "/win")); - slib.addCSourceFiles(.{ + slib.root_module.addIncludePath(b.path(subdir)); + slib.root_module.addIncludePath(b.path(subdir ++ "/generic")); + slib.root_module.addIncludePath(b.path(tcldir ++ "/generic")); + slib.root_module.addIncludePath(b.path(tcldir ++ "/generic")); + slib.root_module.addIncludePath(b.path(tcldir ++ "/win")); + slib.root_module.addCSourceFiles(.{ .files = sources.items, .flags = flags.items, }); - //slib.linkLibrary(stublib); - slib.linkLibC(); - slib.addWin32ResourceFile(.{ + //slib.root_module.linkLibrary(stublib); + slib.root_module.link_libc = true; + slib.root_module.addWin32ResourceFile(.{ .file = b.path(subdir ++ "/win/tclvfs.rc"), .flags = &.{ "-DPACKAGE_MAJOR=1", diff --git a/src/buildsuites/suite_tcl90/build_zlib/build_zlib.zig b/src/buildsuites/suite_tcl90/build_zlib/build_zlib.zig index 89803e60..a8d5831a 100644 --- a/src/buildsuites/suite_tcl90/build_zlib/build_zlib.zig +++ b/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"; } - const statlib = b.addStaticLibrary(.{ + const statlib = b.addLibrary(.{ + .linkage = .static, .name = statlibname, - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .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(); //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 @@ -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(&.{ "-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 }); - defer dir.close(); + var dir = try std.Io.Dir.cwd().openDir(b.graph.io, subdir, .{ .iterate = true }); + defer dir.close(b.graph.io); //var walker = try dir.walk(b.allocator); //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{ ".c", }; - while (try it.next()) |entry| { + while (try it.next(b.graph.io)) |entry| { if (entry.kind == .file) { const ext = fs.path.extension(entry.name); 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.addIncludePath(b.path(subdir)); - statlib.addIncludePath(b.path(subdir ++ "/contrib/minzip")); - statlib.addCSourceFiles(.{ + statlib.root_module.link_libc = true; + statlib.root_module.addIncludePath(b.path(subdir)); + statlib.root_module.addIncludePath(b.path(subdir ++ "/contrib/minzip")); + statlib.root_module.addCSourceFiles(.{ .files = zlib_sources.items, .flags = zlib_flags.items, }); 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); //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 //"-DZLIB_WINAPI", //"-Wl,-exclude-libs=ALL", - std.debug.print("build_zlib.zig flags {s}\n", .{dylib_flags.items}); - const dylib = b.addSharedLibrary(.{ + std.debug.print("build_zlib.zig flags:", .{}); + for (dylib_flags.items) |f| std.debug.print(" {s}", .{f}); + std.debug.print("\n", .{}); + const dylib = b.addLibrary(.{ + .linkage = .dynamic, .name = "zlib1", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); - dylib.linkLibC(); - dylib.addIncludePath(b.path(subdir)); - dylib.addIncludePath(b.path(subdir ++ "/contrib/minizip")); - dylib.addCSourceFiles(.{ + dylib.root_module.link_libc = true; + dylib.root_module.addIncludePath(b.path(subdir)); + dylib.root_module.addIncludePath(b.path(subdir ++ "/contrib/minizip")); + dylib.root_module.addCSourceFiles(.{ .files = zlib_sources.items, .flags = dylib_flags.items, }); - //dylib.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 = .{ .path = "zlib/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); const mgz_exe = b.addExecutable(.{ .name = "minigzip", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); mgz_exe.step.dependOn(&statlib.step); - mgz_exe.addIncludePath(b.path(subdir)); - mgz_exe.addCSourceFile(.{ + mgz_exe.root_module.addIncludePath(b.path(subdir)); + mgz_exe.root_module.addCSourceFile(.{ .file = b.path(subdir ++ "/test/minigzip.c"), .flags = zlib_flags.items, }); - mgz_exe.linkLibC(); - mgz_exe.linkLibrary(statlib); + mgz_exe.root_module.link_libc = true; + mgz_exe.root_module.linkLibrary(statlib); b.installArtifact(mgz_exe); const eg_exe = b.addExecutable(.{ .name = "zlib_example", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); eg_exe.step.dependOn(&statlib.step); - eg_exe.addIncludePath(b.path(subdir)); - eg_exe.addCSourceFile(.{ + eg_exe.root_module.addIncludePath(b.path(subdir)); + eg_exe.root_module.addCSourceFile(.{ .file = b.path(subdir ++ "/test/example.c"), .flags = zlib_flags.items, }); - eg_exe.linkLibC(); - eg_exe.linkLibrary(statlib); + eg_exe.root_module.link_libc = true; + eg_exe.root_module.linkLibrary(statlib); b.installArtifact(eg_exe); const egd_exe = b.addExecutable(.{ .name = "zlib_example_d", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); egd_exe.step.dependOn(&statlib.step); - egd_exe.addIncludePath(b.path(subdir)); - egd_exe.addCSourceFile(.{ + egd_exe.root_module.addIncludePath(b.path(subdir)); + egd_exe.root_module.addCSourceFile(.{ .file = b.path(subdir ++ "/test/example.c"), .flags = dylib_flags.items, }); - egd_exe.linkLibrary(dylib); + egd_exe.root_module.linkLibrary(dylib); egd_exe.root_module.addRPathSpecial("$ORIGIN/../lib"); - egd_exe.linkLibC(); + egd_exe.root_module.link_libc = true; b.installArtifact(egd_exe); const mgzd_exe = b.addExecutable(.{ .name = "minigzip_d", - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); mgzd_exe.step.dependOn(&statlib.step); - mgzd_exe.addIncludePath(b.path(subdir)); - mgzd_exe.addCSourceFile(.{ + mgzd_exe.root_module.addIncludePath(b.path(subdir)); + mgzd_exe.root_module.addCSourceFile(.{ .file = b.path(subdir ++ "/test/minigzip.c"), .flags = dylib_flags.items, }); mgzd_exe.root_module.addRPathSpecial("$ORIGIN/../lib"); - mgzd_exe.linkLibrary(dylib); + mgzd_exe.root_module.linkLibrary(dylib); b.installArtifact(mgzd_exe); return statlib; diff --git a/src/buildsuites/suite_tcl90/suite.tcl b/src/buildsuites/suite_tcl90/suite.tcl index 6885eb12..bbcd4694 100644 --- a/src/buildsuites/suite_tcl90/suite.tcl +++ b/src/buildsuites/suite_tcl90/suite.tcl @@ -50,9 +50,10 @@ array set opt { -testargs {} } #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; -#recipe also validated against the original 0.14.0-dev.2074) > 'zig' on PATH. -set pinned_zig [file normalize [file join $suiteroot .. .. .. bin tools zig-x86_64-windows-0.14.1 zig.exe]] +#bin/tools (zig 0.16.0 official release - hosted on punkbin, minisign-verified; +#the recipe is 0.16-API and does NOT build under 0.14/0.15 - see README Lineage) +#> '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)]} { set opt(-zig) $env(PUNK_ZIG) } elseif {[file exists $pinned_zig]} { diff --git a/src/buildsuites/suite_tcl90/tools/wrapfiletofile.zig b/src/buildsuites/suite_tcl90/tools/wrapfiletofile.zig index eddb33fc..525ee9c6 100644 --- a/src/buildsuites/suite_tcl90/tools/wrapfiletofile.zig +++ b/src/buildsuites/suite_tcl90/tools/wrapfiletofile.zig @@ -10,13 +10,20 @@ const usage = \\ -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); defer arena_state.deinit(); 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_output_file_path: ?[]const u8 = null; var opt_prefix: ?[]const u8 = null; @@ -26,28 +33,27 @@ pub fn main() !void { var i: usize = 1; while (i < args.len) : (i += 1) { const arg = args[i]; - if (std.mem.eql(u8, "-h",arg) or std.mem.eql(u8, "-help",arg)) { - try std.io.getStdOut().writeAll(usage); - return std.process.cleanExit(); - } else if (std.mem.eql(u8,"-prefix",arg)) { + if (std.mem.eql(u8, "-h", arg) or std.mem.eql(u8, "-help", arg)) { + std.debug.print("{s}\n", .{usage}); + return std.process.cleanExit(io); + } else if (std.mem.eql(u8, "-prefix", arg)) { i += 1; if (i > args.len) fatal("expected arg after '{s}'", .{arg}); opt_prefix = args[i]; - } else if (std.mem.eql(u8,"-input",arg)) { + } else if (std.mem.eql(u8, "-input", arg)) { i += 1; if (i > args.len) fatal("expected arg after '{s}'", .{arg}); if (opt_input_file_path != null) fatal("duplicated {s} argument", .{arg}); opt_input_file_path = args[i]; - } else if (std.mem.eql(u8,"-output",arg)) { + } else if (std.mem.eql(u8, "-output", arg)) { i += 1; if (i > args.len) fatal("expected arg after '{s}'", .{arg}); if (opt_output_file_path != null) fatal("duplicated {s} argument", .{arg}); opt_output_file_path = args[i]; - } else if (std.mem.eql(u8,"-prefixnl",arg)) { - i+= 1; + } else if (std.mem.eql(u8, "-prefixnl", arg)) { + i += 1; 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; } else { 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 output_file_path = opt_output_file_path orelse fatal("missing -output file", .{}); - 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_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 prefix = opt_prefix orelse fatal("missing -prefix string", .{}); + + 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(); - const input_data = try input_file.readToEndAlloc(arena, std.math.maxInt(usize)); - defer arena.free(input_data); + defer arena.free(input_data); std.debug.print("inputfile - Read {d} octets.\n", .{input_data.len}); - var output_file = std.fs.cwd().createFile(output_file_path, .{}) catch |err| { - fatal("Unable to open '{s}': {s}", .{ output_file_path, @errorName(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) }); }; - defer output_file.close(); - _ = try output_file.write(prefix); + defer output_file.close(io); + try output_file.writeStreamingAll(io, prefix); if (opt_prefixnl) { - _ = try output_file.write("\n"); + try output_file.writeStreamingAll(io, "\n"); } - try output_file.writeAll(input_data); - return std.process.cleanExit(); + try output_file.writeStreamingAll(io, input_data); + return std.process.cleanExit(io); } fn fatal(comptime format: []const u8, args: anytype) noreturn { - std.debug.print(format,args); + std.debug.print(format, args); std.process.exit(1); -} \ No newline at end of file +} diff --git a/src/scriptapps/bin/punk-getzig.bash b/src/scriptapps/bin/punk-getzig.bash index f57e914b..f0c8d761 100644 --- a/src/scriptapps/bin/punk-getzig.bash +++ b/src/scriptapps/bin/punk-getzig.bash @@ -2,7 +2,7 @@ #tarball="zig-x86_64-windows-0.15.2.zip" #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" uristring="https://ziglang.org" diff --git a/src/scriptapps/bin/punk-getzig.ps1 b/src/scriptapps/bin/punk-getzig.ps1 index 6b2fac90..c8251d23 100644 --- a/src/scriptapps/bin/punk-getzig.ps1 +++ b/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.16.0-dev.254+6dd0270a1.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]