-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ class Leptonica < Formula | |
sha256 cellar: :any_skip_relocation, x86_64_linux: "9b2c01e724c093ba4b4bf19bdd65edcc3ff70dbc5071e5e801f07b9f24cc2d63" | ||
end | ||
|
||
depends_on "cmake" => :build | ||
depends_on "pkg-config" => :build | ||
depends_on "giflib" | ||
depends_on "jpeg-turbo" | ||
|
@@ -25,23 +26,46 @@ class Leptonica < Formula | |
uses_from_macos "zlib" | ||
|
||
def install | ||
Check failure on line 28 in Formula/l/leptonica.rb GitHub Actions / Linux`brew install --verbose --formula --build-bottle leptonica` failed on Linux!
|
||
system "./configure", "--with-libwebp", "--with-libopenjpeg", *std_configure_args | ||
system "make", "install" | ||
system "cmake", "-S", ".", "-B", "build_shared", | ||
"-DBUILD_PROG=ON", | ||
"-DBUILD_SHARED_LIBS=ON", | ||
"-DCMAKE_INSTALL_RPATH=#{rpath}", | ||
*std_cmake_args | ||
system "cmake", "--build", "build_shared" | ||
system "cmake", "--install", "build_shared" | ||
|
||
system "cmake", "-S", ".", "-B", "build_static", | ||
"-DBUILD_PROG=OFF", | ||
"-DBUILD_SHARED_LIBS=OFF", | ||
*std_cmake_args | ||
system "cmake", "--build", "build_static" | ||
lib.install "build_static/src/libleptonica.a" | ||
|
||
# Add pkg-config symlink to align with autotools | ||
odie "lept.pc already exists!" if (lib/"pkgconfig/lept.pc").exist? | ||
odie "lept_Release.pc does not exist!" unless (lib/"pkgconfig/lept_Release.pc").exist? | ||
(lib/"pkgconfig").install_symlink "lept_Release.pc" => "lept.pc" | ||
end | ||
|
||
test do | ||
(testpath/"test.cpp").write <<~EOS | ||
#include <iostream> | ||
(testpath/"test.c").write <<~C | ||
#include <stdio.h> | ||
#include <leptonica/allheaders.h> | ||
int main(int argc, char **argv) { | ||
fprintf(stdout, "%d.%d.%d", LIBLEPT_MAJOR_VERSION, LIBLEPT_MINOR_VERSION, LIBLEPT_PATCH_VERSION); | ||
return 0; | ||
int main() { | ||
printf("%d.%d.%d", LIBLEPT_MAJOR_VERSION, LIBLEPT_MINOR_VERSION, LIBLEPT_PATCH_VERSION); | ||
writeImageFileInfo("#{test_fixtures("test.png")}", stderr, 0); | ||
return 0; | ||
} | ||
EOS | ||
C | ||
|
||
flags = ["-I#{include}/leptonica"] + ENV.cflags.to_s.split | ||
system ENV.cxx, "test.cpp", *flags | ||
assert_equal version.to_s, `./a.out` | ||
system ENV.cc, "test.c", "-o", "test", "-L#{lib}", "-lleptonica" | ||
assert_equal version.to_s, shell_output("./test 2>#{testpath}/stderr.log") | ||
assert_match <<~TEXT, (testpath/"stderr.log").read | ||
Reading the header: | ||
input image format type: png | ||
w = 8, h = 8, bps = 1, spp = 1, iscmap = 1 | ||
xres = 0, yres = 0 | ||
TEXT | ||
end | ||
end |