summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2015-12-17 15:50:00 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2016-04-20 15:50:58 +0800
commit42a58e9cc3f7fff2b039b323a7e9a38587518033 (patch)
tree1a45a3e854d9fc25177e4b2fdf7cb8f4bdea51ca
parent09d742735dc1f62798776ce251b3861e31d77c55 (diff)
downloadlibrsvg-42a58e9cc3f7fff2b039b323a7e9a38587518033.tar.gz
MSVC builds: Add support for introspection via NMake
This adds a set of NMake Makefiles that is used to build the introspection files for librsvg, along with additions to the autotools file that uses the common autotools module to generate another NMake Makefile module that would contain the full command lines to g-ir-scanner and g-ir-compiler, which would be called by these NMake Makefiles. https://bugzilla.gnome.org/show_bug.cgi?id=765245
-rw-r--r--Makefile.am21
-rw-r--r--build/win32/Makefile.am29
-rw-r--r--build/win32/detectenv-msvc.mak76
-rw-r--r--build/win32/introspection-msvc.mak94
-rw-r--r--build/win32/rsvg-introspection-msvc.mak35
5 files changed, 255 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 657c6b29..6206c596 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -293,6 +293,27 @@ MSVCPROJ_GENERATED = \
$(top_builddir)/build/win32/vs9/rsvg.vcproj \
$(top_builddir)/build/win32/vs9/rsvg-convert.vcproj
+if HAVE_INTROSPECTION
+
+MSVC_INTROSPECT_GIRS = $(INTROSPECTION_GIRS)
+
+INTROSPECTION_INTERMEDIATE_ITEMS = \
+ $(top_builddir)/build/win32/Rsvg-@RSVG_API_VERSION@.gir.msvc.introspect \
+ $(top_builddir)/build/win32/Rsvg_@RSVG_API_VERSION_U@_gir_list
+
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_FILES = $(Rsvg_@RSVG_API_VERSION_U@_gir_FILES)
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_PACKAGES = $(Rsvg_@RSVG_API_VERSION_U@_gir_PACKAGES)
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_EXPORT_PACKAGES = $(Rsvg_@RSVG_API_VERSION_U@_gir_EXPORT_PACKAGES)
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_INCLUDE_GIRS = $(Rsvg_@RSVG_API_VERSION_U@_gir_INCLUDES)
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_LIBS = rsvg-@RSVG_API_VERSION@
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_CFLAGS = -I../.. -DRSVG_COMPILATION
+Rsvg_@RSVG_API_VERSION_U@_gir_MSVC_SCANNERFLAGS = $(Rsvg_@RSVG_API_VERSION_U@_gir_SCANNERFLAGS)
+
+MSVCPROJ_GENERATED += $(INTROSPECTION_INTERMEDIATE_ITEMS)
+
+include $(top_srcdir)/build/Makefile.msvc-introspection
+endif # HAVE_INTROSPECTION
+
$(MSVCPROJ_GENERATED): $(top_builddir)/build/win32/vs9/rsvg.headers
EXTRA_DIST += $(MSVCPROJ_GENERATED)
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index db95b529..37b1e237 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -4,3 +4,32 @@ SUBDIRS = \
vs11 \
vs12 \
vs14
+
+if HAVE_INTROSPECTION
+GENERATED_ITEMS = \
+ introspection.body.mak \
+ Rsvg_@RSVG_API_VERSION_U@_gir_list
+
+MSVC_INTROSPECTION_INTERMEDIATE_FILES = Rsvg-@RSVG_API_VERSION@.gir.msvc.introspect
+
+introspection.body.mak: $(MSVC_INTROSPECTION_INTERMEDIATE_FILES)
+ -$(RM) introspection.body.mak
+ for F in `ls *.msvc.introspect`; do \
+ case $$F in \
+ *) cat $(top_builddir)/build/win32/$$F >>introspection.body.mak \
+ ;; \
+ esac; \
+ done
+ $(RM) $(MSVC_INTROSPECTION_INTERMEDIATE_FILES)
+
+DISTCLEANFILES = $(GENERATED_ITEMS)
+
+else
+GENERATED_ITEMS =
+endif
+
+EXTRA_DIST = \
+ rsvg-introspection-msvc.mak \
+ introspection-msvc.mak \
+ detectenv-msvc.mak \
+ $(GENERATED_ITEMS)
diff --git a/build/win32/detectenv-msvc.mak b/build/win32/detectenv-msvc.mak
new file mode 100644
index 00000000..61f979d4
--- /dev/null
+++ b/build/win32/detectenv-msvc.mak
@@ -0,0 +1,76 @@
+# Common NMake Makefile module for checking the build environment
+# This can be copied from $(glib_srcroot)\build\win32 for GNOME items
+# that support MSVC builds and introspection under MSVC, and can be used
+# for building test programs as well.
+
+# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
+# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
+!if !defined(VCINSTALLDIR) && !defined(WINDOWSSDKDIR)
+MSG = ^
+This Makefile is only for Visual Studio 2008 and later.^
+You need to ensure that the Visual Studio Environment is properly set up^
+before running this Makefile.
+!error $(MSG)
+!endif
+
+ERRNUL = 2>NUL
+_HASH=^#
+
+!if ![echo VCVERSION=_MSC_VER > vercl.x] \
+ && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
+ && ![echo PLAT=Win32 >> vercl.x] \
+ && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
+ && ![echo PLAT=x64 >> vercl.x] \
+ && ![echo $(_HASH)endif >> vercl.x] \
+ && ![cl -nologo -TC -P vercl.x $(ERRNUL)]
+!include vercl.i
+!if ![echo VCVER= ^\> vercl.vc] \
+ && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
+!include vercl.vc
+!endif
+!endif
+!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc]
+!endif
+
+!if $(VCVERSION) > 1499 && $(VCVERSION) < 1600
+VSVER = 9
+!elseif $(VCVERSION) > 1599 && $(VCVERSION) < 1700
+VSVER = 10
+!elseif $(VCVERSION) > 1699 && $(VCVERSION) < 1800
+VSVER = 11
+!elseif $(VCVERSION) > 1799 && $(VCVERSION) < 1900
+VSVER = 12
+!elseif $(VCVERSION) > 1899 && $(VCVERSION) < 2000
+VSVER = 14
+!else
+VSVER = 0
+!endif
+
+!if "$(VSVER)" == "0"
+MSG = ^
+This NMake Makefile set supports Visual Studio^
+9 (2008) through 14 (2015). Your Visual Studio^
+version is not supported.
+!error $(MSG)
+!endif
+
+VALID_CFGSET = FALSE
+!if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
+VALID_CFGSET = TRUE
+!endif
+
+# We want debugging symbols logged for all builds,
+# using .pdb files for release builds
+CFLAGS_BASE = /Zi
+
+!if "$(CFG)" == "release" || "$(CFG)" == "Release"
+CFLAGS_ADD = /MD /O2 $(CFLAGS_BASE)
+!else
+CFLAGS_ADD = /MDd /Od $(CFLAGS_BASE)
+!endif
+
+!if "$(PLAT)" == "x64"
+LDFLAGS_ARCH = /machine:x64
+!else
+LDFLAGS_ARCH = /machine:x86
+!endif
diff --git a/build/win32/introspection-msvc.mak b/build/win32/introspection-msvc.mak
new file mode 100644
index 00000000..87398442
--- /dev/null
+++ b/build/win32/introspection-msvc.mak
@@ -0,0 +1,94 @@
+# Common NMake Makefile module for checking the build environment is sane
+# for building introspection files under MSVC/NMake.
+# This can be copied from $(gi_srcroot)\build\win32 for GNOME items
+# that support MSVC builds and introspection under MSVC.
+
+# Can override with env vars as needed
+# You will need to have built gobject-introspection for this to work.
+# Change or pass in or set the following to suit your environment
+
+!if "$(PREFIX)" == ""
+PREFIX = ..\..\..\vs$(VSVER)\$(PLAT)
+!endif
+
+!if ![setlocal] && \
+ ![set PFX=$(PREFIX)] && \
+ ![for %P in (%PFX%) do @echo PREFIX_FULL=%~dpnfP > pfx.x]
+!endif
+!include pfx.x
+
+!if "$(PKG_CONFIG_PATH)" == ""
+PKG_CONFIG_PATH=$(PREFIX_FULL)\lib\pkgconfig
+!else
+PKG_CONFIG_PATH=$(PREFIX_FULL)\lib\pkgconfig;$(PKG_CONFIG_PATH)
+!endif
+
+!if ![del $(ERRNUL) /q/f pfx.x]
+!endif
+
+# Note: The PYTHON must be the Python release series that was used to build
+# the GObject-introspection scanner Python module!
+# Either having python.exe your PATH will work or passing in
+# PYTHON=<full path to your Python interpretor> will do
+
+# This is required, and gobject-introspection needs to be built
+# before this can be successfully run.
+!if "$(PYTHON)" == ""
+PYTHON=python
+!endif
+
+# Path to the pkg-config tool, if not already in the PATH
+!if "$(PKG_CONFIG)" == ""
+PKG_CONFIG=pkg-config
+!endif
+
+# Don't change anything following this line!
+
+GIR_SUBDIR = share\gir-1.0
+GIR_TYPELIBDIR = lib\girepository-1.0
+G_IR_SCANNER = $(PREFIX)\bin\g-ir-scanner
+G_IR_COMPILER = $(PREFIX)\bin\g-ir-compiler.exe
+G_IR_INCLUDEDIR = $(PREFIX)\$(GIR_SUBDIR)
+G_IR_TYPELIBDIR = $(PREFIX)\$(GIR_TYPELIBDIR)
+
+VALID_PKG_CONFIG_PATH = FALSE
+
+MSG_INVALID_PKGCONFIG = You must set or specifiy a valid PKG_CONFIG_PATH
+MSG_INVALID_CFG = You need to specify or set CFG to be release or debug to use this Makefile to build the Introspection Files
+
+ERROR_MSG =
+
+BUILD_INTROSPECTION = TRUE
+
+!if ![set PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)] \
+ && ![$(PKG_CONFIG) --print-errors --errors-to-stdout $(CHECK_PACKAGE) > pkgconfig.x] \
+ && ![setlocal] \
+ && ![set file="pkgconfig.x"] \
+ && ![FOR %A IN (%file%) DO @echo PKG_CHECK_SIZE=%~zA > pkgconfig.chksize] \
+ && ![del $(ERRNUL) /q/f pkgconfig.x]
+!endif
+
+!include pkgconfig.chksize
+!if "$(PKG_CHECK_SIZE)" == "0"
+VALID_PKG_CONFIG_PATH = TRUE
+!else
+VALID_PKG_CONFIG_PATH = FALSE
+!endif
+
+!if ![del $(ERRNUL) /q/f pkgconfig.chksize]
+!endif
+
+VALID_CFGSET = FALSE
+!if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
+VALID_CFGSET = TRUE
+!endif
+
+!if "$(VALID_PKG_CONFIG_PATH)" != "TRUE"
+BUILD_INTROSPECTION = FALSE
+ERROR_MSG = $(MSG_INVALID_PKGCONFIG)
+!endif
+
+!if "$(VALID_CFGSET)" != "TRUE"
+BUILD_INTROSPECTION = FALSE
+ERROR_MSG = $(MSG_INVALID_CFG)
+!endif
diff --git a/build/win32/rsvg-introspection-msvc.mak b/build/win32/rsvg-introspection-msvc.mak
new file mode 100644
index 00000000..1083f3d2
--- /dev/null
+++ b/build/win32/rsvg-introspection-msvc.mak
@@ -0,0 +1,35 @@
+# NMake Makefile to build Introspection Files for GDK-Pixbuf
+
+!include detectenv-msvc.mak
+
+APIVERSION = 2.0
+
+CHECK_PACKAGE = gdk-pixbuf-2.0
+
+!include introspection-msvc.mak
+
+!if "$(BUILD_INTROSPECTION)" == "TRUE"
+all: setgirbuildenv Rsvg-$(APIVERSION).gir Rsvg-$(APIVERSION).typelib
+
+setgirbuildenv:
+ @-set PYTHONPATH=$(PREFIX)\lib\gobject-introspection
+ @-set PATH=vs$(VSVER)\$(CFG)\$(PLAT)\bin;$(PREFIX)\bin;$(PATH)
+ @-set PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)
+ @-set LIB=vs$(VSVER)\$(CFG)\$(PLAT)\bin;$(LIB)
+
+!include introspection.body.mak
+
+install-introspection: all
+ @-copy Rsvg-$(APIVERSION).gir $(G_IR_INCLUDEDIR)
+ @-copy /b Rsvg-$(APIVERSION).typelib $(G_IR_TYPELIBDIR)
+
+!else
+all:
+ @-echo $(ERROR_MSG)
+
+install-introspection: all
+!endif
+
+clean:
+ @-del /f/q Rsvg-$(APIVERSION).typelib
+ @-del /f/q Rsvg-$(APIVERSION).gir