Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Formula/bc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require (Tap.fetch("automattic", "kandelo-homebrew").path/"Kandelo/formula_support/kandelo_formula_support").to_s

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 "binaryen" => :build
depends_on "texinfo" => :build
depends_on "wabt" => :build

skip_clean "bin/bc", "bin/dc"

def install
kandelo_require_arch!("wasm32")

kandelo_wasm_build do
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}"
kandelo_validate_wasm_artifact(buildpath/"bc/bc", fork: :forbidden)
kandelo_validate_wasm_artifact(buildpath/"dc/dc", fork: :forbidden)
system "make", "install"
end
end

test do
assert_match(/bc(?:\.wasm)? 1\.08\.2$/,
kandelo_run_wasm(bin/"bc", ["--version"]))
assert_match(/\Adc(?:\.wasm)? 1\.5\.2 \(GNU bc 1\.08\.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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down