Skip to content

Commit

Permalink
Use BinaryProvider to install Cairo and Pango (#292)
Browse files Browse the repository at this point in the history
* Use BinaryProvider to install Cairo and Pango

* Add Cirrus CI script

* Add Drone CI script

* Always set FONTCONFIG_FILE on Linux, FreeBSD and macOS

* Deprecate old library variables

* Add build.jl files for all dependencies
  • Loading branch information
giordano authored and tknopp committed Sep 6, 2019
1 parent ee4f16c commit a472c0c
Show file tree
Hide file tree
Showing 26 changed files with 1,262 additions and 311 deletions.
19 changes: 19 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
freebsd_instance:
image: freebsd-12-0-release-amd64
task:
name: FreeBSD
env:
matrix:
- JULIA_VERSION: 1.0
- JULIA_VERSION: 1.2
- JULIA_VERSION: 1.3
- JULIA_VERSION: nightly
allow_failures: $JULIA_VERSION == "nightly"
install_script:
- sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)"
build_script:
- cirrusjl build
test_script:
- cirrusjl test
coverage_script:
- cirrusjl coverage codecov coveralls
85 changes: 85 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
kind: pipeline
name: linux - arm - Julia 1.0

platform:
os: linux
arch: arm

steps:
- name: build
image: julia:1.0
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

---
kind: pipeline
name: linux - arm - Julia 1.2

platform:
os: linux
arch: arm

steps:
- name: build
image: julia:1.2
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

---
kind: pipeline
name: linux - arm - Julia 1.3

platform:
os: linux
arch: arm

steps:
- name: build
image: julia:1.3
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

---
kind: pipeline
name: linux - arm64 - Julia 1.0

platform:
os: linux
arch: arm64

steps:
- name: build
image: julia:1.0
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

---
kind: pipeline
name: linux - arm64 - Julia 1.2

platform:
os: linux
arch: arm64

steps:
- name: build
image: julia:1.2
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

---
kind: pipeline
name: linux - arm64 - Julia 1.3

platform:
os: linux
arch: arm64

steps:
- name: build
image: julia:1.3
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

...
7 changes: 2 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ uuid = "159f3aea-2a34-519c-b102-8c37f9878175"
version = "0.6.0"

[deps]
BinDeps = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Graphics = "a2bd30eb-e257-5431-a919-1863eab51364"
Homebrew = "d9be37ee-ecc9-5288-90f1-b9ca67657a75"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
WinRPM = "c17dfb99-b4f7-5aad-8812-456da1ad7187"

[compat]
BinDeps = "≥ 0.3.21"
BinaryProvider = "≥ 0.3.0"
Graphics = "≥ 0.1.0"
julia = "≥ 0.7.0"

Expand Down
244 changes: 62 additions & 182 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,184 +1,64 @@
using BinDeps

using Libdl
using Base.Sys

if Sys.isapple()
deps_file_str = open(joinpath(dirname(pathof(BinDeps)), "dependencies.jl")) do file
read(file, String)
end
if occursin("ZEval",pathof(BinDeps))
patched_dlclose = replace(deps_file_str, "Libdl.dlclose(h)" => "println(\"ignored: dlclose()\")")
include_string(BinDeps,patched_dlclose)
end
end


@BinDeps.setup

# check for cairo version
function validate_cairo_version(name,handle)
f = Libdl.dlsym_e(handle, "cairo_version")
f == C_NULL && return false
v = ccall(f, Int32,())
return v > 10800
using BinaryProvider # requires BinaryProvider 0.3.0 or later

# Parse some basic command-line arguments
const verbose = "--verbose" in ARGS
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))

# These are the two binary objects we care about
products = Product[
LibraryProduct(prefix, "libcairo", :libcairo),
LibraryProduct(prefix, "libpango", :libpango),
LibraryProduct(prefix, "libpangocairo", :libpangocairo),
LibraryProduct(prefix, "libgobject", :libgobject),
]

dependencies = [
# Freetype2-related dependencies
"build_Zlib.v1.2.11.jl",
"build_Bzip2.v1.0.6.jl",
"build_FreeType2.v2.10.1.jl",
# Glib-related dependencies
"build_PCRE.v8.42.0.jl",
"build_Libffi.v3.2.1.jl",
"build_Libiconv.v1.16.0.jl",
"build_Gettext.v0.20.1.jl",
"build_Glib.v2.59.0.jl",
# Fontconfig-related dependencies
"build_Libuuid.v2.34.0.jl",
"build_Expat.v2.2.7.jl",
"build_Fontconfig.v2.13.1.jl",
# HarfBuzz-related dependencies
"build_Graphite2.v1.3.13.jl",
"build_HarfBuzz.v2.6.1.jl",
# Cairo-related dependencies
"build_X11.v1.6.8.jl",
"build_LZO.v2.10.0.jl",
"build_Pixman.v0.38.4.jl",
"build_libpng.v1.6.37.jl",
"build_Cairo.v1.14.12.jl",
# Pango-only dependencies
"build_FriBidi.v1.0.5.jl",
# And finally...Pango!
"build_Pango.v1.42.4.jl"
]

for dependency in dependencies
# These libraries are necessary on Linux, FreeBSD and macOS...
platform_key_abi() isa Windows &&
occursin(r"^build_(Expat|Fontconfig)", dependency) &&
continue
# ...these only on Linux and FreeBSD
platform_key_abi() isa Union{MacOS,Windows} &&
occursin(r"^build_(Libuuid|Graphite2|HarfBuzz|X11)", dependency) &&
continue

# it's a bit faster to run the build in an anonymous module instead of
# starting a new julia process

# Build the dependencies
Mod = @eval module Anon end
Mod.include(dependency)
end

group = library_group("cairo")


libpng = library_dependency("png", aliases = ["libpng","libpng-1.5.14","libpng15","libpng12.so.0","libpng12"], runtime = false, group = group)
pixman = library_dependency("pixman", aliases = ["libpixman","libpixman-1","libpixman-1-0","libpixman-1.0"], depends = [libpng], runtime = false, group = group)
libffi = library_dependency("ffi", aliases = ["libffi"], runtime = false, group = group)
gettext = library_dependency("gettext", aliases = ["libintl", "preloadable_libintl", "libgettextpo", "intltool"], os = :Unix, group = group)
gobject = library_dependency("gobject", aliases = ["libgobject-2.0-0", "libgobject-2.0", "libgobject-2_0-0", "libgobject-2.0.so.0"], depends=[libffi, gettext], group = group)
freetype = library_dependency("freetype", aliases = ["libfreetype"], runtime = false, group = group)
fontconfig = library_dependency("fontconfig", aliases = ["libfontconfig-1", "libfontconfig", "libfontconfig.so.1"], depends = [freetype], runtime = false, group = group)
cairo = library_dependency("cairo", aliases = ["libcairo-2", "libcairo","libcairo.so.2", "libcairo2"], depends = [gobject,fontconfig,libpng], group = group, validate = validate_cairo_version)
pango = library_dependency("pango", aliases = ["libpango-1.0-0", "libpango-1.0","libpango-1.0.so.0", "libpango-1_0-0"], group = group)
pangocairo = library_dependency("pangocairo", aliases = ["libpangocairo-1.0-0", "libpangocairo-1.0", "libpangocairo-1.0.so.0"], depends = [cairo], group = group)
zlib = library_dependency("zlib", aliases = ["libzlib","zlib1"], os = :Windows, group = group)

if Sys.iswindows()
using WinRPM
provides(WinRPM.RPM,"libpango-1_0-0",[pango,pangocairo],os = :Windows)
provides(WinRPM.RPM,["glib2", "libgobject-2_0-0"],gobject,os = :Windows)
provides(WinRPM.RPM,"zlib-devel",zlib,os = :Windows)
provides(WinRPM.RPM,["libcairo2","libharfbuzz0"],cairo,os = :Windows)
end

if Sys.isapple()
using Homebrew
Homebrew.add("graphite2")
provides( Homebrew.HB, "cairo", cairo, os = :Darwin )
provides( Homebrew.HB, "pango", [pango, pangocairo], os = :Darwin, onload =
"""
function __init__()
ENV["PANGO_SYSCONFDIR"] = joinpath("$(Homebrew.prefix())", "etc")
end
""" )
provides( Homebrew.HB, "fontconfig", fontconfig, os = :Darwin )
provides( Homebrew.HB, "glib", gobject, os = :Darwin )
provides( Homebrew.HB, "libpng", libpng, os = :Darwin )
provides( Homebrew.HB, "gettext", gettext, os = :Darwin )
provides( Homebrew.HB, "freetype", freetype, os = :Darwin )
provides( Homebrew.HB, "libffi", libffi, os = :Darwin )
provides( Homebrew.HB, "pixman", pixman, os = :Darwin )
end

# System Package Managers
provides(AptGet,
Dict(
"libcairo2" => cairo,
"libfontconfig1" => fontconfig,
"libpango1.0-0" => [pango,pangocairo],
"libglib2.0-0" => gobject,
"libpng12-0" => libpng,
"libpixman-1-0" => pixman,
"gettext" => gettext
))

# TODO: check whether these are accurate
provides(Yum,
Dict(
"cairo" => cairo,
"fontconfig" => fontconfig,
"pango" => [pango,pangocairo],
"glib2" => gobject,
"libpng" => libpng,
"gettext-libs" => gettext
))

provides(Zypper,
Dict(
"libcairo2" => cairo,
"libfontconfig" => fontconfig,
"libpango-1_0" => [pango,pangocairo],
"libglib-2_0" => gobject,
"libpng12" => libpng,
"libpixman-1" => pixman,
"gettext" => gettext
))

const png_version = "1.5.14"

provides(Sources,
Dict(
URI("http://www.cairographics.org/releases/pixman-0.28.2.tar.gz") => pixman,
URI("http://www.cairographics.org/releases/cairo-1.12.16.tar.xz") => cairo,
URI("http://download.savannah.gnu.org/releases/freetype/freetype-2.4.11.tar.gz") => freetype,
URI("http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.10.2.tar.gz") => fontconfig,
URI("http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.2.tar.gz") => gettext,
URI("ftp://ftp.simplesystems.org/pub/libpng/png/src/history/libpng15/libpng-$(png_version).tar.gz") => libpng,
URI("ftp://sourceware.org/pub/libffi/libffi-3.0.11.tar.gz") => libffi,
URI("http://ftp.gnome.org/pub/gnome/sources/glib/2.34/glib-2.34.3.tar.xz") => gobject,
URI("http://ftp.gnome.org/pub/GNOME/sources/pango/1.32/pango-1.32.6.tar.xz") => [pango,pangocairo],
URI("http://zlib.net/zlib-1.2.7.tar.gz") => zlib
))

xx(t...) = (Sys.iswindows() ? t[1] : (Sys.islinux() || length(t) == 2) ? t[2] : t[3])

provides(BuildProcess,
Dict(
Autotools(libtarget = "pixman/libpixman-1.la", installed_libname = xx("libpixman-1-0.","libpixman-1.","libpixman-1.0.")*Libdl.dlext) => pixman,
Autotools(libtarget = xx("objs/.libs/libfreetype.la","libfreetype.la")) => freetype,
Autotools(libtarget = "src/libfontconfig.la") => fontconfig,
Autotools(libtarget = "src/libcairo.la", configure_options = append!(append!(
AbstractString[],
!Sys.islinux() ? AbstractString["--without-x","--disable-xlib","--disable-xcb"] : AbstractString[]),
Sys.isapple() ? AbstractString["--enable-quartz","--enable-quartz-font","--enable-quartz-image","--disable-gl"] : AbstractString[])) => cairo,
Autotools(libtarget = "gettext-tools/gnulib-lib/.libs/libgettextlib.la") => gettext,
Autotools(libtarget = "libffi.la") => libffi,
Autotools(libtarget = "gobject/libgobject-2.0.la") => gobject,
Autotools(libtarget = "pango/libpango-1.0.la") => [pango,pangocairo]
))

provides(BuildProcess,Autotools(libtarget = "libpng15.la"),libpng,os = :Unix)


if VERSION < v"1.0.0"
provides(SimpleBuild,
(@build_steps begin
GetSources(zlib)
@build_steps begin
ChangeDirectory(joinpath(BinDeps.depsdir(zlib),"src","zlib-1.2.7"))
MakeTargets(["-fwin32/Makefile.gcc"])
#MakeTargets(["-fwin32/Makefile.gcc","DESTDIR=../../usr/","INCLUDE_PATH=include","LIBRARY_PATH=lib","SHARED_MODE=1","install"])
end
end),zlib, os = :Windows)
end

prefix=joinpath(BinDeps.depsdir(libpng),"usr")
uprefix = replace(replace(prefix,"\\" => "/"),"C:/" => "/c/")
pngsrcdir = joinpath(BinDeps.depsdir(libpng),"src","libpng-$png_version")
pngbuilddir = joinpath(BinDeps.depsdir(libpng),"builds","libpng-$png_version")
provides(BuildProcess,
(@build_steps begin
GetSources(libpng)
CreateDirectory(pngbuilddir)
@build_steps begin
ChangeDirectory(pngbuilddir)
FileRule(joinpath(prefix,"lib","libpng15.dll"),@build_steps begin
`cmake -DCMAKE_INSTALL_PREFIX="$prefix" -G"MSYS Makefiles" $pngsrcdir`
`make`
`cp 'libpng*.dll' $prefix/lib`
`cp 'libpng*.a' $prefix/lib`
`cp 'libpng*.pc' $prefix/lib/pkgconfig`
`cp pnglibconf.h $prefix/include`
`cp $pngsrcdir/png.h $prefix/include`
`cp $pngsrcdir/pngconf.h $prefix/include`
end)
end
end),libpng, os = :Windows)


@BinDeps.install Dict([(:gobject, :_jl_libgobject),
(:cairo, :_jl_libcairo),
(:pango, :_jl_libpango),
(:pangocairo, :_jl_libpangocairo)])


if Sys.isapple()
import Pkg.Types.printpkgstyle
printpkgstyle(stdout, :Installed, "Patched install script, restarting Julia is recommended.")
end
# Finally, write out a deps.jl file
write_deps_file(joinpath(@__DIR__, "deps.jl"), products)
Loading

0 comments on commit a472c0c

Please sign in to comment.