mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-31 06:13:29 +02:00
build
win32
dirent
vs10
vs11
vs12
vs14
vs8
vs9
Makefile.am
detectenv-msvc.mak
glibpc.py
make.msc
module.defs
pc_base.py
replace.py
setup.py
ChangeLog
Makefile-newvs.am
Makefile.am
Makefile.msvcproj
README
docs
gio
glib
gmodule
gobject
gthread
m4macros
po
tests
.dir-locals.el
.gitignore
AUTHORS
COPYING
ChangeLog.pre-1-2
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-14
ChangeLog.pre-2-16
ChangeLog.pre-2-18
ChangeLog.pre-2-2
ChangeLog.pre-2-20
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
HACKING
INSTALL.in
Makefile.am
NEWS
NEWS.pre-1-3
README.commits
README.in
README.rationale
README.win32
acglib.m4
acinclude.m4
autogen.sh
check-abis.sh
config.h.win32.in
configure.ac
gio-2.0.pc.in
gio-unix-2.0.pc.in
gio-windows-2.0.pc.in
glib-2.0.pc.in
glib-gettextize.in
glib-tap.mk
glib-zip.in
glib.doap
glib.mk
gmodule-2.0.pc.in
gmodule-export-2.0.pc.in
gmodule-no-export-2.0.pc.in
gobject-2.0.pc.in
gthread-2.0.pc.in
makefile.msc
msvc_recommended_pragmas.h
sanity_check
tap-driver.sh
tap-test
win32-fixup.pl
Some packages might have some parts that are built for certain build configs, meaning that they could have .pc files of their own, such as Pango, where PangoFT2 is optionally built. Allow such an option if needed. Also remove some trailing whitespaces.
109 lines
4.4 KiB
Python
109 lines
4.4 KiB
Python
#!/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)/build/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)
|
|
|
|
# check and setup the exec_prefix
|
|
if getattr(args, 'exec_prefix', None) is None:
|
|
input_exec_prefix = args.prefix
|
|
else:
|
|
input_exec_prefix = args.exec_prefix
|
|
if not os.path.exists(input_exec_prefix):
|
|
raise SystemExit('Specified exec-prefix \'%s\' is invalid' %
|
|
input_exec_prefix)
|
|
|
|
|
|
# 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:
|
|
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:
|
|
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('\\','/')
|
|
|
|
# use absolute paths for prefix and exec_prefix
|
|
self.prefix = os.path.abspath(args.prefix).replace('\\','/')
|
|
self.exec_prefix = os.path.abspath(input_exec_prefix).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})
|