Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastfec 0.1.9 #123946

Closed
wants to merge 3 commits into from
Closed
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
50 changes: 31 additions & 19 deletions Formula/fastfec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class Fastfec < Formula
desc "Extremely fast FEC filing parser written in C"
homepage "https://github.com/washingtonpost/FastFEC"
url "https://github.com/washingtonpost/FastFEC/archive/refs/tags/0.0.4.tar.gz"
sha256 "8c508e0a93416a1ce5609536152dcbdab0df414c3f3a791e11789298455d1c71"
# Check whether PCRE linking issue is fixed in Zig at version bump.
url "https://github.com/washingtonpost/FastFEC/archive/refs/tags/0.1.9.tar.gz"
sha256 "1f6611b76c54005580d937cbac75b57783a33aa18eb32e4906ae919f6a1f0c0e"
license "MIT"

bottle do
Expand All @@ -16,29 +17,40 @@ class Fastfec < Formula

depends_on "pkg-config" => :build
depends_on "zig" => :build
depends_on "pcre"
uses_from_macos "curl"

on_macos do
# Zig attempts to link with `libpcre.a` on Linux.
# This fails because it was not compiled with `-fPIC`.
# Use Homebrew PCRE on Linux when upstream resolves
# https://github.com/ziglang/zig/issues/14111
# Don't forget to update the `install` method.
depends_on "pcre"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it use pcre2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there isn't an issue yet, could you make one for that too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end

resource "homebrew-13360" do
url "https://docquery.fec.gov/dcdev/posted/13360.fec"
sha256 "b7e86309f26af66e21b28aec7bd0f7844d798b621eefa0f7601805681334e04c"
end

# Fix install_name rewriting for bottling.
# https://github.com/washingtonpost/FastFEC/pull/56
patch do
url "https://github.com/washingtonpost/FastFEC/commit/36cf7e84083ac2c6dbd1694107e2c0a3fdc800ae.patch?full_index=1"
sha256 "d00cc61ea7bd1ab24496265fb8cf203de7451ef6b77a69822becada3f0e14047"
end

def install
ENV["ZIG_SYSTEM_LINKER_HACK"] = "1"
args = [
# Use brew's pcre
"-Dvendored-pcre=false",
]
if OS.linux?
args << "--search-prefix"
args << Formula["curl"].opt_prefix
end
system "zig", "build", *args
# Set `vendored-pcre` to `false` unconditionally when `pcre` linkage is fixed upstream.
system "zig", "build", "-Dvendored-pcre=#{OS.linux?}"
bin.install "zig-out/bin/fastfec"
lib.install "zig-out/lib/#{shared_library("libfastfec")}"
end

test do
system "#{bin}/fastfec", "--no-stdin", "13425"
assert_predicate testpath/"output/13425/F3XN.csv", :exist?
assert_predicate testpath/"output/13425/header.csv", :exist?
assert_predicate testpath/"output/13425/SA11A1.csv", :exist?
assert_predicate testpath/"output/13425/SB23.csv", :exist?
testpath.install resource("homebrew-13360")
system bin/"fastfec", "--no-stdin", "13360.fec"
%w[F3XA header SA11A1 SA17 SB23 SB29].each do |name|
assert_path_exists testpath/"output/13360/#{name}.csv"
end
end
end