[json-glib] MSVC builds: Improve introspection builds on MSVC
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib] MSVC builds: Improve introspection builds on MSVC
- Date: Fri, 22 Apr 2016 11:46:11 +0000 (UTC)
commit 3a91387198ad5474f5b1af5744fb7496584769b6
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jan 4 14:26:49 2016 +0800
MSVC builds: Improve introspection builds on MSVC
This changes the introspection build process on MSVC by moving the
source/header list generation from using a Python script to generating
the list (and the full command lines for g-ir-scanner and g-ir-compiler)
using the common autotools module, to make it more easily maintained.
build/win32/Makefile.am | 34 +++++--
.../{detectenv_msvc.mak => detectenv-msvc.mak} | 21 +++-
build/win32/gen-file-list-jsonglib.py | 115 --------------------
build/win32/introspection-msvc.mak | 79 ++++++++------
build/win32/json-glib-introspection-msvc.mak | 40 ++------
json-glib/Makefile.am | 26 ++++-
6 files changed, 121 insertions(+), 194 deletions(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index 813b9fb..ae561b3 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -1,9 +1,29 @@
SUBDIRS = vs9 vs10 vs11 vs12 vs14
-EXTRA_DIST = \
- config.h.win32.in \
- config.h.win32 \
- gen-file-list-jsonglib.py \
- detectenv_msvc.mak \
- introspection-msvc.mak \
- json-glib-introspection-msvc.mak
+if HAVE_INTROSPECTION
+GENERATED_ITEMS = \
+ introspection.body.mak \
+ Json_1_0_gir_list
+
+introspection.body.mak: Json-1.0.gir.msvc.introspect
+ -$(RM) introspection.body.mak
+ for F in `ls *.msvc.introspect`; do \
+ case $$F in \
+ *) cat $(top_builddir)/build/win32/$$F >>$@ \
+ ;; \
+ esac; \
+ done
+ $(RM) Json-1.0.gir.msvc.introspect
+else
+GENERATED_ITEMS =
+endif
+
+EXTRA_DIST = \
+ config.h.win32.in \
+ config.h.win32 \
+ detectenv-msvc.mak \
+ introspection-msvc.mak \
+ json-glib-introspection-msvc.mak \
+ $(GENERATED_ITEMS)
+
+DISTCLEANFILES = $(GENERATED_ITEMS)
diff --git a/build/win32/detectenv_msvc.mak b/build/win32/detectenv-msvc.mak
similarity index 68%
rename from build/win32/detectenv_msvc.mak
rename to build/win32/detectenv-msvc.mak
index 020548a..61f979d 100644
--- a/build/win32/detectenv_msvc.mak
+++ b/build/win32/detectenv-msvc.mak
@@ -1,3 +1,8 @@
+# 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)
@@ -35,6 +40,8 @@ VSVER = 10
VSVER = 11
!elseif $(VCVERSION) > 1799 && $(VCVERSION) < 1900
VSVER = 12
+!elseif $(VCVERSION) > 1899 && $(VCVERSION) < 2000
+VSVER = 14
!else
VSVER = 0
!endif
@@ -42,20 +49,24 @@ VSVER = 0
!if "$(VSVER)" == "0"
MSG = ^
This NMake Makefile set supports Visual Studio^
-9 (2008) through 12 (2013). Your 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"
+!if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
VALID_CFGSET = TRUE
!endif
-!if "$(CFG)" == "release"
-CFLAGS_ADD = /MD /O2
+# 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 /Zi
+CFLAGS_ADD = /MDd /Od $(CFLAGS_BASE)
!endif
!if "$(PLAT)" == "x64"
diff --git a/build/win32/introspection-msvc.mak b/build/win32/introspection-msvc.mak
index d637cc7..8739844 100644
--- a/build/win32/introspection-msvc.mak
+++ b/build/win32/introspection-msvc.mak
@@ -1,39 +1,67 @@
-# Common Utility NMake Makefile Template
-# Used to Generate Introspection files for various Projects
+# 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
+# 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
-BASEDIR = ..\..\..\vs$(VSVER)\$(PLAT)
-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)
+!if "$(PREFIX)" == ""
+PREFIX = ..\..\..\vs$(VSVER)\$(PLAT)
+!endif
-# Note: The PYTHON2 must be a Python 2.6.x or 2.7.x Interpretor!
-# Either having python.exe from Python 2.6.x/2.7.x in your PATH will work
-# or passing in PYTHON2=<full path to your Python 2.6.x/2.7.x interpretor> will do
+!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.
-PYTHON2=python
+!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
-VALID_GCC_INSTPATH = FALSE
MSG_INVALID_PKGCONFIG = You must set or specifiy a valid PKG_CONFIG_PATH
-MSG_INVALID_MINGWDIR = You must set or specifiy a valid MINGWDIR, where gcc.exe can be found in
%MINGWDIR%\bin
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] \
+!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] \
@@ -47,27 +75,14 @@ VALID_PKG_CONFIG_PATH = TRUE
VALID_PKG_CONFIG_PATH = FALSE
!endif
-!if ![IF EXIST %MINGWDIR%\bin\gcc.exe @echo VALID_GCC_INSTPATH=TRUE > gcccheck.x]
-!endif
-
-!if ![IF NOT EXIST %MINGWDIR%\bin\gcc.exe @echo VALID_GCC_INSTPATH=FALSE > gcccheck.x]
-!endif
-
-!include gcccheck.x
-
-!if ![del $(ERRNUL) /q/f pkgconfig.chksize gcccheck.x]
+!if ![del $(ERRNUL) /q/f pkgconfig.chksize]
!endif
VALID_CFGSET = FALSE
-!if "$(CFG)" == "release" || "$(CFG)" == "debug"
+!if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
VALID_CFGSET = TRUE
!endif
-!if "$(VALID_GCC_INSTPATH)" != "TRUE"
-BUILD_INTROSPECTION = FALSE
-ERROR_MSG = $(MSG_INVALID_MINGWDIR)
-!endif
-
!if "$(VALID_PKG_CONFIG_PATH)" != "TRUE"
BUILD_INTROSPECTION = FALSE
ERROR_MSG = $(MSG_INVALID_PKGCONFIG)
diff --git a/build/win32/json-glib-introspection-msvc.mak b/build/win32/json-glib-introspection-msvc.mak
index 9089e28..6511033 100644
--- a/build/win32/json-glib-introspection-msvc.mak
+++ b/build/win32/json-glib-introspection-msvc.mak
@@ -1,6 +1,6 @@
# NMake Makefile to build Introspection Files for JSON-GLib
-!include detectenv_msvc.mak
+!include detectenv-msvc.mak
APIVERSION = 1.0
@@ -11,38 +11,15 @@ CHECK_PACKAGE = gio-2.0
!if "$(BUILD_INTROSPECTION)" == "TRUE"
all: setgirbuildnev Json-$(APIVERSION).gir Json-$(APIVERSION).typelib
-json_list:
- @-echo Generating Filelist to Introspect for JSON-GLib...
- $(PYTHON2) gen-file-list-jsonglib.py
-
-vs$(VSVER)\$(CFG)\$(PLAT)\bin\Json-$(APIVERSION).lib:
- @-echo Copying Json-1.0.lib from json-glib-1.0.lib
- @-copy /b vs$(VSVER)\$(CFG)\$(PLAT)\bin\json-glib-$(APIVERSION).lib
vs$(VSVER)\$(CFG)\$(PLAT)\bin\Json-$(APIVERSION).lib
-
-setgirbuildnev:
- @set CC=$(CC)
- @set PYTHONPATH=$(BASEDIR)\lib\gobject-introspection
- @set PATH=vs$(VSVER)\$(CFG)\$(PLAT)\bin;$(BASEDIR)\bin;$(PATH);$(MINGWDIR)\bin
+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)
-Json-$(APIVERSION).gir: json_list vs$(VSVER)\$(CFG)\$(PLAT)\bin\Json-$(APIVERSION).lib
- @-echo Generating Json-$(APIVERSION).gir...
- $(PYTHON2) $(G_IR_SCANNER) --verbose -I..\.. \
- -I$(BASEDIR)\include\glib-2.0 -I$(BASEDIR)\lib\glib-2.0\include \
- --namespace=Json --nsversion=$(APIVERSION) \
- --include=GObject-2.0 --include=Gio-2.0 \
- --no-libtool --library=json-glib-1.0 \
- --reparse-validate --add-include-path=$(BASEDIR)\share\gir-1.0 --add-include-path=. \
- --warn-all --pkg-export json-glib-$(APIVERSION) --c-include "json-glib/json-glib.h" \
- -DJSON_COMPILATION=1 -DG_LOG_DOMAIN=\"Json\" \
- --filelist=json_list -o $@
-
-Json-$(APIVERSION).typelib: Json-$(APIVERSION).gir
- @-echo Compiling Json-$(APIVERSION).typelib...
- $(G_IR_COMPILER) --includedir=. --debug --verbose Json-$(APIVERSION).gir -o Json-$(APIVERSION).typelib
-
-install-introspection: setgirbuildnev Json-$(APIVERSION).gir Json-$(APIVERSION).typelib
+!include introspection.body.mak
+
+install-introspection: setgirbuildenv Json-$(APIVERSION).gir Json-$(APIVERSION).typelib
@-copy Json-$(APIVERSION).gir $(G_IR_INCLUDEDIR)
@-copy /b Json-$(APIVERSION).typelib $(G_IR_TYPELIBDIR)
@@ -54,6 +31,3 @@ all:
clean:
@-del /f/q Json-$(APIVERSION).typelib
@-del /f/q Json-$(APIVERSION).gir
- @-del /f/q vs$(VSVER)\$(CFG)\$(PLAT)\bin\Json-$(APIVERSION).lib
- @-del /f/q json_list
- @-del /f/q *.pyc
diff --git a/json-glib/Makefile.am b/json-glib/Makefile.am
index e8dedf9..2079bb8 100644
--- a/json-glib/Makefile.am
+++ b/json-glib/Makefile.am
@@ -161,6 +161,28 @@ json_glib_HEADERS_EXCLUDES = jgdummy
include $(top_srcdir)/build/Makefile.msvcproj
+# NMake/MSVC introspection
+if HAVE_INTROSPECTION
+NMAKE_INTROSPECTION_FILES = \
+ $(top_builddir)/build/win32/Json-1.0.gir.msvc.introspect \
+ $(top_builddir)/build/win32/Json_1_0_gir_list
+
+MSVC_INTROSPECT_GIRS = Json-1.0.gir
+
+Json_1_0_gir_MSVC_FILES = $(Json_1_0_gir_FILES)
+
+Json_1_0_gir_MSVC_INCLUDE_GIRS = $(Json_1_0_gir_INCLUDES)
+Json_1_0_gir_MSVC_LIBS = json-glib-1.0
+Json_1_0_gir_MSVC_CFLAGS = -DJSON_COMPILATION=1 -I..\\..
+
+Json_1_0_gir_MSVC_SCANNERFLAGS = $(Json_1_0_gir_SCANNERFLAGS)
+
+include $(top_srcdir)/build/Makefile.msvc-introspection
+else
+NMAKE_INTROSPECTION_FILES =
+endif
+
dist-hook: \
- $(top_builddir)/build/win32/vs9/json-glib.vcproj \
- $(top_builddir)/build/win32/vs9/json-glib.headers
+ $(top_builddir)/build/win32/vs9/json-glib.vcproj \
+ $(top_builddir)/build/win32/vs9/json-glib.headers \
+ $(NMAKE_INTROSPECTION_FILES)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]