[librsvg/git-msvc] Visual Studio: Support building from GIT checkout




commit 1adad27f07070cc3742a8b39c096bc7342ad4ccd
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jan 10 18:48:25 2022 +0800

    Visual Studio: Support building from GIT checkout
    
    Add rules in win32/generate-msvc.mak to create win32/config-msvc.mak,
    win32/config.h.win32 and include/librsvg/rsvg-version.h so that we can
    support building from a GIT checkout using Visual Studio 2013+ without
    manually editing the *.in files for the build.  Add also a rule to
    remove the generated files and clean up the vsXX build directories.
    These rules are meant for GIT checkouts only and are not meant for
    release tarballs, at least for now.
    
    The newly-added win32/prebuild.py is not meant to be distributed, so it
    is not added to 'make dist'.

 win32/generate-msvc.mak | 16 ++++++++++++++
 win32/prebuild.py       | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
---
diff --git a/win32/generate-msvc.mak b/win32/generate-msvc.mak
index 2acbd65a1..6af43531f 100644
--- a/win32/generate-msvc.mak
+++ b/win32/generate-msvc.mak
@@ -18,3 +18,19 @@ $(OUTDIR)\librsvg\librsvg.def: .\librsvg.symbols
 $(OUTDIR)\librsvg\Rsvg_2_0_gir_list: $(librsvg_real_pub_HDRS)
        @if exist $@ del $@
        @for %%s in ($**) do echo %%s >> $@
+
+# Generate NMake Makefiles (for git checkouts only)
+
+config.h.win32: ..\.git ..\configure.ac prebuild.py config.h.win32.in
+config-msvc.mak: ..\.git ..\configure.ac prebuild.py config-msvc.mak.in
+..\include\librsvg\rsvg-version.h: ..\.git ..\configure.ac prebuild.py ..\include\librsvg\rsvg-version.h.in
+
+generate-nmake-files: config.h.win32 config-msvc.mak ..\include\librsvg\rsvg-version.h
+       @if not "$(PYTHON)" == "" $(PYTHON) prebuild.py
+       @if "$(PYTHON)" == "" echo You need to specify your Python interpreter PATH by passing in 
PYTHON^=^<full_path_to_python_interpreter^>
+
+remove-generated-nmake-files: ..\.git
+       @-del /f/q config-msvc.mak
+       @-del /f/q config.h.win32
+       @-del /f/q ..\include\librsvg\rsvg-version.h
+       @-for /f %%d in ('dir /ad /b vs*') do @rmdir /s/q %%d
diff --git a/win32/prebuild.py b/win32/prebuild.py
new file mode 100644
index 000000000..cb47ae6f4
--- /dev/null
+++ b/win32/prebuild.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+# vim: encoding=utf-8
+#expand *.in files
+#this script is only intended for building from git, not for building from the released tarball, which 
already includes all necessary files
+import os
+import sys
+import re
+import string
+import subprocess
+import optparse
+
+def get_version(srcroot):
+    ver = {}
+    RE_VERSION = re.compile(r'^m4_define\(\[(rsvg_\w+)\],\s*\[(\d+)\]\)')
+    with open(os.path.join(srcroot, 'configure.ac'), 'r') as ac:
+        for i in ac:
+            mo = RE_VERSION.search(i)
+            if mo:
+                ver[mo.group(1).upper()] = int(mo.group(2))
+    ver['LIBRSVG_MAJOR_VERSION'] = ver['RSVG_MAJOR_VERSION']
+    ver['LIBRSVG_MINOR_VERSION'] = ver['RSVG_MINOR_VERSION']
+    ver['LIBRSVG_MICRO_VERSION'] = ver['RSVG_MICRO_VERSION']
+    ver['PACKAGE_VERSION'] = '%d.%d.%d' % (ver['LIBRSVG_MAJOR_VERSION'],
+                                           ver['LIBRSVG_MINOR_VERSION'],
+                                           ver['LIBRSVG_MICRO_VERSION'])
+    ver['PACKAGE'] = 'librsvg'
+    ver['PACKAGE_NAME'] = ver['PACKAGE']
+    ver['PACKAGE_TARNAME'] = ver['PACKAGE']
+    ver['GETTEXT_PACKAGE'] = ver['PACKAGE']
+    ver['PACKAGE_BUGREPORT'] = 'https://gitlab.gnome.org/GNOME/librsvg/issues'
+    return ver
+
+def process_in(src, dest, vars):
+    RE_VARS = re.compile(r'@(\w+?)@')
+    with open(src, 'r') as s:
+        with open(dest, 'w') as d:
+            for i in s:
+                i = RE_VARS.sub(lambda x: str(vars[x.group(1)]), i)
+                d.write(i)
+
+def get_srcroot():
+    if not os.path.isabs(__file__):
+        path = os.path.abspath(__file__)
+    else:
+        path = __file__
+    dirname = os.path.dirname(path)
+    return os.path.abspath(os.path.join(dirname, '..'))
+
+def main(argv):
+    srcroot = get_srcroot()
+    ver = get_version(srcroot)
+    process_in('config.h.win32.in', 'config.h.win32', ver.copy())
+    process_in('config-msvc.mak.in', 'config-msvc.mak', ver.copy())
+    process_in(os.path.join(srcroot, 'include', 'librsvg', 'rsvg-version.h.in'),
+               os.path.join(srcroot, 'include', 'librsvg', 'rsvg-version.h'),
+               ver.copy())
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]