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

fancy-cat 0.3.0 #209090

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fancy-cat 0.3.0 #209090

wants to merge 1 commit into from

Conversation

chenrui333
Copy link
Member

Created by brew bump


Created with brew bump-formula-pr.

@github-actions github-actions bot added bump-formula-pr PR was created using `brew bump-formula-pr` zig Zig use is a significant feature of the PR or issue labels Feb 27, 2025
autobump: add fancy-cat

Signed-off-by: Rui Chen <[email protected]>
@botantony
Copy link
Contributor

@chenrui333 I raised an issue about that problem, use this patch for now:

diff --git a/Formula/f/fancy-cat.rb b/Formula/f/fancy-cat.rb
index 70f4b9c62a5..dd36f65e60b 100644
--- a/Formula/f/fancy-cat.rb
+++ b/Formula/f/fancy-cat.rb
@@ -1,9 +1,9 @@
 class FancyCat < Formula
   desc "PDF reader for terminal emulators using the Kitty image protocol"
   homepage "https://github.com/freref/fancy-cat"
-  url "https://github.com/freref/fancy-cat/archive/refs/tags/v0.2.0.tar.gz"
-  sha256 "60f92cd08da6ed845b81edca75f376bf312b26e5420b7a244b275845b6f38af8"
-  license "MIT"
+  url "https://github.com/freref/fancy-cat/archive/refs/tags/v0.3.0.tar.gz"
+  sha256 "d062d1569dcf2ad664b61426f3a506bed653df3da1d0480a302a7e560c035622"
+  license "AGPL-3.0-only"
 
   bottle do
     sha256 cellar: :any,                 arm64_sequoia: "d12990678c4072a43aa05986d1513e50c7ea99b949c40739a967ccf71eff1977"
@@ -17,6 +17,8 @@ class FancyCat < Formula
   depends_on "zig" => :build
   depends_on "mupdf"
 
+  patch :DATA
+
   def install
     # Fix illegal instruction errors when using bottles on older CPUs.
     # https://github.com/Homebrew/homebrew-core/issues/92282
@@ -36,3 +38,98 @@ class FancyCat < Formula
     assert_match version.to_s, shell_output("#{bin}/fancy-cat --version")
   end
 end
+
+__END__
+diff --git a/build.zig b/build.zig
+index 84d13a9..d9c6ff3 100755
+--- a/build.zig
++++ b/build.zig
+@@ -1,12 +1,26 @@
+ const std = @import("std");
+ 
+-fn addMupdfDeps(exe: *std.Build.Step.Compile, b: *std.Build, prefix: []const u8) void {
+-    exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include", .{prefix}) });
+-    exe.addLibraryPath(.{ .cwd_relative = b.fmt("{s}/lib", .{prefix}) });
+-
+-    exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/lib/libmupdf.a", .{prefix}) });
+-    exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/lib/libmupdf-third.a", .{prefix}) });
+-
++fn addMupdfDeps(exe: *std.Build.Step.Compile, target: std.Target) void {
++    if (target.os.tag == .macos and target.cpu.arch == .aarch64) {
++        exe.addIncludePath(.{ .cwd_relative = "/opt/homebrew/include" });
++        exe.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib" });
++    } else if (target.os.tag == .macos and target.cpu.arch == .x86_64) {
++        exe.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
++        exe.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
++    } else if (target.os.tag == .linux) {
++        exe.addIncludePath(.{ .cwd_relative = "/home/linuxbrew/.linuxbrew/include" });
++        exe.addLibraryPath(.{ .cwd_relative = "/home/linuxbrew/.linuxbrew/lib" });
++
++        const linux_libs = [_][]const u8{
++            "mupdf-third", "harfbuzz",
++            "freetype",    "jbig2dec",
++            "jpeg",        "openjp2",
++            "gumbo",       "mujs",
++        };
++        for (linux_libs) |lib| exe.linkSystemLibrary(lib);
++    }
++    exe.linkSystemLibrary("mupdf");
++    exe.linkSystemLibrary("z");
+     exe.linkLibC();
+ }
+ 
+@@ -14,39 +28,13 @@ pub fn build(b: *std.Build) void {
+     const target = b.standardTargetOptions(.{});
+     const optimize = b.standardOptimizeOption(.{});
+ 
+-    const prefix = "./local";
+-    const location = "./deps/mupdf/local";
+-
+-    var make_args = std.ArrayList([]const u8).init(b.allocator);
+-    defer make_args.deinit();
+-
+-    make_args.append("make") catch unreachable;
+-    make_args.append("-C") catch unreachable;
+-    make_args.append("deps/mupdf") catch unreachable;
+-
+-    if (target.result.os.tag == .linux) {
+-        make_args.append("HAVE_X11=no") catch unreachable;
+-        make_args.append("HAVE_GLUT=no") catch unreachable;
+-    }
+-
+-    make_args.append("XCFLAGS=-w -DTOFU -DTOFU_CJK -DFZ_ENABLE_PDF=1 " ++
+-        "-DFZ_ENABLE_XPS=0 -DFZ_ENABLE_SVG=0 -DFZ_ENABLE_CBZ=0 " ++
+-        "-DFZ_ENABLE_IMG=0 -DFZ_ENABLE_HTML=0 -DFZ_ENABLE_EPUB=0") catch unreachable;
+-    make_args.append("tools=no") catch unreachable;
+-    make_args.append("apps=no") catch unreachable;
+-
+-    const prefix_arg = b.fmt("prefix={s}", .{prefix});
+-    make_args.append(prefix_arg) catch unreachable;
+-    make_args.append("install") catch unreachable;
+-
+-    const mupdf_build_step = b.addSystemCommand(make_args.items);
+-
+     const exe = b.addExecutable(.{
+         .name = "fancy-cat",
+         .root_source_file = b.path("src/main.zig"),
+         .target = target,
+         .optimize = optimize,
+     });
++
+     exe.headerpad_max_install_names = true;
+ 
+     const deps = .{
+@@ -59,12 +47,8 @@ pub fn build(b: *std.Build) void {
+     exe.root_module.addImport("vaxis", deps.vaxis.module("vaxis"));
+     exe.root_module.addImport("fzwatch", deps.fzwatch.module("fzwatch"));
+ 
+-    exe.step.dependOn(&mupdf_build_step.step);
+-
+-    addMupdfDeps(exe, b, location);
+-
++    addMupdfDeps(exe, target.result);
+     b.installArtifact(exe);
+-    b.getInstallStep().dependOn(&mupdf_build_step.step);
+ 
+     const run_cmd = b.addRunArtifact(exe);
+     if (b.args) |args| run_cmd.addArgs(args);

@botantony
Copy link
Contributor

this patch should be better: freref/fancy-cat/pull/67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autobump automerge-skip `brew pr-automerge` will skip this pull request bump-formula-pr PR was created using `brew bump-formula-pr` zig Zig use is a significant feature of the PR or issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants