From bfa474b6346a557fe7d0e7567ca1cb23fa15536a Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 01:39:01 -0400 Subject: [PATCH 1/5] bc: add arbitrary-precision calculator tools --- Formula/bc.rb | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 58 insertions(+) create mode 100644 Formula/bc.rb diff --git a/Formula/bc.rb b/Formula/bc.rb new file mode 100644 index 0000000..fe56151 --- /dev/null +++ b/Formula/bc.rb @@ -0,0 +1,57 @@ +require_relative "../Kandelo/formula_support/kandelo_formula_support" + +class Bc < Formula + include KandeloFormulaSupport + + desc "Arbitrary-precision numeric processing language for Kandelo" + homepage "https://www.gnu.org/software/bc/" + url "https://ftpmirror.gnu.org/gnu/bc/bc-1.08.2.tar.gz" + mirror "https://ftp.gnu.org/gnu/bc/bc-1.08.2.tar.gz" + sha256 "ae470fec429775653e042015edc928d07c8c3b2fc59765172a330d3d87785f86" + license "GPL-3.0-or-later" + + depends_on "texinfo" => :build + + skip_clean "bin/bc", "bin/dc" + + def install + kandelo_require_arch!("wasm32") + + kandelo_wasm_build do |root| + ENV.delete("BC_ENV_ARGS") + + system kandelo_configure, *kandelo_std_configure_args, + "--disable-dependency-tracking", + "--without-libedit", + "--without-readline" + system "make", "-j#{ENV.make_jobs}" + + instrumented = buildpath/"dc/dc.instrumented" + system "#{root}/scripts/run-wasm-fork-instrument.sh", + buildpath/"dc/dc", "-o", instrumented + mv instrumented, buildpath/"dc/dc" + + system "make", "install" + end + end + + test do + assert_match(/bc(?:\.wasm)? 1\.08\.2$/, + kandelo_run_wasm(bin/"bc", ["--version"])) + assert_match(/dc(?:\.wasm)?.*1\.5\.2$/, + kandelo_run_wasm(bin/"dc", ["--version"])) + + source = <<~BC + scale=30 + 2^128 + 1/7 + BC + assert_equal <<~EOS, kandelo_run_wasm(bin/"bc", ["-q"], stdin: source) + 340282366920938463463374607431768211456 + .142857142857142857142857142857 + EOS + + assert_equal "dc-child5\n", + kandelo_run_wasm(bin/"dc", [], stdin: "!printf dc-child\n2 3 + p\n") + end +end diff --git a/README.md b/README.md index 1d2c102..44a16ff 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Current migration controls and pilots include: Kandelo's musl `catopen` and `catgets` implementation. - `ctags`, Universal Ctags' maintained tag generator, `readtags` query client, and optscript interpreter with complete C and C++ workflows. +- `bc`, the GNU arbitrary-precision calculator language and `dc` processor. The SDK is not yet a Homebrew dependency. Trusted builds supply an `HOMEBREW_KANDELO_ROOT` checkout containing the SDK, sysroot, kernel, and Node From 74f37a4b4f30db789cc74fa6faa01e284133fa74 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 01:44:46 -0400 Subject: [PATCH 2/5] bc: assert the installed dc version line --- Formula/bc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/bc.rb b/Formula/bc.rb index fe56151..7d2335e 100644 --- a/Formula/bc.rb +++ b/Formula/bc.rb @@ -38,7 +38,7 @@ def install test do assert_match(/bc(?:\.wasm)? 1\.08\.2$/, kandelo_run_wasm(bin/"bc", ["--version"])) - assert_match(/dc(?:\.wasm)?.*1\.5\.2$/, + assert_match(/\Adc(?:\.wasm)? 1\.5\.2 \(GNU bc 1\.08\.2\)$/, kandelo_run_wasm(bin/"dc", ["--version"])) source = <<~BC From 5de397bf58455a7b0e7f00b48b93c2424bc2b954 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 01:45:59 -0400 Subject: [PATCH 3/5] bc: keep dc on its native spawn path --- Formula/bc.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Formula/bc.rb b/Formula/bc.rb index 7d2335e..8c9da11 100644 --- a/Formula/bc.rb +++ b/Formula/bc.rb @@ -17,7 +17,7 @@ class Bc < Formula def install kandelo_require_arch!("wasm32") - kandelo_wasm_build do |root| + kandelo_wasm_build do ENV.delete("BC_ENV_ARGS") system kandelo_configure, *kandelo_std_configure_args, @@ -25,12 +25,6 @@ def install "--without-libedit", "--without-readline" system "make", "-j#{ENV.make_jobs}" - - instrumented = buildpath/"dc/dc.instrumented" - system "#{root}/scripts/run-wasm-fork-instrument.sh", - buildpath/"dc/dc", "-o", instrumented - mv instrumented, buildpath/"dc/dc" - system "make", "install" end end From 5b2faa8709ecb902038d6bb8277dfa0e10522f3a Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 22:30:45 -0400 Subject: [PATCH 4/5] bc: load support through the installed tap --- Formula/bc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/bc.rb b/Formula/bc.rb index 8c9da11..1c3638c 100644 --- a/Formula/bc.rb +++ b/Formula/bc.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 Bc < Formula include KandeloFormulaSupport From 7d2091c23fb628c3de15cd9a487bccf79b5adaeb Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Sat, 11 Jul 2026 23:27:36 -0400 Subject: [PATCH 5/5] bc: enforce fork-free artifact contracts --- Formula/bc.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Formula/bc.rb b/Formula/bc.rb index 1c3638c..6f6b21b 100644 --- a/Formula/bc.rb +++ b/Formula/bc.rb @@ -10,7 +10,9 @@ class Bc < Formula sha256 "ae470fec429775653e042015edc928d07c8c3b2fc59765172a330d3d87785f86" license "GPL-3.0-or-later" + depends_on "binaryen" => :build depends_on "texinfo" => :build + depends_on "wabt" => :build skip_clean "bin/bc", "bin/dc" @@ -25,6 +27,8 @@ def install "--without-libedit", "--without-readline" system "make", "-j#{ENV.make_jobs}" + kandelo_validate_wasm_artifact(buildpath/"bc/bc", fork: :forbidden) + kandelo_validate_wasm_artifact(buildpath/"dc/dc", fork: :forbidden) system "make", "install" end end