[gi-docgen/msvc] utils.py: Improve .gir search on Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/msvc] utils.py: Improve .gir search on Windows
- Date: Wed, 5 May 2021 02:56:22 +0000 (UTC)
commit be9df05db1488ab081e20933e153e47d50f8214b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed May 5 10:46:13 2021 +0800
utils.py: 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 www.python.org)
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).
gidocgen/utils.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gidocgen/utils.py b/gidocgen/utils.py
index 655ea7a..d781900 100644
--- a/gidocgen/utils.py
+++ b/gidocgen/utils.py
@@ -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
+ else:
+ 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 = []
paths.append(os.getcwd())
- # 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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]