From 61751884331a4f2a12e9db8dcfa50f3f1f019c55 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 04:08:21 -0400 Subject: [PATCH 1/4] gawk: add real pattern-processing workflows --- Formula/gawk.rb | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 Formula/gawk.rb diff --git a/Formula/gawk.rb b/Formula/gawk.rb new file mode 100644 index 0000000..f373333 --- /dev/null +++ b/Formula/gawk.rb @@ -0,0 +1,86 @@ +require_relative "../Kandelo/formula_support/kandelo_formula_support" + +class Gawk < Formula + include KandeloFormulaSupport + + desc "GNU pattern scanning and processing language for Kandelo" + homepage "https://www.gnu.org/software/gawk/" + url "https://ftpmirror.gnu.org/gnu/gawk/gawk-5.3.0.tar.xz" + mirror "https://ftp.gnu.org/gnu/gawk/gawk-5.3.0.tar.xz" + sha256 "ca9c16d3d11d0ff8c69d79dc0b47267e1329a69b39b799895604ed447d3ca90b" + license "GPL-3.0-or-later" + + skip_clean "bin/gawk" + + def install + kandelo_require_arch!("wasm32") + + instrumented = buildpath/"gawk.instrumented" + kandelo_wasm_build do |root| + # The SDK site owns target facts; these probes are specific to gnulib and gawk. + ENV["gl_cv_func_strerror_0_works"] = "yes" + ENV["ac_cv_func_GetSystemTimeAsFileTime"] = "no" + + system kandelo_configure, *kandelo_std_configure_args, + "--disable-nls", + "--disable-extensions", + "--without-readline", + "--without-mpfr", + "--disable-dependency-tracking" + system "make", "-j#{ENV.make_jobs}" + system "#{root}/scripts/run-wasm-fork-instrument.sh", buildpath/"gawk", "-o", instrumented + end + + kandelo_install_bin(buildpath, "gawk.instrumented", "gawk") + man1.install buildpath/"doc/gawk.1" + end + + test do + assert_match(/GNU Awk 5\.3\.0$/, kandelo_run_wasm(bin/"gawk", ["--version"])) + + (testpath/"sales.csv").write <<~CSV + region,amount + east,7 + west,3 + east,5 + CSV + aggregate = <<~AWK + BEGIN { FS = ","; OFS = ":" } + NR > 1 { total[$1] += $2; count[$1]++ } + END { + print "east", total["east"], count["east"] + print "west", total["west"], count["west"] + } + AWK + assert_equal "east:12:2\nwest:3:1\n", + kandelo_run_wasm( + bin/"gawk", [aggregate, "sales.csv"], env: { "KERNEL_CWD" => testpath } + ) + + extensions = <<~'AWK' + BEGIN { + match("alpha42", /([a-z]+)([0-9]+)/, capture) + print capture[1], capture[2] + print gensub(/([a-z]+)([0-9]+)/, "\\2-\\1", 1, "beta17") + } + AWK + assert_equal "alpha 42\n17-beta\n", kandelo_run_wasm(bin/"gawk", [extensions]) + + (testpath/"first.txt").write("a\nb\n") + (testpath/"second.txt").write("c\n") + assert_equal "1:1:a\n1:2:b\n2:1:c\n", + kandelo_run_wasm( + bin/"gawk", + ['{ print ARGIND ":" FNR ":" $0 }', "first.txt", "second.txt"], + env: { "KERNEL_CWD" => testpath }, + ) + + missing = kandelo_run_wasm( + bin/"gawk", ["{ print }", "missing.txt"], + env: { "KERNEL_CWD" => testpath }, + merge_stderr: true, + expected_status: 2, + ) + assert_match(/missing\.txt.*No such file or directory/, missing) + end +end diff --git a/README.md b/README.md index 523e7ea..f6ef630 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ Current migration controls and pilots include: - `dash`, the dependency-free POSIX shell with instrumented subprocess support; - `make`, GNU dependency-driven build automation using the tap's POSIX shell; - `ed`, the conforming line editor and restricted editor required by patch workflows; -- `m4`, the GNU macro processor with process-executing builtins backed by the tap's Dash shell. +- `m4`, the GNU macro processor with process-executing builtins backed by the tap's Dash shell; +- `gawk`, GNU's pattern scanning and text-processing language. The SDK is not yet a Homebrew dependency. Trusted builds supply an `HOMEBREW_KANDELO_ROOT` checkout containing the SDK, sysroot, kernel, and Node From 0359f599424822c13bc4c8af7e885b3d97b72629 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 04:09:01 -0400 Subject: [PATCH 2/4] gawk: satisfy formula style --- Formula/gawk.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/gawk.rb b/Formula/gawk.rb index f373333..0058241 100644 --- a/Formula/gawk.rb +++ b/Formula/gawk.rb @@ -79,7 +79,7 @@ def install bin/"gawk", ["{ print }", "missing.txt"], env: { "KERNEL_CWD" => testpath }, merge_stderr: true, - expected_status: 2, + expected_status: 2 ) assert_match(/missing\.txt.*No such file or directory/, missing) end From 5e63d4e90db8d273a22590a09e494a99321609a1 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 04:11:09 -0400 Subject: [PATCH 3/4] gawk: keep runtime search paths guest-relocatable --- Formula/gawk.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Formula/gawk.rb b/Formula/gawk.rb index 0058241..cd59c3b 100644 --- a/Formula/gawk.rb +++ b/Formula/gawk.rb @@ -15,6 +15,7 @@ class Gawk < Formula def install kandelo_require_arch!("wasm32") + guest_prefix = "/home/linuxbrew/.linuxbrew" instrumented = buildpath/"gawk.instrumented" kandelo_wasm_build do |root| # The SDK site owns target facts; these probes are specific to gnulib and gawk. @@ -26,6 +27,8 @@ def install "--disable-extensions", "--without-readline", "--without-mpfr", + "--datadir=#{guest_prefix}/share", + "--libdir=#{guest_prefix}/lib", "--disable-dependency-tracking" system "make", "-j#{ENV.make_jobs}" system "#{root}/scripts/run-wasm-fork-instrument.sh", buildpath/"gawk", "-o", instrumented From e3ec444dcdaa99f5c396f3055ac094d26d825c3e Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 22:11:31 -0400 Subject: [PATCH 4/4] gawk: load support through the installed tap --- Formula/gawk.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/gawk.rb b/Formula/gawk.rb index cd59c3b..d33214c 100644 --- a/Formula/gawk.rb +++ b/Formula/gawk.rb @@ -1,4 +1,4 @@ -require_relative "../Kandelo/formula_support/kandelo_formula_support" +require (Tap.fetch("automattic", "kandelo-homebrew").path/"Kandelo/formula_support/kandelo_formula_support").to_s class Gawk < Formula include KandeloFormulaSupport