Improve cairo and pixman (#806)

* Use meson to build cairo

* Update xmake.lua

* Update xmake.lua

* modify ci

* fix pixman and cario

* Update xmake.lua

* fix freetype pkgconfig

* improve pkgconf

* Update xmake.lua

* restore ci

Co-authored-by: Kelvin Zhang <zhangxp1998@gmail.com>
pull/808/head
ruki 3 years ago committed by GitHub
parent b28784e30e
commit 4d6dedb0df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/windows.yml
  2. 39
      packages/c/cairo/patches/2021.10.07/macosx.patch
  3. 27
      packages/c/cairo/port/cairo-features.h.in
  4. 230
      packages/c/cairo/port/xmake.lua
  5. 46
      packages/c/cairo/xmake.lua
  6. 2
      packages/f/freetype/xmake.lua
  7. 32
      packages/p/pixman/xmake.lua
  8. 5
      packages/p/pkgconf/xmake.lua

@ -32,7 +32,7 @@ jobs:
- name: Tests
run: |
if ("${{ matrix.os }}" -eq "windows-latest") {
if ("${{ matrix.os }}" -eq "windows-2019") {
xmake l ./scripts/test.lua -D -a ${{ matrix.arch }} -k ${{ matrix.kind }} --vs_runtime=${{ matrix.vs_runtime }} --vs_sdkver=10.0.19041.0 --linkjobs=2
} else {
xmake l ./scripts/test.lua -D -a ${{ matrix.arch }} -k ${{ matrix.kind }} --vs_runtime=${{ matrix.vs_runtime }} --linkjobs=2

@ -0,0 +1,39 @@
diff --git a/meson.build b/meson.build
index 3c261d0ff..5f98981e9 100644
--- a/meson.build
+++ b/meson.build
@@ -192,6 +192,9 @@ test_deps = []
internal_deps = []
extra_link_args = []
+thread_dep = dependency('threads')
+deps += [thread_dep]
+
if host_machine.endian() == 'big'
conf.set('WORDS_BIGENDIAN', 1)
endif
diff --git a/util/cairo-script/meson.build b/util/cairo-script/meson.build
index 653c19d33..9f90bc8b5 100644
--- a/util/cairo-script/meson.build
+++ b/util/cairo-script/meson.build
@@ -46,17 +46,20 @@ pkgmod.generate(libcairoscript,
meson.override_dependency('cairo-script-interpreter', libcairoscript_dep)
csi_replay_exe = executable('csi-replay', csi_replay_sources,
+ c_args: pthread_c_args,
include_directories: [incbase],
dependencies: deps + [libcairo_dep, libcairoscript_dep],
)
csi_exec_exe = executable('csi-exec', csi_exec_sources,
+ c_args: pthread_c_args,
include_directories: [incbase],
dependencies: deps + [libcairo_dep, libcairoscript_dep],
)
if feature_conf.get('CAIRO_HAS_SCRIPT_SURFACE', 0) == 1 and conf.get('HAVE_LIBGEN_H', 0) == 1
csi_trace_exe = executable('csi-trace', csi_trace_sources,
+ c_args: pthread_c_args,
include_directories: [incbase],
dependencies: deps + [libcairo_dep, libcairoscript_dep],
)

@ -1,27 +0,0 @@
#ifndef CAIRO_FEATURES_H
#define CAIRO_FEATURES_H
#ifdef _WIN32
#define CAIRO_HAS_WIN32_SURFACE 1
#define CAIRO_HAS_WIN32_FONT 1
#endif
#define CAIRO_HAS_PNG_FUNCTIONS 1
#define CAIRO_HAS_PS_SURFACE 1
#define CAIRO_HAS_PDF_SURFACE 1
#define CAIRO_HAS_SCRIPT_SURFACE 1
#define CAIRO_HAS_SVG_SURFACE 1
#define CAIRO_HAS_IMAGE_SURFACE 1
#define CAIRO_HAS_MIME_SURFACE 1
#define CAIRO_HAS_RECORDING_SURFACE 1
#define CAIRO_HAS_OBSERVER_SURFACE 1
#define CAIRO_HAS_USER_FONT 1
#define CAIRO_HAS_GOBJECT_FUNCTIONS 0
#define CAIRO_HAS_FT_FONT 1
#define CAIRO_HAS_FC_FONT ${FC_ON}
#endif

@ -1,230 +0,0 @@
add_rules("mode.debug", "mode.release")
add_requires("zlib", "libpng", "pixman")
option("with_x11")
set_default(is_plat("linux") and true or false)
add_defines("CAIRO_HAS_XLIB_SURFACE=1")
option_end()
if has_config("with_x11") then
add_requires("libxrender")
end
option("with_freetype")
set_default(true)
add_defines(
"HAVE_FT_GLYPHSLOT_EMBOLDEN=1",
"HAVE_FT_LIBRARY_SETLCDFILTER=1",
"HAVE_FT_GLYPHSLOT_OBLIQUE=1",
"HAVE_FT_LOAD_SFNT_TABLE=1",
"HAVE_FT_GET_X11_FONT_FORMAT=" .. (has_config("with_x11") and "1" or "0"),
"CAIRO_HAS_FT_FONT=1"
)
option_end()
if has_config("with_freetype") then
add_requires("freetype")
end
option("with_fontconfig")
set_default(is_plat("linux") and true or false)
add_defines(
"CAIRO_HAS_FC_FONT=1"
)
option_end()
if has_config("with_fontconfig") then
add_requires("fontconfig")
end
target("cairo")
set_kind("$(kind)")
add_packages("zlib", "libpng", "pixman")
add_includedirs("$(projectdir)")
add_includedirs("$(projectdir)/src")
if is_plat("windows") then
if is_kind("static") then
add_defines("CAIRO_WIN32_STATIC_BUILD=1")
end
add_syslinks("gdi32", "msimg32", "user32")
elseif is_plat("macosx") then
add_frameworks("CoreGraphics", "CoreFoundation")
elseif is_plat("linux") then
add_cxflags("pthread")
end
if is_plat("windows") then
add_includedirs("$(projectdir)/src/win32")
add_files(
"src/win32/cairo-win32-debug.c",
"src/win32/cairo-win32-device.c",
"src/win32/cairo-win32-gdi-compositor.c",
"src/win32/cairo-win32-system.c",
"src/win32/cairo-win32-surface.c",
"src/win32/cairo-win32-display-surface.c",
"src/win32/cairo-win32-printing-surface.c",
"src/win32/cairo-win32-font.c"
)
else
add_defines(
"HAVE_INTTYPES_H=1",
"HAVE_STDINT_H=1",
"HAVE_SYS_TYPES_H=1",
"HAVE_UINT64_T=1",
"HAVE_UNISTD_H=1",
"CAIRO_HAS_PTHREAD=1",
"CAIRO_HAS_REAL_PTHREAD=1"
)
end
-- set_configvar("FT_ON", has_config("with_freetype") and 1 or 0)
-- add_configfiles("cairo-features.h.in", {prefixdir = "$(projectdir)"})
add_headerfiles(
"src/cairo.h",
"src/cairo-deprecated.h",
"src/cairo-pdf.h",
"src/cairo-ps.h",
"src/cairo-script.h",
"src/cairo-svg.h",
"src/cairo-win32.h",
"src/cairo-ft.h",
"src/cairo-xlib.h",
"cairo-features.h",
"cairo-version.h",
"util/cairo-gobject/cairo-gobject.h",
{prefixdir = "cairo"}
)
add_files(
"src/cairo-analysis-surface.c",
"src/cairo-arc.c",
"src/cairo-array.c",
"src/cairo-atomic.c",
"src/cairo-base64-stream.c",
"src/cairo-base85-stream.c",
"src/cairo-bentley-ottmann.c",
"src/cairo-bentley-ottmann-rectangular.c",
"src/cairo-bentley-ottmann-rectilinear.c",
"src/cairo-botor-scan-converter.c",
"src/cairo-boxes.c",
"src/cairo-boxes-intersect.c",
"src/cairo.c",
"src/cairo-cache.c",
"src/cairo-clip.c",
"src/cairo-clip-boxes.c",
"src/cairo-clip-polygon.c",
"src/cairo-clip-region.c",
"src/cairo-clip-surface.c",
"src/cairo-color.c",
"src/cairo-composite-rectangles.c",
"src/cairo-compositor.c",
"src/cairo-contour.c",
"src/cairo-damage.c",
"src/cairo-debug.c",
"src/cairo-default-context.c",
"src/cairo-device.c",
"src/cairo-error.c",
"src/cairo-fallback-compositor.c",
"src/cairo-fixed.c",
"src/cairo-font-face.c",
"src/cairo-font-face-twin.c",
"src/cairo-font-face-twin-data.c",
"src/cairo-font-options.c",
"src/cairo-freelist.c",
"src/cairo-freed-pool.c",
"src/cairo-gstate.c",
"src/cairo-hash.c",
"src/cairo-hull.c",
"src/cairo-image-compositor.c",
"src/cairo-image-info.c",
"src/cairo-image-source.c",
"src/cairo-image-surface.c",
"src/cairo-line.c",
"src/cairo-lzw.c",
"src/cairo-matrix.c",
"src/cairo-mask-compositor.c",
"src/cairo-mesh-pattern-rasterizer.c",
"src/cairo-mempool.c",
"src/cairo-misc.c",
"src/cairo-mono-scan-converter.c",
"src/cairo-mutex.c",
"src/cairo-no-compositor.c",
"src/cairo-observer.c",
"src/cairo-output-stream.c",
"src/cairo-paginated-surface.c",
"src/cairo-path-bounds.c",
"src/cairo-path.c",
"src/cairo-path-fill.c",
"src/cairo-path-fixed.c",
"src/cairo-path-in-fill.c",
"src/cairo-path-stroke.c",
"src/cairo-path-stroke-boxes.c",
"src/cairo-path-stroke-polygon.c",
"src/cairo-path-stroke-traps.c",
"src/cairo-path-stroke-tristrip.c",
"src/cairo-pattern.c",
"src/cairo-pen.c",
"src/cairo-polygon.c",
"src/cairo-polygon-intersect.c",
"src/cairo-polygon-reduce.c",
"src/cairo-raster-source-pattern.c",
"src/cairo-recording-surface.c",
"src/cairo-rectangle.c",
"src/cairo-rectangular-scan-converter.c",
"src/cairo-region.c",
"src/cairo-rtree.c",
"src/cairo-scaled-font.c",
"src/cairo-shape-mask-compositor.c",
"src/cairo-slope.c",
"src/cairo-spans.c",
"src/cairo-spans-compositor.c",
"src/cairo-spline.c",
"src/cairo-stroke-dash.c",
"src/cairo-stroke-style.c",
"src/cairo-surface.c",
"src/cairo-surface-clipper.c",
"src/cairo-surface-fallback.c",
"src/cairo-surface-observer.c",
"src/cairo-surface-offset.c",
"src/cairo-surface-snapshot.c",
"src/cairo-surface-subsurface.c",
"src/cairo-surface-wrapper.c",
"src/cairo-time.c",
"src/cairo-tor-scan-converter.c",
"src/cairo-tor22-scan-converter.c",
"src/cairo-clip-tor-scan-converter.c",
"src/cairo-tag-attributes.c",
"src/cairo-tag-stack.c",
"src/cairo-toy-font-face.c",
"src/cairo-traps.c",
"src/cairo-tristrip.c",
"src/cairo-traps-compositor.c",
"src/cairo-unicode.c",
"src/cairo-user-font.c",
"src/cairo-version.c",
"src/cairo-wideint.c",
-- generic font support
"src/cairo-cff-subset.c",
"src/cairo-scaled-font-subsets.c",
"src/cairo-truetype-subset.c",
"src/cairo-type1-fallback.c",
"src/cairo-type1-glyph-names.c",
"src/cairo-type1-subset.c",
"src/cairo-type3-glyph-surface.c",
-- pdf
"src/cairo-pdf-interchange.c",
"src/cairo-pdf-operators.c",
"src/cairo-pdf-shading.c",
"src/cairo-pdf-surface.c",
-- png
"src/cairo-png.c",
-- ps surface
"src/cairo-ps-surface.c",
-- deflate source
"src/cairo-deflate-stream.c",
-- svg surface
"src/cairo-svg-surface.c",
-- script surface
"src/cairo-script-surface.c"
)
if has_config("with_freetype") then
add_files("src/cairo-ft-font.c")
add_packages("freetype", "fontconfig")
end
target_end()

@ -3,35 +3,53 @@ package("cairo")
set_homepage("https://cairographics.org/")
set_description("Vector graphics library with cross-device output support.")
set_urls("https://cairographics.org/releases/cairo-$(version).tar.xz")
add_versions("1.16.0", "5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331")
add_urls("https://gitlab.freedesktop.org/cairo/cairo/-/archive/a04786b9330109ce54bf7f65c7068281419cec6a/cairo-a04786b9330109ce54bf7f65c7068281419cec6a.tar.gz")
add_versions("2021.10.07", "8fc7e374a2de1d975171b58c7d43e4d430a28da082c0536ad6e2b178a9863d03")
add_deps("libpng", "pixman", "zlib", "freetype")
if is_plat("linux") then
add_deps("fontconfig")
add_deps("meson", "ninja")
add_deps("libpng", "pixman", "zlib", "freetype", "expat", "glib")
if is_plat("windows") then
add_deps("pkgconf")
end
add_patches("2021.10.07", path.join(os.scriptdir(), "patches", "2021.10.07", "macosx.patch"), "8f47e272eb9112e0592b2fcf816fe225c6540a9298dbddc38543ae2fc9fe4e6d")
if is_plat("linux") or is_plat("macosx") then
add_syslinks("pthread")
end
if is_plat("windows") then
add_syslinks("gdi32", "msimg32", "user32")
elseif is_plat("macosx") then
add_frameworks("CoreGraphics", "CoreFoundation")
elseif is_plat("linux") then
add_syslinks("pthread")
add_frameworks("CoreGraphics", "CoreFoundation", "Foundation")
end
on_load("windows", function (package)
if not package:config("shared") then
if not package:config("shared") then
package:add("defines", "CAIRO_WIN32_STATIC_BUILD=1")
end
end)
on_install("windows", "macosx", "linux", function (package)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
os.cp(path.join(package:scriptdir(), "port", "cairo-features.h.in"), "cairo-features.h")
io.replace("cairo-features.h", "${FC_ON}", (package:is_plat("linux") and "1" or "0"), {plain = true})
import("package.tools.xmake").install(package, {kind = package:config("shared") and "shared" or "static"})
local configs = {
"-Dtests=disabled",
"-Dgtk_doc=false",
"-Dfontconfig=disabled",
"-Dgtk2-utils=disabled"}
table.insert(configs, "-Ddebug=" .. (package:debug() and "true" or "false"))
table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
io.replace("meson.build", "subdir('fuzzing')", "", {plain = true})
io.replace("meson.build", "subdir('docs')", "", {plain = true})
io.replace("meson.build", "fallback: ['fontconfig', 'fontconfig_dep'],", "", {plain = true})
io.replace("meson.build", "'CoreFoundation'", "'CoreFoundation', 'Foundation'", {plain = true})
io.replace("meson.build", "subdir('util')", "", {plain = true})
io.replace("src/meson.build", ", subdir: 'cairo'", "", {plain = true})
io.replace("util/cairo-gobject/meson.build", ", subdir: 'cairo'", "", {plain = true})
io.replace("util/cairo-script/meson.build", ", subdir: 'cairo'", "", {plain = true})
import("package.tools.meson").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("cairo_create", {includes = "cairo/cairo.h"}))
assert(package:has_cfuncs("cairo_create", {includes = "cairo.h"}))
end)

@ -51,7 +51,7 @@ package("freetype")
end)
on_install("windows", "mingw", function (package)
local configs = {}
local configs = {"-DCMAKE_INSTALL_LIBDIR=lib"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
local function add_dep(opt)

@ -3,28 +3,22 @@ package("pixman")
set_homepage("https://cairographics.org/")
set_description("Low-level library for pixel manipulation.")
set_urls("https://cairographics.org/releases/pixman-$(version).tar.gz")
add_versions("0.38.0", "a7592bef0156d7c27545487a52245669b00cf7e70054505381cff2136d890ca8")
add_versions("0.40.0", "6d200dec3740d9ec4ec8d1180e25779c00bc749f94278c8b9021f5534db223fc")
add_urls("https://gitlab.freedesktop.org/pixman/pixman/-/archive/eadb82866b0f6a326a61c36f60e5c2be8f7479af/pixman-eadb82866b0f6a326a61c36f60e5c2be8f7479af.tar.gz")
add_versions("2021.12.17", "6dba7bc2d921082aa3bb4922fd19e6ce43d2ba8990549d1ea1596bec41d4461c")
if is_plat("windows") then
add_deps("make")
else
add_deps("pkg-config")
end
add_includedirs("include/pixman-1")
add_deps("meson", "ninja")
on_install("windows", function (package)
import("core.tool.toolchain")
local runenvs = toolchain.load("msvc"):runenvs()
io.gsub("Makefile.win32.common", "%-MD", "-" .. package:config("vs_runtime"))
os.vrunv("make", {"-f", "Makefile.win32", "pixman", "MMX=off"}, {envs = runenvs})
os.cp("pixman/*.h", package:installdir("include/pixman-1"))
os.cp("pixman/release/*.lib", package:installdir("lib"))
end)
add_includedirs("include/pixman-1")
on_install("macosx", "linux", function (package)
import("package.tools.autoconf").install(package, {"--disable-dependency-tracking", "--disable-gtk", "--disable-silent-rules"})
on_install("macosx", "linux", "windows", function (package)
local configs = {
"-Dtests=disabled",
"-Dopenmp=disabled",
"-Dlibpng=disabled",
"-Dgtk=disabled"}
table.insert(configs, "-Ddebug=" .. (package:debug() and "true" or "false"))
table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
import("package.tools.meson").install(package, configs)
end)
on_test(function (package)

@ -18,8 +18,13 @@ package("pkgconf")
on_install("@windows", function(package)
import("package.tools.meson").install(package, {"-Dtests=false"})
local bindir = package:installdir("bin")
os.cp(path.join(bindir, "pkgconf.exe"), path.join(bindir, "pkg-config.exe"))
end)
on_test(function (package)
os.vrun("pkgconf --version")
if is_subhost("windows") then
os.vrun("pkg-config --version")
end
end)

Loading…
Cancel
Save