[libsoup] build: Support introspection for MSVC builds
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] build: Support introspection for MSVC builds
- Date: Mon, 22 Feb 2016 08:09:09 +0000 (UTC)
commit 46d83dce5779ee51b8c3b0eb09e47e95c8e80a63
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Nov 27 19:31:55 2015 +0800
build: Support introspection for MSVC builds
This makes use of the common autotools module to generate the necessary bits
for NMake to run g-ir-scanner and g-ir-compiler to build the introspection
files for libsoup and libsoup-gnome.
https://bugzilla.gnome.org/show_bug.cgi?id=758759
build/win32/Makefile.am | 31 +++++++++++++-
build/win32/detectenv-msvc.mak | 67 +++++++++++++++++++++++++++++
build/win32/introspection-msvc.mak | 71 +++++++++++++++++++++++++++++++
build/win32/soup-introspection-msvc.mak | 37 ++++++++++++++++
libsoup/Makefile.am | 63 ++++++++++++++++++++++++----
5 files changed, 260 insertions(+), 9 deletions(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index 3440704..f71fcb3 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -1,3 +1,32 @@
SUBDIRS = vs9 vs10 vs11 vs12 vs14
-EXTRA_DIST = replace.py
+if HAVE_INTROSPECTION
+GENERATED_ITEMS = \
+ introspection.body.mak \
+ Soup_2_4_gir_list \
+ SoupGNOME_2_4_gir_list
+
+MSVC_INTROSPECTION_INTERMEDIATE_FILES = Soup-2.4.gir.msvc.introspect SoupGNOME-2.4.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 = \
+ replace.py \
+ detectenv-msvc.mak \
+ introspection-msvc.mak \
+ soup-introspection-msvc.mak \
+ $(GENERATED_ITEMS)
diff --git a/build/win32/detectenv-msvc.mak b/build/win32/detectenv-msvc.mak
new file mode 100644
index 0000000..7a29ba4
--- /dev/null
+++ b/build/win32/detectenv-msvc.mak
@@ -0,0 +1,67 @@
+# 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"
+VALID_CFGSET = TRUE
+!endif
+
+!if "$(CFG)" == "release"
+CFLAGS_ADD = /MD /O2
+!else
+CFLAGS_ADD = /MDd /Od /Zi
+!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 0000000..121b7fd
--- /dev/null
+++ b/build/win32/introspection-msvc.mak
@@ -0,0 +1,71 @@
+# Common Utility NMake Makefile Template
+# Used to Generate Introspection files for various Projects
+
+# 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 "$(BASEDIR)" == ""
+BASEDIR = ..\..\..\vs$(VSVER)\$(PLAT)
+!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
+
+# Don't change anything following this line!
+
+GIR_SUBDIR = share\gir-1.0
+GIR_TYPELIBDIR = lib\girepository-1.0
+G_IR_SCANNER = $(BASEDIR)\bin\g-ir-scanner
+G_IR_COMPILER = $(BASEDIR)\bin\g-ir-compiler.exe
+G_IR_INCLUDEDIR = $(BASEDIR)\$(GIR_SUBDIR)
+G_IR_TYPELIBDIR = $(BASEDIR)\$(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 ![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"
+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/soup-introspection-msvc.mak b/build/win32/soup-introspection-msvc.mak
new file mode 100644
index 0000000..d2fa8f2
--- /dev/null
+++ b/build/win32/soup-introspection-msvc.mak
@@ -0,0 +1,37 @@
+# NMake Makefile to build Introspection Files for Pango
+
+!include detectenv-msvc.mak
+
+APIVERSION = 2.4
+
+CHECK_PACKAGE = gio-2.0
+
+!include introspection-msvc.mak
+
+!if "$(BUILD_INTROSPECTION)" == "TRUE"
+
+INTROSPECTION_TARGETS = Soup-$(APIVERSION).gir Soup-$(APIVERSION).typelib SoupGNOME-$(APIVERSION).gir
SoupGNOME-$(APIVERSION).typelib
+
+all: setbuildenv $(INTROSPECTION_TARGETS)
+
+install-introspection: all
+ @-copy Soup-$(APIVERSION).gir $(G_IR_INCLUDEDIR)
+ @-copy /b Soup-$(APIVERSION).typelib $(G_IR_TYPELIBDIR)
+ @-copy SoupGNOME-$(APIVERSION).gir $(G_IR_INCLUDEDIR)
+ @-copy /b SoupGNOME-$(APIVERSION).typelib $(G_IR_TYPELIBDIR)
+
+setbuildenv:
+ @set PYTHONPATH=$(BASEDIR)\lib\gobject-introspection
+ @set PATH=vs$(VSVER)\$(CFG)\$(PLAT)\bin;$(BASEDIR)\bin;$(PATH)
+ @set PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)
+ @set LIB=vs$(VSVER)\$(CFG)\$(PLAT)\bin;$(BASEDIR)\lib;$(LIB)
+
+!include introspection.body.mak
+
+!else
+all:
+ @-echo $(ERROR_MSG)
+!endif
+
+clean:
+ @-del /f/q $(INTROSPECTION_TARGETS)
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index cde277f..19a77c7 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -10,9 +10,12 @@ if OS_WIN32
LIBWS2_32 = -lws2_32
endif
+SOUP_COMMON_CPPFLAGS = \
+ -DG_LOG_DOMAIN=\"libsoup\" \
+ -DLIBSOUP_COMPILATION
+
AM_CPPFLAGS = \
- -DG_LOG_DOMAIN=\"libsoup\" \
- -DLIBSOUP_COMPILATION \
+ $(SOUP_COMMON_CPPFLAGS) \
-DLOCALEDIR=\"$(localedir)\" \
-I$(top_srcdir) \
-I$(top_builddir) \
@@ -261,6 +264,8 @@ INTROSPECTION_COMPILER_ARGS = --includedir=.
if HAVE_INTROSPECTION
+SOUP_UNSTABLE_REQUEST_CFLAG = -DLIBSOUP_USE_UNSTABLE_REQUEST_API
+
# Core library
gi_soup_files = \
$(filter-out soup.h soup-enum-types.% soup-proxy-resolver.h,\
@@ -269,7 +274,7 @@ gi_built_soup_files = soup-enum-types.h
Soup-2.4.gir: libsoup-2.4.la
Soup_2_4_gir_INCLUDES = Gio-2.0
-Soup_2_4_gir_CFLAGS = $(AM_CPPFLAGS) -DLIBSOUP_USE_UNSTABLE_REQUEST_API
+Soup_2_4_gir_CFLAGS = $(AM_CPPFLAGS) $(SOUP_UNSTABLE_REQUEST_CFLAG)
Soup_2_4_gir_LIBS = libsoup-2.4.la
Soup_2_4_gir_EXPORT_PACKAGES = libsoup-2.4
Soup_2_4_gir_SCANNERFLAGS = --c-include "libsoup/soup.h"
@@ -295,14 +300,17 @@ EXTRA_DIST += Soup-2.4.metadata Soup-2.4-custom.vala libsoup-2.4.deps
if BUILD_LIBSOUP_GNOME
+SOUPGNOME_GIR_SCANNER_BASE_FLAGS = \
+ --identifier-prefix=Soup \
+ --symbol-prefix=soup
+
# GNOME extensions
gi_soup_gnome_files = $(filter-out soup-gnome.h,\
$(libsoupgnomeinclude_HEADERS) \
$(filter-out %.h, $(libsoup_gnome_2_4_la_SOURCES)))
SoupGNOME-2.4.gir: libsoup-gnome-2.4.la Soup-2.4.gir
SoupGNOME_2_4_gir_SCANNERFLAGS = \
- --identifier-prefix=Soup \
- --symbol-prefix=soup \
+ $(SOUPGNOME_GIR_SCANNER_BASE_FLAGS) \
--c-include "libsoup/soup-gnome.h" \
--include-uninstalled=$(builddir)/Soup-2.4.gir
SoupGNOME_2_4_gir_CFLAGS = $(AM_CPPFLAGS)
@@ -343,8 +351,47 @@ soup_gnome_HEADERS_EXCLUDES = dummy
include $(top_srcdir)/build/Makefile.msvcproj
+if HAVE_INTROSPECTION
+# Introspection Items for MSVC
+MSVC_INTROSPECT_GIRS = Soup-2.4.gir SoupGNOME-2.4.gir
+
+BASE_MSVC_GIR_CFLAGS = \
+ $(SOUP_COMMON_CPPFLAGS) \
+ -I../..
+
+INTROSPECTION_INTERMEDIATE_ITEMS = \
+ $(top_builddir)/build/win32/Soup-2.4.gir.msvc.introspect \
+ $(top_builddir)/build/win32/Soup_2_4_gir_list \
+ $(top_builddir)/build/win32/SoupGNOME-2.4.gir.msvc.introspect \
+ $(top_builddir)/build/win32/SoupGNOME_2_4_gir_list
+
+# libsoup
+Soup_2_4_gir_MSVC_FILES = $(gi_soup_files) $(gi_built_soup_files)
+Soup_2_4_gir_MSVC_EXPORT_PACKAGES = $(Soup_2_4_gir_EXPORT_PACKAGES)
+Soup_2_4_gir_MSVC_INCLUDE_GIRS = $(Soup_2_4_gir_INCLUDES)
+Soup_2_4_gir_MSVC_LIBS = soup-2.4
+Soup_2_4_gir_MSVC_CFLAGS = $(BASE_MSVC_GIR_CFLAGS) $(SOUP_UNSTABLE_REQUEST_CFLAG)
+Soup_2_4_gir_MSVC_SCANNERFLAGS = --c-include \"libsoup/soup.h\"
+
+# libsoup-gnome
+SoupGNOME_2_4_gir_MSVC_FILES = $(gi_soup_gnome_files)
+SoupGNOME_2_4_gir_MSVC_GIR_DEPS = Soup-2.4.gir
+SoupGNOME_2_4_gir_MSVC_EXPORT_PACKAGES = $(SoupGNOME_2_4_gir_EXPORT_PACKAGES)
+SoupGNOME_2_4_gir_MSVC_LIBS = soup-gnome-2.4 soup-2.4
+SoupGNOME_2_4_gir_MSVC_CFLAGS = $(BASE_MSVC_GIR_CFLAGS)
+SoupGNOME_2_4_gir_MSVC_SCANNERFLAGS = i \
+ $(SOUPGNOME_GIR_SCANNER_BASE_FLAGS) \
+ --c-include \"libsoup/soup-gnome.h\" \
+ --include-uninstalled=./Soup-2.4.gir
+
+include $(top_srcdir)/build/Makefile.msvc-introspection
+else
+INTROSPECTION_INTERMEDIATE_ITEMS =
+endif
+
dist-hook: \
- $(top_builddir)/build/win32/vs9/soup.vcproj \
- $(top_builddir)/build/win32/vs9/soup.headers \
+ $(top_builddir)/build/win32/vs9/soup.vcproj \
+ $(top_builddir)/build/win32/vs9/soup.headers \
$(top_builddir)/build/win32/vs9/soup-gnome.vcproj \
- $(top_builddir)/build/win32/vs9/soup-gnome.headers
+ $(top_builddir)/build/win32/vs9/soup-gnome.headers \
+ $(INTROSPECTION_INTERMEDIATE_ITEMS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]