Skip to content

Commit

Permalink
plantuml: test
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocab committed Nov 28, 2021
1 parent 38dbe68 commit 65d200a
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 0 deletions.
61 changes: 61 additions & 0 deletions Formula/graphviz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
class Graphviz < Formula
desc "Graph visualization software from AT&T and Bell Labs"
homepage "https://www.graphviz.org/"
url "https://gitlab.com/graphviz/graphviz.git",
tag: "2.49.3",
revision: "3425dae078262591d04fec107ec71ab010651852"
license "EPL-1.0"

depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "bison" => :build
depends_on "pkg-config" => :build
depends_on "carlocab/personal/librsvg"
depends_on "carlocab/personal/pango"
depends_on "gd"
depends_on "gts"
depends_on "libpng"
depends_on "libtool"

uses_from_macos "flex" => :build

on_linux do
depends_on "byacc" => :build
depends_on "ghostscript" => :build
end

def install
args = %W[
--disable-debug
--disable-dependency-tracking
--prefix=#{prefix}
--disable-php
--disable-swig
--disable-tcl
--with-quartz
--without-freetype2
--without-gdk
--without-gdk-pixbuf
--without-gtk
--without-poppler
--without-qt
--without-x
--with-gts
]

system "./autogen.sh"
system "./configure", *args
system "make"
system "make", "install"
end

test do
(testpath/"sample.dot").write <<~EOS
digraph G {
a -> b
}
EOS

system "#{bin}/dot", "-Tpdf", "-o", "sample.pdf", "sample.dot"
end
end
49 changes: 49 additions & 0 deletions Formula/harfbuzz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class Harfbuzz < Formula
desc "OpenType text shaping engine"
homepage "https://github.com/harfbuzz/harfbuzz"
url "https://github.com/harfbuzz/harfbuzz/archive/3.1.2.tar.gz"
sha256 "c27d2640e70e95bdbc2fbeca2f9cc212ee583da1149c9f6dacf1316217652e56"
license "MIT"
head "https://github.com/harfbuzz/harfbuzz.git"

depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "cairo"
depends_on "freetype"
depends_on "glib"
depends_on "gobject-introspection"
depends_on "graphite2"
depends_on "icu4c"

resource "ttf" do
url "https://github.com/harfbuzz/harfbuzz/raw/fc0daafab0336b847ac14682e581a8838f36a0bf/test/shaping/fonts/sha1sum/270b89df543a7e48e206a2d830c0e10e5265c630.ttf"
sha256 "9535d35dab9e002963eef56757c46881f6b3d3b27db24eefcc80929781856c77"
end

def install
args = %w[
--default-library=both
-Dcairo=enabled
-Dcoretext=enabled
-Dfreetype=enabled
-Dglib=enabled
-Dgobject=enabled
-Dgraphite=enabled
-Dicu=enabled
-Dintrospection=enabled
]

mkdir "build" do
system "meson", *std_meson_args, *args, ".."
system "ninja"
system "ninja", "install"
end
end

test do
resource("ttf").stage do
shape = `echo 'സ്റ്റ്' | #{bin}/hb-shape 270b89df543a7e48e206a2d830c0e10e5265c630.ttf`.chomp
assert_equal "[glyph201=0+1183|U0D4D=0+0]", shape
end
end
end
94 changes: 94 additions & 0 deletions Formula/librsvg.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
class Librsvg < Formula
desc "Library to render SVG files using Cairo"
homepage "https://wiki.gnome.org/Projects/LibRsvg"
url "https://download.gnome.org/sources/librsvg/2.50/librsvg-2.50.7.tar.xz"
sha256 "fffb61b08cd5282aaae147a02b305166a7426fad22a8b9427708f0f2fc426ebc"
license "LGPL-2.1-or-later"

depends_on "gobject-introspection" => :build
depends_on "pkg-config" => :build
depends_on "rust" => :build
depends_on "cairo"
depends_on "carlocab/personal/pango"
depends_on "gdk-pixbuf"
depends_on "glib"

def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--disable-Bsymbolic
--enable-tools=yes
--enable-pixbuf-loader=yes
--enable-introspection=yes
]

system "./configure", *args

# disable updating gdk-pixbuf cache, we will do this manually in post_install
# https://github.com/Homebrew/homebrew/issues/40833
inreplace "gdk-pixbuf-loader/Makefile",
"$(GDK_PIXBUF_QUERYLOADERS) > $(DESTDIR)$(gdk_pixbuf_cache_file) ;",
""

system "make", "install",
"gdk_pixbuf_binarydir=#{lib}/gdk-pixbuf-2.0/2.10.0/loaders",
"gdk_pixbuf_moduledir=#{lib}/gdk-pixbuf-2.0/2.10.0/loaders"
end

def post_install
# librsvg is not aware GDK_PIXBUF_MODULEDIR must be set
# set GDK_PIXBUF_MODULEDIR and update loader cache
ENV["GDK_PIXBUF_MODULEDIR"] = "#{HOMEBREW_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders"
system "#{Formula["gdk-pixbuf"].opt_bin}/gdk-pixbuf-query-loaders", "--update-cache"
end

test do
(testpath/"test.c").write <<~EOS
#include <librsvg/rsvg.h>
int main(int argc, char *argv[]) {
RsvgHandle *handle = rsvg_handle_new();
return 0;
}
EOS
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gdk_pixbuf = Formula["gdk-pixbuf"]
gettext = Formula["gettext"]
glib = Formula["glib"]
libpng = Formula["libpng"]
pixman = Formula["pixman"]
flags = %W[
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gdk_pixbuf.opt_include}/gdk-pixbuf-2.0
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{include}/librsvg-2.0
-I#{libpng.opt_include}/libpng16
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{cairo.opt_lib}
-L#{gdk_pixbuf.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lcairo
-lgdk_pixbuf-2.0
-lgio-2.0
-lglib-2.0
-lgobject-2.0
-lm
-lrsvg-2
]
on_macos do
flags << "-lintl"
end
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end
82 changes: 82 additions & 0 deletions Formula/pango.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
class Pango < Formula
desc "Framework for layout and rendering of i18n text"
homepage "https://www.pango.org/"
url "https://download.gnome.org/sources/pango/1.48/pango-1.48.10.tar.xz"
sha256 "21e1f5798bcdfda75eabc4280514b0896ab56f656d4e7e66030b9a2535ecdc98"
license "LGPL-2.0-or-later"
head "https://gitlab.gnome.org/GNOME/pango.git", branch: "main"

depends_on "gobject-introspection" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "cairo"
depends_on "carlocab/personal/harfbuzz"
depends_on "fontconfig"
depends_on "fribidi"
depends_on "glib"

def install
mkdir "build" do
system "meson", *std_meson_args,
"-Ddefault_library=both",
"-Dintrospection=enabled",
"-Duse_fontconfig=true",
".."
system "ninja", "-v"
system "ninja", "install", "-v"
end
end

test do
system "#{bin}/pango-view", "--version"
(testpath/"test.c").write <<~EOS
#include <pango/pangocairo.h>
int main(int argc, char *argv[]) {
PangoFontMap *fontmap;
int n_families;
PangoFontFamily **families;
fontmap = pango_cairo_font_map_get_default();
pango_font_map_list_families (fontmap, &families, &n_families);
g_free(families);
return 0;
}
EOS
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gettext = Formula["gettext"]
glib = Formula["glib"]
harfbuzz = Formula["harfbuzz"]
libpng = Formula["libpng"]
pixman = Formula["pixman"]
flags = %W[
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{harfbuzz.opt_include}/harfbuzz
-I#{include}/pango-1.0
-I#{libpng.opt_include}/libpng16
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{cairo.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lcairo
-lglib-2.0
-lgobject-2.0
-lpango-1.0
-lpangocairo-1.0
]
on_macos do
flags << "-lintl"
end
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end
32 changes: 32 additions & 0 deletions Formula/plantuml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class Plantuml < Formula
desc "Draw UML diagrams"
homepage "https://plantuml.com/"
url "https://downloads.sourceforge.net/project/plantuml/1.2021.14/plantuml.1.2021.14.jar"
sha256 "79af076fa7854741b7620fb01405caca7f297f015301c86dbefb893628689460"
license "GPL-3.0-or-later"

livecheck do
url :stable
regex(%r{url=.*?/plantuml[._-]v?(\d+(?:\.\d+)+)\.t}i)
end

depends_on "carlocab/personal/graphviz"
depends_on "openjdk"

def install
jar = "plantuml.jar"
libexec.install "plantuml.#{version}.jar" => jar
(bin/"plantuml").write <<~EOS
#!/bin/bash
if [[ "$*" != *"-gui"* ]]; then
VMARGS="-Djava.awt.headless=true"
fi
GRAPHVIZ_DOT="#{Formula["graphviz"].opt_bin}/dot" exec "#{Formula["openjdk"].opt_bin}/java" $VMARGS -jar #{libexec}/#{jar} "$@"
EOS
chmod 0755, bin/"plantuml"
end

test do
system bin/"plantuml", "-testdot"
end
end

0 comments on commit 65d200a

Please sign in to comment.