aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/gobject-introspection
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/gobject-introspection
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/gobject-introspection')
-rw-r--r--vcpkg/ports/gobject-introspection/0001-g-ir-tool-template.in.patch61
-rw-r--r--vcpkg/ports/gobject-introspection/0004-fastcall.patch12
-rw-r--r--vcpkg/ports/gobject-introspection/portfile.cmake108
-rw-r--r--vcpkg/ports/gobject-introspection/vcpkg-port-config.cmake69
-rw-r--r--vcpkg/ports/gobject-introspection/vcpkg.json37
5 files changed, 287 insertions, 0 deletions
diff --git a/vcpkg/ports/gobject-introspection/0001-g-ir-tool-template.in.patch b/vcpkg/ports/gobject-introspection/0001-g-ir-tool-template.in.patch
new file mode 100644
index 0000000..617ecd7
--- /dev/null
+++ b/vcpkg/ports/gobject-introspection/0001-g-ir-tool-template.in.patch
@@ -0,0 +1,61 @@
+diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in
+index 469af0c..f165a98 100755
+--- a/tools/g-ir-tool-template.in
++++ b/tools/g-ir-tool-template.in
+@@ -1,4 +1,4 @@
+-#!@PYTHON_CMD@
++#!/usr/bin/env python3
+ # -*- Mode: Python -*-
+ # GObject-Introspection - a framework for introspecting GObject libraries
+ # Copyright (C) 2008 Johan Dahlin
+@@ -46,22 +46,20 @@ if debug:
+ filedir = os.path.dirname(__file__)
+
+ # Try using relative paths first so that the installation prefix is relocatable
+-datadir = os.path.abspath(os.path.join(filedir, '..', 'share'))
++datadir = os.path.abspath(os.path.join(filedir, '..', '..', 'share'))
+ # Fallback to hard-coded paths if the relocatable paths are wrong
++datadir = os.getenv('VCPKG_GI_DATADIR', datadir)
+ if not os.path.isdir(os.path.join(datadir, 'gir-1.0')):
+- datadir = "@datarootdir@"
++ raise Exception('Failed to determine datadir')
+
+ builtins.__dict__['DATADIR'] = datadir
+
+-gir_dir = os.path.abspath(os.path.join(filedir, '..', '@gir_dir_prefix@', 'gir-1.0'))
+-# Fallback to hard-coded paths if the relocatable paths are wrong
+-if not os.path.isdir(gir_dir):
+- gir_dir = "@GIR_DIR@"
++gir_dir = os.path.abspath(os.path.join(datadir, 'gir-1.0'))
+
+ builtins.__dict__['GIR_DIR'] = gir_dir
+
+ # Again, relative paths first so that the installation prefix is relocatable
+-pylibdir = os.path.abspath(os.path.join(filedir, '..', 'lib', 'gobject-introspection'))
++pylibdir = os.path.abspath(os.path.join(filedir, '..', '..', 'lib', 'gobject-introspection'))
+
+ # EXT_SUFFIX for py3 SO for py2
+ py_mod_suffix = sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SO')
+@@ -89,13 +87,19 @@ if not os.path.isfile(os.path.join(pylibdir, 'giscanner', '_giscanner' + py_mod_
+ gdump_path = os.path.join(builddir, 'giscanner', 'gdump.c')
+ if os.path.isfile(gdump_path):
+ builtins.__dict__['GDUMP_PATH'] = gdump_path
+ else:
+- # Okay, we're not running uninstalled and the prefix is not
+- # relocatable. Use hard-coded libdir.
+- pylibdir = os.path.join('@libdir@', 'gobject-introspection')
++ raise Exception('Could not determine pylibdir')
+
+ sys.path.insert(0, pylibdir)
+
++vcpkg_gi_lib_path = os.getenv('VCPKG_GI_LIBDIR', None)
++vcpkg_gi_lib_path_var = os.getenv('VCPKG_GI_LIBDIR_VAR', None)
++if vcpkg_gi_lib_path_var is not None and vcpkg_gi_lib_path is not None:
++ ld_lib_path = os.getenv(vcpkg_gi_lib_path_var, '')
++ if ld_lib_path != '':
++ ld_lib_path = os.pathsep + ld_lib_path
++ os.environ[vcpkg_gi_lib_path_var] = vcpkg_gi_lib_path + ld_lib_path
++
+ from giscanner.utils import dll_dirs
+ dll_dirs = dll_dirs()
+ dll_dirs.add_dll_dirs(['gio-2.0'])
diff --git a/vcpkg/ports/gobject-introspection/0004-fastcall.patch b/vcpkg/ports/gobject-introspection/0004-fastcall.patch
new file mode 100644
index 0000000..74fbbb6
--- /dev/null
+++ b/vcpkg/ports/gobject-introspection/0004-fastcall.patch
@@ -0,0 +1,12 @@
+diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
+index 38e21534edfa6c92f2ecb6c8a68b6d0360c21c64..4ca62d21f8fa8e663db152415d0ef85cfe6107f5 100644
+--- a/giscanner/scannerlexer.l
++++ b/giscanner/scannerlexer.l
+@@ -193,6 +193,7 @@ stringtext ([^\\\"])|(\\.)
+ "__declspec(deprecated(".*"))" { /* Ignore */ }
+ "__declspec"[\t ]*"("[a-z\t ]+")" { /* Ignore */ }
+ "__stdcall" { /* ignore */ }
++"__fastcall" { /* ignore */ }
+ "__w64" { /* ignore */ }
+
+ "G_GINT64_CONSTANT" { return INTL_CONST; }
diff --git a/vcpkg/ports/gobject-introspection/portfile.cmake b/vcpkg/ports/gobject-introspection/portfile.cmake
new file mode 100644
index 0000000..2bb82e9
--- /dev/null
+++ b/vcpkg/ports/gobject-introspection/portfile.cmake
@@ -0,0 +1,108 @@
+string(REGEX REPLACE "^([0-9]+[.][0-9]+).*\$" "\\1" GI_MAJOR_MINOR "${VERSION}")
+
+vcpkg_download_distfile(ARCHIVE
+ URLS "https://download.gnome.org/sources/gobject-introspection/${GI_MAJOR_MINOR}/gobject-introspection-${VERSION}.tar.xz"
+ FILENAME "gobject-introspection-${VERSION}.tar.xz"
+ SHA512 e139fadb4174c72b648914f3774d89fc0e5eaee45bba0c13edf05de883664dad8276dbc34006217bb09871ed4bad23adab51ff232a17b9eb131329b2926cafb7
+)
+
+vcpkg_extract_source_archive(
+ SOURCE_PATH
+ ARCHIVE "${ARCHIVE}"
+ PATCHES
+ 0001-g-ir-tool-template.in.patch
+ 0004-fastcall.patch # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/498
+)
+
+include("${CURRENT_PORT_DIR}/vcpkg-port-config.cmake")
+vcpkg_get_gobject_introspection_programs(PYTHON3)
+
+set(additional_binaries "")
+set(options "")
+set(options_release "")
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ message(STATUS "Static triplet. Not building introspection data.")
+ list(APPEND options_release -Dbuild_introspection_data=false)
+ vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
+endif()
+
+vcpkg_find_acquire_program(PKGCONFIG)
+vcpkg_find_acquire_program(FLEX)
+vcpkg_find_acquire_program(BISON)
+list(APPEND additional_binaries
+ "flex='${FLEX}'"
+ "bison='${BISON}'"
+)
+
+if("cairo" IN_LIST FEATURES)
+ list(APPEND options_release -Dcairo=enabled)
+else()
+ list(APPEND options_release -Dcairo=disabled)
+endif()
+
+vcpkg_configure_meson(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -Ddoctool=disabled
+ -Dgtk_doc=false
+ ${options}
+ OPTIONS_DEBUG
+ -Dbuild_introspection_data=false
+ -Dcairo=disabled
+ OPTIONS_RELEASE
+ ${options_release}
+ ADDITIONAL_BINARIES
+ "python='${PYTHON3}'"
+ ${additional_binaries}
+)
+
+set(ENV{PKG_CONFIG} "${PKGCONFIG}")
+vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}/lib/pkgconfig")
+# VCPKG_GI_... variables are used by, and scoped to, giscanner
+set(ENV{VCPKG_GI_LIBDIR} "${CURRENT_INSTALLED_DIR}/lib")
+set(ENV{VCPKG_GI_DATADIR} "${CURRENT_PACKAGES_DIR}/share")
+file(MAKE_DIRECTORY "$ENV{VCPKG_GI_DATADIR}/gir-1.0")
+if(VCPKG_TARGET_IS_WINDOWS)
+ set(ENV{VCPKG_GI_LIBDIR_VAR} "LIB")
+elseif(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
+ set(ENV{VCPKG_GI_LIBDIR_VAR} "DYLD_LIBRARY_PATH")
+else()
+ set(ENV{VCPKG_GI_LIBDIR_VAR} "LD_LIBRARY_PATH")
+endif()
+vcpkg_install_meson(ADD_BIN_TO_PATH)
+vcpkg_copy_pdbs()
+vcpkg_fixup_pkgconfig()
+
+# Cf. https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/517
+if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gir")
+ foreach(lib IN ITEMS GLib-2.0 GObject-2.0 GModule-2.0 Gio-2.0)
+ file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gir/${lib}.gir" DESTINATION "${CURRENT_PACKAGES_DIR}/share/gir-1.0")
+ file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gir/${lib}.typelib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/girepository-1.0")
+ endforeach()
+endif()
+
+file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+foreach(script IN ITEMS g-ir-annotation-tool g-ir-scanner)
+ file(RENAME "${CURRENT_PACKAGES_DIR}/bin/${script}" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/${script}")
+ file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/${script}")
+endforeach()
+vcpkg_copy_tools(TOOL_NAMES g-ir-compiler g-ir-generate g-ir-inspect AUTO_CLEAN)
+
+file(GLOB pcfiles "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/*.pc")
+foreach(file IN LISTS pcfiles)
+ vcpkg_replace_string("${file}" [[=${bindir}/g-ir-]] [[=${prefix}/tools/gobject-introspection/g-ir-]])
+endforeach()
+# No fixup for debug: Let it fail early as long as we lack debug builds for (windows) python.
+
+if(VCPKG_TARGET_IS_WINDOWS)
+ file(GLOB _pyd_lib_files "${CURRENT_PACKAGES_DIR}/lib/gobject-introspection/giscanner/_giscanner.*.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/gobject-introspection/giscanner/_giscanner.*.lib")
+ file(REMOVE ${_pyd_lib_files})
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/man")
+
+file(COPY "${CURRENT_PORT_DIR}/vcpkg-port-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
diff --git a/vcpkg/ports/gobject-introspection/vcpkg-port-config.cmake b/vcpkg/ports/gobject-introspection/vcpkg-port-config.cmake
new file mode 100644
index 0000000..57f8728
--- /dev/null
+++ b/vcpkg/ports/gobject-introspection/vcpkg-port-config.cmake
@@ -0,0 +1,69 @@
+include_guard(GLOBAL)
+
+function(z_vcpkg_get_gobject_introspection_python out_var)
+ if(VCPKG_CROSSCOMPILING)
+ message(STATUS
+ "Cross build with gobject-introspection. "
+ "Building and using ${PORT} will fail if the host cannot execute target binaries."
+ )
+ endif()
+
+ set(target_python "${CURRENT_INSTALLED_DIR}/tools/python3/python3${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
+ if(VCPKG_TARGET_IS_WINDOWS)
+ set(target_python "${CURRENT_INSTALLED_DIR}/tools/python3/python.exe")
+ endif()
+
+ # Varation of x_vcpkg_get_python_packages, but
+ # - providing the interpreter for the target
+ # - using venv also for windows
+ message(STATUS "Setting up ${TARGET_TRIPLET} python venv which provides setuptools...")
+ set(venv_path "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-gir-venv")
+ file(REMOVE_RECURSE "${venv_path}")
+ file(MAKE_DIRECTORY "${venv_path}")
+
+ set(python_sub_path /bin)
+ set(python_venv_options --symlinks)
+ if(VCPKG_TARGET_IS_WINDOWS)
+ set(python_sub_path /Scripts)
+ set(python_venv_options --copies)
+ endif()
+
+ set(ENV{PYTHONNOUSERSITE} "1")
+ vcpkg_execute_required_process(
+ COMMAND "${target_python}" -I -m venv ${python_venv_options} "${venv_path}"
+ WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}"
+ LOGNAME "venv-init-${TARGET_TRIPLET}"
+ )
+
+ set(gobject_introspection_python "${venv_path}${python_sub_path}/python${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
+ set(ENV{VIRTUAL_ENV} "${venv_path}")
+ unset(ENV{PYTHONHOME})
+ unset(ENV{PYTHONPATH})
+ vcpkg_execute_required_process(
+ COMMAND "${gobject_introspection_python}" -I -m pip install setuptools
+ WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}"
+ LOGNAME "venv-install-setuptools-${TARGET_TRIPLET}"
+ )
+
+ message(STATUS "Finished (with ${out_var} at ${gobject_introspection_python})")
+ set("${out_var}" "${gobject_introspection_python}" PARENT_SCOPE)
+endfunction()
+
+function(vcpkg_get_gobject_introspection_programs)
+ if("PYTHON3" IN_LIST ARGN)
+ z_vcpkg_get_gobject_introspection_python(PYTHON3)
+ set(PYTHON3 "${PYTHON3}" PARENT_SCOPE)
+ list(REMOVE_ITEM ARGN "PYTHON3")
+ endif()
+ if("GIR_COMPILER" IN_LIST ARGN)
+ set(GIR_COMPILER "${CURRENT_INSTALLED_DIR}/tools/gobject-introspection/g-ir-compiler${VCPKG_TARGET_EXECUTABLE_SUFFIX}" PARENT_SCOPE)
+ list(REMOVE_ITEM ARGN "GIR_COMPILER")
+ endif()
+ if("GIR_SCANNER" IN_LIST ARGN)
+ set(GIR_SCANNER "${CURRENT_INSTALLED_DIR}/tools/gobject-introspection/g-ir-scanner" PARENT_SCOPE)
+ list(REMOVE_ITEM ARGN "GIR_SCANNER")
+ endif()
+ if(NOT ARGN STREQUAL "")
+ message(FATAL_ERROR "Unsupported arguments: ${ARGN}")
+ endif()
+endfunction()
diff --git a/vcpkg/ports/gobject-introspection/vcpkg.json b/vcpkg/ports/gobject-introspection/vcpkg.json
new file mode 100644
index 0000000..8c2767a
--- /dev/null
+++ b/vcpkg/ports/gobject-introspection/vcpkg.json
@@ -0,0 +1,37 @@
+{
+ "name": "gobject-introspection",
+ "version": "1.82.0",
+ "port-version": 1,
+ "description": [
+ "A middleware layer between C libraries (using GObject) and language bindings.",
+ "Building (with) gobject-introspection is based on dynamic library linkage. Static builds of the core feature set are supported only for CI purposes.",
+ "The g-ir-scanner program runs executables for the target system. This limits actual cross-build support to targets supported by the host CPU."
+ ],
+ "homepage": "https://gi.readthedocs.io/en/latest/",
+ "license": null,
+ "supports": "!(static & staticcrt)",
+ "dependencies": [
+ "glib",
+ "libffi",
+ "python3",
+ {
+ "name": "vcpkg-tool-meson",
+ "host": true
+ }
+ ],
+ "features": {
+ "cairo": {
+ "description": "Install introspection data for cairo.",
+ "supports": "!static",
+ "dependencies": [
+ {
+ "name": "cairo",
+ "default-features": false,
+ "features": [
+ "gobject"
+ ]
+ }
+ ]
+ }
+ }
+}