mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
ef73ce4f7f
Since we are now building introspection files for GLib while building GLib, so we want to make sure that we indeed load the freshly-built DLLs when running g-ir-scanner, so we add the various needed subdirs (and if needed, subprojects), to set the GI_EXTRA_BASE_DLL_DIRS envvar so that g-ir-scanner will look for the newly-built GLib DLLs. Ideally, upstream g-ir-scanner will need to be updated accordingly to do something similar to what we are doing here, but this is needed until the time that we require a g-ir-scanner that contains the update. This will also fix the g-ir-scanner erroring out when there is no pre-existing GLib on the system, as the needed DLLs are now found. Related issue: https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/499 Related MR in G-I: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/458
69 lines
2.1 KiB
Python
69 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# Copyright © 2024 Chun-wei Fan.
|
|
#
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
#
|
|
# Original author: Chun-wei Fan <fanc999@yahoo.com.tw>
|
|
|
|
"""
|
|
This script runs pkg-config against the uninstalled pkg-config files to obtain the
|
|
paths where the newly-built GLib and subproject DLLs reside
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--build-path", required=True, help="Root build directory")
|
|
parser.add_argument(
|
|
"--pkg-config", help="pkg-config or compatible executable", default="pkg-config"
|
|
)
|
|
parser.add_argument(
|
|
"--pkg-config-path",
|
|
help="Additional paths to look for pkg-config .pc files",
|
|
)
|
|
args = parser.parse_args()
|
|
build_path = args.build_path
|
|
uninstalled_pc_path = os.path.join(build_path, "meson-uninstalled")
|
|
if not os.path.isdir(uninstalled_pc_path):
|
|
raise ValueError("%s is not a valid build path" % build_path)
|
|
|
|
additional_pkg_config_paths = [uninstalled_pc_path]
|
|
if args.pkg_config_path is not None:
|
|
additional_pkg_config_paths += args.pkg_config_path.split(os.pathsep)
|
|
|
|
if "PKG_CONFIG_PATH" in os.environ:
|
|
additional_pkg_config_paths += os.environ["PKG_CONFIG_PATH"].split(os.pathsep)
|
|
|
|
os.environ["PKG_CONFIG_PATH"] = os.pathsep.join(additional_pkg_config_paths)
|
|
|
|
# The _giscanner Python module depends on GIO, so use gio-2.0-uninstalled.pc
|
|
pkg_config_result = subprocess.run(
|
|
[args.pkg_config, "--libs-only-L", "gio-2.0"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
lib_args = pkg_config_result.stdout.split()
|
|
libpaths = []
|
|
for arg in lib_args:
|
|
# Get rid of the "-L" prefix in the library paths
|
|
if arg[2:] not in libpaths:
|
|
libpaths.append(arg[2:])
|
|
|
|
# Now append the paths in %PATH%, if the paths exist
|
|
paths = os.environ["PATH"].split(os.pathsep)
|
|
for path in paths:
|
|
if os.path.isdir(path):
|
|
libpaths.append(path)
|
|
|
|
print(os.pathsep.join(libpaths).rstrip())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|