Commit f658e94e authored by Chun-wei Fan's avatar Chun-wei Fan Committed by Chun-wei Fan

build: Drop Visual Studio projects

In master, it is already possible to build GLib using Visual Studio
using Meson[1] for some time, so we should focus on maintaining only the
Meson build files for building GLib with Visual Studio.

[1]: There are caveats when building with Visual Studio 2008, namely
     that one needs to use the mt command to embed the manifests that
     are generated with the .exe/DLLs, for all builds, and that in the
     case where the compilation hangs on Visual Studio 2008 x64, as a
     workaround, should stop the build by terminating all cl.exe tasks
     and change the compiler optimization flag from /O2 (full speed) to
     /O1 (optimize for size), due to compiler optimization issues.
parent b4259dec
......@@ -7,7 +7,7 @@ include $(top_srcdir)/glib.mk
ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
SUBDIRS = . m4macros glib gmodule gthread gobject gio po docs tests subprojects
DIST_SUBDIRS = $(SUBDIRS) build win32
DIST_SUBDIRS = $(SUBDIRS) build
bin_SCRIPTS = glib-gettextize
......@@ -50,7 +50,6 @@ EXTRA_DIST += \
tap-driver.sh \
tap-test \
msvc_recommended_pragmas.h \
config.h.win32.in \
po/po2tbl.sed.in \
glib-2.0.pc.in \
gobject-2.0.pc.in \
......@@ -113,7 +112,6 @@ BUILT_EXTRA_DIST += \
README \
INSTALL \
ChangeLog \
config.h.win32 \
$(NULL)
CONFIGURE_DEPENDENCIES = acglib.m4
......
......@@ -3466,15 +3466,6 @@ Makefile
build/Makefile
build/win32/Makefile
build/win32/dirent/Makefile
win32/Makefile
win32/vs9/Makefile
win32/vs9/glib-version-paths.vsprops
win32/vs10/Makefile
win32/vs10/glib-version-paths.props
win32/vs11/Makefile
win32/vs12/Makefile
win32/vs14/Makefile
win32/vs15/Makefile
glib/Makefile
glib/libcharset/Makefile
glib/gnulib/Makefile
......
......@@ -973,43 +973,7 @@ gio_LDADD = libgio-2.0.la \
$(top_builddir)/glib/libglib-2.0.la \
$(NULL)
# ------------------------------------------------------------------------
# ------ MSVC Project File Generation ------
# ------------------------------------------------------------------------
#
MSVCPROJS = gio glib-compile-resources glib-compile-schemas gio-tool
gio_FILES = \
$(gio_base_sources) \
$(win32_actual_sources) \
$(win32_more_sources_for_vcproj) \
$(settings_base_sources) \
$(win32_settings_sources)
gio_EXCLUDES = dummy
gio_HEADERS_DIR = $(includedir)/glib-2.0/gio
gio_HEADERS_INST = $(gioinclude_HEADERS) $(nodist_gioinclude_HEADERS)
gio_HEADERS_EXCLUDES = dummy
glib_compile_resources_FILES = $(glib_compile_resources_SOURCES)
glib_compile_resources_EXCLUDES = dummy
glib_compile_schemas_FILES = $(glib_compile_schemas_SOURCES)
glib_compile_schemas_EXCLUDES = dummy
gio_tool_FILES = $(gio_SOURCES)
gio_tool_EXCLUDES = dummy
include $(top_srcdir)/win32/Makefile.msvcproj
dist-hook: \
$(BUILT_EXTRA_DIST) \
$(top_builddir)/win32/vs9/gio.vcproj \
$(top_builddir)/win32/vs9/gio.headers \
$(top_builddir)/win32/vs9/glib-compile-schemas.vcproj \
$(top_builddir)/win32/vs9/glib-compile-resources.vcproj \
$(top_builddir)/win32/vs9/gio-tool.vcproj
dist-hook: $(BUILT_EXTRA_DIST)
files='$(BUILT_EXTRA_DIST)'; \
for f in $$files; do \
if test -f $$f; then d=.; else d=$(srcdir); fi; \
......
......@@ -9,15 +9,13 @@ include $(top_srcdir)/glib.mk
# to config.status will not result in changes to glibconfig.h so we
# avoid touching its timestamp (in order not to rebuild the whole tree).
#
DISTCLEANFILES += glibconfig-stamp glibconfig.h glibconfig.h.win32
DISTCLEANFILES += glibconfig-stamp glibconfig.h
BUILT_SOURCES += glibconfig-stamp
configexecincludedir = $(libdir)/glib-2.0/include
nodist_configexecinclude_HEADERS = glibconfig.h
glibconfig-stamp: ../config.status
$(AM_V_GEN) cd $(top_builddir) && \
$(SHELL) ./config.status glib/glibconfig.h
$(AM_V_GEN) cd $(top_builddir) && \
$(SHELL) ./config.status glib/glibconfig.h.win32
@touch glibconfig-stamp
......@@ -57,7 +55,6 @@ MIRRORING_TAB_SOURCE = \
EXTRA_DIST += \
glib.rc.in \
gen-unicode-tables.pl \
glibconfig.h.win32.in \
gregex.c \
gregex.h \
win_iconv.c \
......@@ -70,7 +67,6 @@ CLEANFILES += libglib-gdb.py
# These may be in the builddir too
BUILT_EXTRA_DIST += \
glibconfig.h.win32 \
glib.rc
lib_LTLIBRARIES = libglib-2.0.la
......@@ -458,19 +454,7 @@ glib.def: libglib-2.0.la
glib-2.0.lib: libglib-2.0.la glib.def
$(AM_V_GEN) lib.exe -machine:@LIB_EXE_MACHINE_FLAG@ -name:libglib-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(builddir)/glib.def -out:$@
# ------ MSVC Project File Generation ------
MSVCPROJS = glib
glib_FILES = $(libglib_2_0_la_SOURCES)
glib_EXCLUDES = *-unix.c|gthread-*.c
glib_HEADERS_DIR = $(glibsubincludedir)
glib_HEADERS_INST = $(deprecatedinclude_HEADERS) $(glibsubinclude_HEADERS)
glib_HEADERS_EXCLUDES = dummy
include $(top_srcdir)/win32/Makefile.msvcproj
dist-hook: $(BUILT_EXTRA_DIST) $(top_builddir)/win32/vs9/glib.vcproj $(top_builddir)/win32/vs9/glib.headers
dist-hook: $(BUILT_EXTRA_DIST)
files='$(BUILT_EXTRA_DIST)'; \
for f in $$files; do \
if test -f $$f; then d=.; else d=$(srcdir); fi; \
......
......@@ -217,19 +217,7 @@ gobject.def: libgobject-2.0.la
gobject-2.0.lib: libgobject-2.0.la gobject.def
$(AM_V_GEN) lib.exe -machine:@LIB_EXE_MACHINE_FLAG@ -name:libgobject-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(builddir)/gobject.def -out:$@
# ------ MSVC Project File Generation ------
MSVCPROJS = gobject
gobject_FILES = $(libgobject_2_0_la_SOURCES)
gobject_EXCLUDES = dummy
gobject_HEADERS_DIR = $(libgobjectincludedir)
gobject_HEADERS_INST = $(gobject_public_h_sources)
gobject_HEADERS_EXCLUDES = dummy
include $(top_srcdir)/win32/Makefile.msvcproj
dist-hook: $(BUILT_EXTRA_DIST) $(top_builddir)/win32/vs9/gobject.vcproj $(top_builddir)/win32/vs9/gobject.headers
dist-hook: $(BUILT_EXTRA_DIST)
files='$(BUILT_EXTRA_DIST)'; \
for f in $$files; do \
if test -f $$f; then d=.; else d=$(srcdir); fi; \
......
# Centralized autotools file
# Create the Visual Studio 2012/2013/2015 project files
# from the Visual Studio 2010 project files
# This autotools file, from GLib, can be used in other projects
# that have Visual Studio build support.
# Author: Fan, Chun-wei
# November 05, 2012
# MSVC_BASE_VER: Baseline MSVC 201x version to copy/process project files from (100 for 2010, 120 for 2013)
# MSVC_BASE_VER_LONG: Long Version of baseline Visual Studio 201x version (2010, 2012, 2013, 14, 15)
# MSVC_BASE_TOOLSET: Use if baseline MSVC toolset is not in the form v$(MSVC_BASE_VER)0, meaning v$(MSVC_BASE_TOOLSET)
# MSVC_VER_LONG: Long Version of target Visual Studio (2012, 2013, 14 and so on)
# MSVC_VER: Short Version of target Visual Studio (110 for 2012, 120 for 2013, 140 for 2015, 141 for 2017)
# MSVC_TOOLSET: Use if target MSVC toolsett is not in the form v $(MSVC_VER)0, meaning v$(MSVC_TOOLSET)
if MSVC_BASE_NO_TOOLSET_SET
MSVC_BASE_TOOLSET = $(MSVC_BASE_VER)0
endif
if MSVC_NO_TOOLSET_SET
MSVC_TOOLSET = $(MSVC_VER)0
endif
%.sln:
sed 's/11\.00/12\.00/g' < $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@ > $(top_builddir)/win32/vs$(MSVC_VER)/$@.tmp
sed 's/$(MSVC_BASE_VER_LONG)/$(MSVC_VER_LONG)/g' < $(top_builddir)/win32/vs$(MSVC_VER)/$@.tmp > $(top_builddir)/win32/vs$(MSVC_VER)/$@
rm $(top_builddir)/win32/vs$(MSVC_VER)/$@.tmp
%.txt:
sed 's/vs$(MSVC_BASE_VER)/vs$(MSVC_VER)/g' < $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@ > $(top_builddir)/win32/vs$(MSVC_VER)/$@.tmp
sed 's/VS$(MSVC_BASE_VER)/VS$(MSVC_VER)/g' < $(top_builddir)/win32/vs$(MSVC_VER)/$@.tmp > $(top_builddir)/win32/vs$(MSVC_VER)/$@
rm $(top_builddir)/win32/vs$(MSVC_VER)/$@.tmp
%.vcxproj:
if test -e $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@; then \
sed 's/v$(MSVC_BASE_TOOLSET)/v$(MSVC_TOOLSET)/g' < $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@ > $(top_builddir)/win32/vs$(MSVC_VER)/$@; \
else \
sed 's/v$(MSVC_BASE_TOOLSET)/v$(MSVC_TOOLSET)/g' < $(top_builddir)/win32/vs$(MSVC_BASE_VER)/$@ > $(top_builddir)/win32/vs$(MSVC_VER)/$@; \
fi
%.props: $(top_builddir)/win32/vs$(MSVC_BASE_VER)/Makefile
if test -e $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@; then \
sed 's/<VSVer>$(MSVC_BASE_VER)<\/VSVer>/<VSVer>$(MSVC_VER)<\/VSVer>/g' < $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@ > $(top_builddir)/win32/vs$(MSVC_VER)/$@; \
else \
sed 's/<VSVer>$(MSVC_BASE_VER)<\/VSVer>/<VSVer>$(MSVC_VER)<\/VSVer>/g' < $(top_builddir)/win32/vs$(MSVC_BASE_VER)/$@ > $(top_builddir)/win32/vs$(MSVC_VER)/$@; \
fi
%.vcxproj.filters:
if test -e $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@; then \
cp $(top_srcdir)/win32/vs$(MSVC_BASE_VER)/$@ $(top_builddir)/win32/vs$(MSVC_VER)/$@; \
else \
cp $(top_builddir)/win32/vs$(MSVC_BASE_VER)/$@ $(top_builddir)/win32/vs$(MSVC_VER)/$@; \
fi
SUBDIRS = vs9 vs10 vs11 vs12 vs14 vs15
EXTRA_DIST = \
glibpc.py \
pc_base.py \
replace.py \
gen_util_scripts.py
# Author: Fan, Chun-wei
# Common Autotools file used to generate Visual Studio 2008+
# Projects from their templates
# This autotools file, from GLib, can be used in other projects
# that have Visual Studio build support.
# * Input variables:
#
# MSVCPROJS - List of Projects that should be generated
#
# * Simple tutorial
#
# Add this to Makefile.am where your library/program is built:
# include <this Makefile.msvcproj>
# MSVCPROJS = YourProject (can be multiple projects in a single srcdir)
# YourProject_FILES = $(libyourlib_1_0_SOURCES)
# YourProject_EXCLUDES = ... # list of sources to exclude, separated by '|', wildcards allowed; use random unsed value if none
# (the following 3 lines if headers need to be installed)
# YourProject_HEADERS_DIR = $(libyourlibincludedir)
# YourProject_HEADERS_INST = $(libyourlib_1_0_HEADERS)
# YourProject_HEADERS_EXCLUDES = ... # <list of headers to exclude from installation, separated by '|', wildcards allowed; use random unsed value if none>
#
# dist-hook: \ # (or add to it if it is already there, note the vs9 items will also call the vs10 items in the process)
# $(top_builddir)/win32/vs9/YourProject.vcproj \
# $(top_builddir)/win32/vs9/YourProject.headers # if headers need to be installed
#
# --or, if Visual Studio 2013 or later is required--
# dist-hook: \ # (or add to it if it is already there, this does -not- call other vs items in the process)
# $(top_builddir)/win32/vs12/YourProject.vcxproj \
# $(top_builddir)/win32/vs12/YourProject.vs12.headers # if headers need to be installed
# Private functions
## Transform the MSVC project filename (no filename extensions) to something which can reference through a variable
## without automake/make complaining, eg Gtk-2.0 -> Gtk_2_0
_proj_name=$(subst /,_,$(subst -,_,$(subst .,_,$(1))))
_proj_path_raw:=$(subst $(abs_top_srcdir),,$(abs_srcdir))
_proj_path=$(subst /,\\,$(_proj_path_raw))
_proj_subdir_int=$(subst \\\\,\\,\\$(_proj_path)\\)
_proj_subdir=$(subst \\.\\,\\,$(_proj_subdir_int))
_proj_files_raw=$(subst /,\\,$($(_proj_name)_FILES))
_proj_files=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_files_raw))))
_proj_filters=$($(_proj_name)_EXCLUDES)
_proj_headers_raw=$(subst /,\\,$($(_proj_name)_HEADERS_INST))
_proj_headers=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_headers_raw))))
_proj_headers_excludes=$($(_proj_name)_HEADERS_EXCLUDES)
_headers_dest_posix=$(subst $(includedir),,$($(_proj_name)_HEADERS_DIR))
_headers_destdir=$(subst /,\\,$(_headers_dest_posix))
#
# Creates Visual Studio 2008/2010 projects from items passed in from autotools files
# $(1) - Base Name of the MSVC project files (outputs)
#
define msvcproj-builder
$(top_builddir)/win32/vs10/$(1).vcxproj: $(top_builddir)/win32/vs9/$(1).vcproj
$(top_builddir)/win32/vs10/$(1).vcxproj.filters: $(top_builddir)/win32/vs9/$(1).vcproj
$(1).sourcefiles: $(top_builddir)/win32/vs9/$(1).vcproj
$(1).vs10.sourcefiles: $(top_builddir)/win32/vs9/$(1).vcproj
$(1).vs10.sourcefiles.filters: $(top_builddir)/win32/vs9/$(1).vcproj
$(top_builddir)/win32/vs9/$(1).vcproj: Makefile
-$(RM) $(top_builddir)/win32/vs9/$(1).vcproj
-$(RM) $(top_builddir)/win32/vs10/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs10/$(1).vcxproj.filters
-$(RM) $(top_builddir)/win32/vs11/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs11/$(1).vcxproj.filters
-$(RM) $(top_builddir)/win32/vs12/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs12/$(1).vcxproj.filters
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj.filters
for F in $(_proj_files); do \
case $$$$F in \
$(_proj_filters)) \
;; \
*.c|*.cpp|*.cc|*.cxx) \
echo ' <File RelativePath="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).sourcefiles && \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs10.sourcefiles && \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs10.sourcefiles.filters \
;; \
esac; \
done
$(CPP) -P - <$(top_srcdir)/win32/vs9/$(1).vcprojin >$(top_builddir)/win32/vs9/$(1).vcproj
$(CPP) -P - <$(top_srcdir)/win32/vs10/$(1).vcxprojin >$(top_builddir)/win32/vs10/$(1).vcxproj
$(CPP) -P - <$(top_srcdir)/win32/vs10/$(1).vcxproj.filtersin >$(top_builddir)/win32/vs10/$(1).vcxproj.filters
$(RM) $(1).sourcefiles
$(RM) $(1).vs10.sourcefiles
$(RM) $(1).vs10.sourcefiles.filters
$(top_builddir)/win32/vs10/$(1).vs10.headers: $(top_builddir)/win32/vs9/$(1).headers
$(top_builddir)/win32/vs9/$(1).headers: Makefile
-$(RM) $(top_builddir)/win32/vs9/$(1).headers
-$(RM) $(top_builddir)/win32/vs10/$(1).vs10.headers
for F in $(_proj_headers); do \
case $$$$F in \
$(_proj_headers_excludes)) \
;; \
*.h|*.hpp|*.hh|*.hxx) \
echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'&#x0D;&#x0A;' >>$(top_builddir)/win32/vs9/$(1).headers && \
echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs10/$(1).vs10.headers \
;; \
esac; \
done
$(top_builddir)/win32/vs12/$(1).vcxproj.filters: $(top_builddir)/win32/vs12/$(1).vcxproj
$(top_builddir)/win32/vs12/$(1).vcxproj: Makefile
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj.filters
for F in $(_proj_files); do \
case $$$$F in \
$(_proj_filters)) \
;; \
*.c|*.cpp|*.cc|*.cxx) \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs12.sourcefiles && \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs12.sourcefiles.filters \
;; \
esac; \
done
$(CPP) -P - <$(top_srcdir)/win32/vs12/$(1).vcxprojin >$(top_builddir)/win32/vs12/$(1).vcxproj
$(CPP) -P - <$(top_srcdir)/win32/vs12/$(1).vcxproj.filtersin >$(top_builddir)/win32/vs12/$(1).vcxproj.filters
$(RM) $(1).vs12.sourcefiles
$(RM) $(1).vs12.sourcefiles.filters
$(top_builddir)/win32/vs12/$(1).vs12.headers: Makefile
-$(RM) $(top_builddir)/win32/vs12/$(1).vs12.headers
for F in $(_proj_headers); do \
case $$$$F in \
$(_proj_headers_excludes)) \
;; \
*.h|*.hpp|*.hh|*.hxx) \
echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs12/$(1).vs12.headers \
;; \
esac; \
done
endef
$(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))
# 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) < 1910
VSVER = 14
!elseif $(VCVERSION) > 1909 && $(VCVERSION) < 2000
VSVER = 15
!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
# Simple Python script to generate the full .schema.xml files
import os
import sys
import argparse
from replace import replace_multi
def main(argv):
srcroot = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
parser = argparse.ArgumentParser(description='Generate Utility Scripts')
parser.add_argument('-t', '--type', help='Script Type (glib-mkenums or gdbus-codegen)', required=True)
parser.add_argument('--version', help='Package Version', required=True)
args = parser.parse_args()
replace_items = {'@PYTHON@': 'python',
'@GLIB_VERSION@': args.version,
'@VERSION@': args.version}
if args.type == 'glib-mkenums':
replace_multi(srcroot + '/gobject/glib-mkenums.in',
srcroot + '/gobject/glib-mkenums',
replace_items)
elif args.type == 'glib-genmarshal':
replace_multi(srcroot + '/gobject/glib-genmarshal.in',
srcroot + '/gobject/glib-genmarshal',
replace_items)
elif args.type == 'gdbus-codegen':
replace_multi(srcroot + '/gio/gdbus-2.0/codegen/gdbus-codegen.in',
srcroot + '/gio/gdbus-2.0/codegen/gdbus-codegen',
replace_items)
else:
raise ValueError('Type must be glib-mkenums, glib-genmarshal or gdbus-codegen')
if __name__ == '__main__':
sys.exit(main(sys.argv))
#!/usr/bin/python
#
# Utility script to generate .pc files for GLib
# for Visual Studio builds, to be used for
# building introspection files
# Author: Fan, Chun-wei
# Date: March 10, 2016
import os
import sys
from replace import replace_multi
from pc_base import BasePCItems
def main(argv):
base_pc = BasePCItems()
base_pc.setup(argv)
pkg_replace_items = {'@G_THREAD_CFLAGS@': '',
'@G_THREAD_LIBS@': '',
'@CARBON_LIBS@': '',
'@COCOA_LIBS@': ''}
glib_replace_items = {'glib-genmarshal': '${exec_prefix}/bin/glib-genmarshal',
'glib-mkenums': 'perl ${exec_prefix}/bin/glib-mkenums',
'gobject-query': '${exec_prefix}/bin/gobject-query',
'@PCRE_REQUIRES@': '',
'@INTLLIBS@': '-lintl',
'@G_LIBS_EXTRA@': '',
'@PCRE_LIBS@': '',
'@ICONV_LIBS@': '-liconv',
'@GLIB_EXTRA_CFLAGS@': ''}
pkg_replace_items.update(base_pc.base_replace_items)
glib_replace_items.update(pkg_replace_items)
# Generate glib-2.0.pc
replace_multi(base_pc.top_srcdir + '/glib-2.0.pc.in',
base_pc.srcdir + '/glib-2.0.pc',
glib_replace_items)
# Generate gthread-2.0.pc
replace_multi(base_pc.top_srcdir + '/gthread-2.0.pc.in',
base_pc.srcdir + '/gthread-2.0.pc',
pkg_replace_items)
# Generate gmodule*-2.0.pc
gmodule_replace_items = {'@G_MODULE_SUPPORTED@': 'yes',
'@G_MODULE_LDFLAGS@': '',
'@G_MODULE_LIBS@': ''}
gmodule_replace_items.update(pkg_replace_items)
replace_multi(base_pc.top_srcdir + '/gmodule-2.0.pc.in',
base_pc.srcdir + '/gmodule-2.0.pc',
gmodule_replace_items)
replace_multi(base_pc.top_srcdir + '/gmodule-export-2.0.pc.in',
base_pc.srcdir + '/gmodule-export-2.0.pc',
gmodule_replace_items)
replace_multi(base_pc.top_srcdir + '/gmodule-no-export-2.0.pc.in',
base_pc.srcdir + '/gmodule-no-export-2.0.pc',
gmodule_replace_items)
# Generate gobject-2.0.pc
gobject_replace_items = {'@LIBFFI_LIBS@': ''}
gobject_replace_items.update(pkg_replace_items)
replace_multi(base_pc.top_srcdir + '/gobject-2.0.pc.in',
base_pc.srcdir + '/gobject-2.0.pc',
gobject_replace_items)
# Generate gio*-2.0.pc
gio_replace_items = {'@GIO_MODULE_DIR@': '${exec_prefix}/bin/gio/modules',
'@ZLIB_LIBS@': '-lzlib1',
'@NETWORK_LIBS@': '-lws2_32',
'@SELINUX_LIBS@': '',
'@LIBMOUNT_LIBS@': '',
'glib-compile-schemas': '${exec_prefix}/bin/glib-compile-schemas',
'glib-compile-resources': '${exec_prefix}/bin/glib-compile-resources',
'gdbus-codegen': 'python ${exec_prefix}/bin/gdbus-codegen'}
gio_replace_items.update(pkg_replace_items)
replace_multi(base_pc.top_srcdir + '/gio-2.0.pc.in',
base_pc.srcdir + '/gio-2.0.pc',
gio_replace_items)
replace_multi(base_pc.top_srcdir + '/gio-windows-2.0.pc.in',
base_pc.srcdir + '/gio-windows-2.0.pc',
pkg_replace_items)
if __name__ == '__main__':
sys.exit(main(sys.argv))
#!/usr/bin/python
#
# Simple utility script to generate the basic info
# needed in a .pc (pkg-config) file, used especially
# for introspection purposes
# This can be used in various projects where
# there is the need to generate .pc files,
# and is copied from GLib's $(srcroot)/win32
# Author: Fan, Chun-wei
# Date: March 10, 2016
import os
import sys
import argparse
class BasePCItems:
def __init__(self):
self.base_replace_items = {}
self.exec_prefix = ''
self.includedir = ''
self.libdir = ''
self.prefix = ''
self.srcdir = os.path.dirname(__file__)
self.top_srcdir = self.srcdir + '\\..'
self.version = ''
def setup(self, argv, parser=None):
if parser is None:
parser = argparse.ArgumentParser(description='Setup basic .pc file info')
parser.add_argument('--prefix', help='prefix of the installed library',
required=True)
parser.add_argument('--exec-prefix',
help='prefix of the installed programs, \
if different from the prefix')
parser.add_argument('--includedir',
help='includedir of the installed library, \
if different from ${prefix}/include')
parser.add_argument('--libdir',
help='libdir of the installed library, \
if different from ${prefix}/lib')
parser.add_argument('--version', help='Version of the package',
required=True)
args = parser.parse_args()
self.version = args.version
# check whether the prefix and exec_prefix are valid
if not os.path.exists(args.prefix):
raise SystemExit('Specified prefix \'%s\' is invalid' % args.prefix)
# use absolute paths for prefix
self.prefix = os.path.abspath(args.prefix).replace('\\','/')
# check and setup the exec_prefix
if getattr(args, 'exec_prefix', None) is None:
exec_prefix_use_shorthand = True
self.exec_prefix = '${prefix}'
else:
if args.exec_prefix.startswith('${prefix}'):
exec_prefix_use_shorthand = True
input_exec_prefix = args.prefix + args.exec_prefix[len('${prefix}'):]
else:
exec_prefix_use_shorthand = False
input_exec_prefix = args.exec_prefix
if not os.path.exists(input_exec_prefix):
raise SystemExit('Specified exec_prefix \'%s\' is invalid' %
args.exec_prefix)
if exec_prefix_use_shorthand is True:
self.exec_prefix = args.exec_prefix.replace('\\','/')
else:
self.exec_prefix = os.path.abspath(input_exec_prefix).replace('\\','/')
# check and setup the includedir
if getattr(args, 'includedir', None) is None:
self.includedir = '${prefix}/include'
else:
if args.includedir.startswith('${prefix}'):
includedir_use_shorthand = True
input_includedir = args.prefix + args.includedir[len('${prefix}'):]
else:
if args.includedir.startswith('${exec_prefix}'):
includedir_use_shorthand = True
input_includedir = input_exec_prefix + args.includedir[len('${exec_prefix}'):]
else:
includedir_use_shorthand = False
input_includedir = args.includedir
if not os.path.exists(input_includedir):
raise SystemExit('Specified includedir \'%s\' is invalid' %
args.includedir)
if includedir_use_shorthand is True:
self.includedir = args.includedir.replace('\\','/')
else:
self.includedir = os.path.abspath(input_includedir).replace('\\','/')
# check and setup the libdir
if getattr(args, 'libdir', None) is None:
self.libdir = '${prefix}/lib'
else:
if args.libdir.startswith('${prefix}'):
libdir_use_shorthand = True
input_libdir = args.prefix + args.libdir[len('${prefix}'):]
else:
if args.libdir.startswith('${exec_prefix}'):
libdir_use_shorthand = True
input_libdir = input_exec_prefix + args.libdir[len('${exec_prefix}'):]
else:
libdir_use_shorthand = False
input_libdir = args.libdir
if not os.path.exists(input_libdir):
raise SystemExit('Specified libdir \'%s\' is invalid' %
args.libdir)
if libdir_use_shorthand is True:
self.libdir = args.libdir.replace('\\','/')
else:
self.libdir = os.path.abspath(input_libdir).replace('\\','/')
# setup dictionary for replacing items in *.pc.in
self.base_replace_items.update({'@VERSION@': self.version})
self.base_replace_items.update({'@prefix@': self.prefix})
self.base_replace_items.update({'@exec_prefix@': self.exec_prefix})
self.base_replace_items.update({'@libdir@': self.libdir})
self.base_replace_items.update({'@includedir@': self.includedir})
#!/usr/bin/python
#
# Simple utility script to manipulate
# certain types of strings in a file