summaryrefslogtreecommitdiffstats
path: root/source-builder/sb/pkgconfig.py
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-06-15 17:40:34 +1200
committerChris Johns <chrisj@rtems.org>2014-06-15 17:40:34 +1200
commit0ffee1931680e92757a4d91199e2517f05e7364d (patch)
tree0a0447a40008a02e238bfa55ab0c7a413de4b47a /source-builder/sb/pkgconfig.py
parentsb: Tighten the canadian cross compile detection. (diff)
downloadrtems-source-builder-0ffee1931680e92757a4d91199e2517f05e7364d.tar.bz2
sb: Add support for building RTEMS 3rd party packages.
Remove the 'opt' from various macros and shell variables. Add pkgconfig to the checks to make it clear the check is a pkgconfig check. Add NTP support as the first package to be built using the RSB. Split the RTEMS URL's out from the base bset file into a separate file that be included by other files. Add an RTEMS BSP configuration file to help abstract the process of building 3rd party packages. Clean the cross and canadian cross support up so we can cleanly support cross and canadian cross building. Refactor the pkgconfig support and clean up the PC file handling of loading modules. Add support for %{?..} to return false if a macro is %{nil}. Add %{pkgconfig ..} support to allow better control of access RTEMS pkgconfig files.
Diffstat (limited to 'source-builder/sb/pkgconfig.py')
-rwxr-xr-xsource-builder/sb/pkgconfig.py65
1 files changed, 60 insertions, 5 deletions
diff --git a/source-builder/sb/pkgconfig.py b/source-builder/sb/pkgconfig.py
index 8427777..1299178 100755
--- a/source-builder/sb/pkgconfig.py
+++ b/source-builder/sb/pkgconfig.py
@@ -34,6 +34,7 @@
# provided by the full pkg-config so packages can configure and build.
#
+import copy
import os
import os.path
import re
@@ -73,6 +74,14 @@ class package(object):
loaded = {}
@staticmethod
+ def _copy(src, dst):
+ dst.name_ = src.name_
+ dst.file_ = src.file_
+ dst.defines = copy.copy(src.defines)
+ dst.fields = copy.copy(src.fields)
+ dst.nodes = copy.copy(src.nodes)
+
+ @staticmethod
def is_version(v):
for n in v.split('.'):
if not n.isdigit():
@@ -384,7 +393,9 @@ class package(object):
def load(self, name):
if name in package.loaded:
- raise error('package already loaded: %s' % (name))
+ package._copy(package.loaded[name], self)
+ return
+ self._log('loading: %s' % (name))
if self.name_:
self._clean()
self.name_ = name
@@ -392,14 +403,14 @@ class package(object):
if file:
self._log('load: %s (%s)' % (name, file))
if self.src:
- self.src.writelines('==%s%s' % ('=' * 80, os.linesep))
- self.src.writelines(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep))
- self.src.writelines('==%s%s' % ('=' * 80, os.linesep))
+ self.src('==%s%s' % ('=' * 80, os.linesep))
+ self.src(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep))
+ self.src('==%s%s' % ('=' * 80, os.linesep))
f = open(file)
tm = False
for l in f.readlines():
if self.src:
- self.src.writelines(l)
+ self.src(l)
l = l[:-1]
hash = l.find('#')
if hash >= 0:
@@ -455,6 +466,7 @@ class package(object):
package.loaded[name] = self
def get(self, label, private = True):
+ self._log('get: %s (%s)' % (label, ','.join(self.fields)))
if label.lower() not in self.fields:
return None
s = ''
@@ -504,3 +516,46 @@ class package(object):
else:
self._log('check: %s not found' % (self.name_))
return ok
+
+def check_package(libraries, args, output, src):
+ ec = 1
+ pkg = None
+ flags = { 'cflags': '',
+ 'libs': '' }
+ output('libraries: %s' % (libraries))
+ libs = package.splitter(libraries)
+ for lib in libs:
+ output('pkg: %s' % (lib))
+ pkg = package(lib[0], prefix = args.prefix, output = output, src = src)
+ if args.dump:
+ output(pkg)
+ if pkg.exists():
+ if len(lib) == 1:
+ if args.exact_version:
+ if pkg.check('=', args.exact_version):
+ ec = 0
+ elif args.atleast_version:
+ if pkg.check('>=', args.atleast_version):
+ ec = 0
+ elif args.max_version:
+ if pkg.check('<=', args.max_version):
+ ec = 0
+ else:
+ ec = 0
+ else:
+ if len(lib) != 3:
+ raise error('invalid package check: %s' % (' '.join(lib)))
+ if pkg.check(lib[1], lib[2]):
+ ec = 0
+ if ec == 0:
+ cflags = pkg.get('cflags')
+ if cflags:
+ flags['cflags'] += cflags
+ libs = pkg.get('libs', private = False)
+ if libs:
+ flags['libs'] += libs
+ break
+ if ec > 0:
+ break
+ return ec, pkg, flags
+