glib/build/win32/glibpc.py
Chun-wei Fan 374a61f245 MSVC builds: Add scripts to generate .pc files
Add a generic script, pc_base.py, which can be utilized to obtain path
info, along with user-input version info, which can be used to generate
pkg-config .pc files.  Also enhance replace.py a bit so that it can also
be used in the future to replace multiple items in a file in one shot.
This is done to make building introspection files easier, as it depends
much on the pkg-config .pc files to work.

Update the project files so that when Python is available, we can generate
the full, usable .pc files when we complete and 'install' the builds, and
copy them to appropriate locations so that pkg-config can be set to find
them easily.
2016-03-10 20:33:35 +08:00

89 lines
3.4 KiB
Python

#!/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@': '',
'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))