[json-glib] MSVC Builds: Rework Introspection Files Build



commit 0b1397ad168078bf2b588ab413ad921c04aab8a2
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Feb 7 18:55:32 2014 +0800

    MSVC Builds: Rework Introspection Files Build
    
    Use a set of NMake Makefiles in place of custom Visual Studio Projects to
    generate the introspection files for JSON-GLib.
    
    Although this means that one needs to build the introspection files in two
    stages, namely using the projects to build the JSON-GLib DLL and then
    running this NMake Makefile to generate the introspection files.  The
    original approach required setting lots of environment variables for the
    building of introspection files to work.  Using NMake Makefiles will make
    it clearer to the one building the introspection files on what items and
    variables are needed exactly to do the job

 build/win32/Makefile.am                      |    4 +-
 build/win32/detectenv_msvc.mak               |   65 +++++++++++++
 build/win32/gengir_jsonglib.bat              |  132 --------------------------
 build/win32/introspection-msvc.mak           |   79 +++++++++++++++
 build/win32/json-glib-introspection-msvc.mak |   64 +++++++++++++
 5 files changed, 211 insertions(+), 133 deletions(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index 75f9332..eea13ac 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -4,4 +4,6 @@ EXTRA_DIST =    \
        config.h.win32.in       \
        config.h.win32  \
        gen-file-list-jsonglib.py       \
-       gengir_jsonglib.bat
+       detectenv_msvc.mak      \
+       introspection-msvc.mak  \
+       json-glib-introspection-msvc.mak
diff --git a/build/win32/detectenv_msvc.mak b/build/win32/detectenv_msvc.mak
new file mode 100644
index 0000000..020548a
--- /dev/null
+++ b/build/win32/detectenv_msvc.mak
@@ -0,0 +1,65 @@
+# 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
+!else
+VSVER = 0
+!endif
+
+!if "$(VSVER)" == "0"
+MSG = ^
+This NMake Makefile set supports Visual Studio^
+9 (2008) through 12 (2013).  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..d637cc7
--- /dev/null
+++ b/build/win32/introspection-msvc.mak
@@ -0,0 +1,79 @@
+# 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
+
+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)
+
+# 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
+
+# This is required, and gobject-introspection needs to be built
+# before this can be successfully run.
+PYTHON2=python
+
+# Don't change anything following this line!
+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]     \
+       && ![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 ![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]
+!endif
+
+VALID_CFGSET = FALSE
+!if "$(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)
+!endif
+
+!if "$(VALID_CFGSET)" != "TRUE"
+BUILD_INTROSPECTION = FALSE
+ERROR_MSG = $(MSG_INVALID_CFG)
+!endif
diff --git a/build/win32/json-glib-introspection-msvc.mak b/build/win32/json-glib-introspection-msvc.mak
new file mode 100644
index 0000000..f638272
--- /dev/null
+++ b/build/win32/json-glib-introspection-msvc.mak
@@ -0,0 +1,64 @@
+# NMake Makefile to build Introspection Files for ATK
+
+# Change or pass in as a variable/env var if needed
+JSONGLIB_DLLNAME = json-glib-1-vs$(VSVER)
+
+# Please do not change anything after this line
+
+!include detectenv_msvc.mak
+
+APIVERSION = 1.0
+
+CHECK_PACKAGE =  gio-2.0
+
+!include introspection-msvc.mak
+
+!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
+       @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=$(JSONGLIB_DLLNAME)      \
+       --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
+       @-copy Json-$(APIVERSION).gir $(G_IR_INCLUDEDIR)
+       @-copy /b Json-$(APIVERSION).typelib $(G_IR_TYPELIBDIR)
+
+!else
+all:
+       @-echo $(ERROR_MSG)
+!endif
+
+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


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