Commit be9df05d authored by Chun-wei Fan's avatar Chun-wei Fan
Browse files Improve .gir search on Windows

On Windows, we tend to look for .gir files in the $(prefix) directory
indicated by $(prefix)/bin/g-ir-scanner when running g-ir-scanner, so:

*  We add a special case for find_program() to look for g-ir-scanner on
   Windows without any executable extensions, since that is how
   g-ir-scanner is being deployed as a Python script.

*  Update default_search_paths() to first look for the presence of
   g-ir-scanner, and use its "installation prefix" to construct the
   default path where g-ir-scanner looks for the .gir files.

This way, we can make gi-docgen work better on Visual Studio builds
where Python (i.e. the official binary installers from
is generally installed seperately from the $(prefix) of our GNOME stack,
meaning that we can reduce the need to copy the dependent .gir files
from under our $(prefix).
parent faabcc2e
Pipeline #280101 passed with stage
in 2 minutes and 6 seconds
......@@ -794,7 +794,10 @@ def find_program(bin_name, path=None):
search_paths.insert(0, '')
for ext in bin_extensions:
executable = bin_name + ext
if bin_name == 'g-ir-scanner':
executable = bin_name
executable = bin_name + ext
for p in search_paths:
full_path = os.path.join(p, executable)
......@@ -818,9 +821,15 @@ def default_search_paths():
paths = []
# Add sys.base_prefix when using MSYS2
if sys.platform == 'win32' and 'GCC' in sys.version:
paths.append(os.path.join(sys.base_prefix, 'share', 'gir-1.0'))
if sys.platform == 'win32':
# Use the prefix directory of g-ir-scanner on Windows
g_ir_scanner = find_program('g-ir-scanner')
if g_ir_scanner is not None:
g_ir_scanner_prefix = os.path.dirname(os.path.dirname(g_ir_scanner))
paths.append(os.path.join(g_ir_scanner_prefix, 'share', 'gir-1.0'))
# Add sys.base_prefix when using MSYS2
if 'GCC' in sys.version:
paths.append(os.path.join(sys.base_prefix, 'share', 'gir-1.0'))
if xdg_data_home is not None:
paths.append(os.path.join(xdg_data_home, "gir-1.0"))
if xdg_data_dirs is not None:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment