Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/40866 )
Change subject: scons: Create a Configure checker for pkg-config.
......................................................................
scons: Create a Configure checker for pkg-config.
This will check if a pkg-config package exists at all, and then if it
does will attempt to use the supplied pkg-config arguments and
ParseConfig to set up the environment as needed.
Change-Id: I1495e5370b60dcebb1c9ce38517e84d727abc2fd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40866
Tested-by: kokoro <noreply+kok...@google.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
---
M SConstruct
M site_scons/gem5_scons/configure.py
2 files changed, 34 insertions(+), 22 deletions(-)
Approvals:
Andreas Sandberg: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/SConstruct b/SConstruct
index 9e3af37..27816bf 100755
--- a/SConstruct
+++ b/SConstruct
@@ -484,14 +484,7 @@
# check go a library config check and at that point the test
# will fail if libprotobuf cannot be found.
if have_pkg_config:
- try:
- # Attempt to establish what linking flags to add for
- # protobuf
- # using pkg-config
- main.ParseConfig(
- 'pkg-config --cflags --libs-only-L protobuf')
- except:
- warning('pkg-config could not get protobuf flags.')
+
conf.CheckPkgConfig('protobuf', '--cflags', '--libs-only-L')
except Exception as e:
warning('While checking protoc version:', str(e))
main['HAVE_PROTOC'] = False
@@ -724,23 +717,13 @@
main['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
-def check_hdf5_pkg(name):
- print("Checking for %s using pkg-config..." % name, end="")
- try:
- main.ParseConfig('pkg-config --cflags-only-I --libs-only-L %s' %
name)
- except:
- print(" no")
- return False
- print(" yes")
- return True
-
# Check if there is a pkg-config configuration for hdf5. If we find
# it, setup the environment to enable linking and header inclusion. We
# don't actually try to include any headers or link with hdf5 at this
# stage.
if have_pkg_config:
- if not check_hdf5_pkg('hdf5-serial'):
- check_hdf5_pkg('hdf5')
+ conf.CheckPkgConfig(['hdf5-serial', 'hdf5'],
+ '--cflags-only-I', '--libs-only-L')
# Check if the HDF5 libraries can be found. This check respects the
# include path and library path provided by pkg-config. We perform
diff --git a/site_scons/gem5_scons/configure.py
b/site_scons/gem5_scons/configure.py
index cebbb12..7bf97b2 100644
--- a/site_scons/gem5_scons/configure.py
+++ b/site_scons/gem5_scons/configure.py
@@ -41,6 +41,7 @@
import os
import SCons.Script
+import SCons.Util
def CheckCxxFlag(context, flag, autoadd=True):
context.Message("Checking for compiler %s support... " % flag)
@@ -106,6 +107,33 @@
else:
return tuple(map(int, ret[1].split(".")))
+def CheckPkgConfig(context, pkgs, *args):
+ if not SCons.Util.is_List(pkgs):
+ pkgs = [pkgs]
+ assert(pkgs)
+
+ for pkg in pkgs:
+ context.Message('Checking for pkg-config package %s... ' % pkg)
+ ret = context.TryAction('pkg-config %s' % pkg)[0]
+ if not ret:
+ context.Result(ret)
+ continue
+
+ if len(args) == 0:
+ break
+
+ cmd = ' '.join(['pkg-config'] + list(args) + [pkg])
+ try:
+ context.env.ParseConfig(cmd)
+ ret = 1
+ context.Result(ret)
+ break
+ except Exception as e:
+ ret = 0
+ context.Result(ret)
+
+ return ret
+
def Configure(env, *args, **kwargs):
kwargs.setdefault('conf_dir',
os.path.join(env['BUILDROOT'], '.scons_config'))
@@ -113,10 +141,11 @@
os.path.join(env['BUILDROOT'], 'scons_config.log'))
kwargs.setdefault('custom_tests', {})
kwargs['custom_tests'].update({
- 'CheckMember' : CheckMember,
- 'CheckPythonLib' : CheckPythonLib,
'CheckCxxFlag' : CheckCxxFlag,
'CheckLinkFlag' : CheckLinkFlag,
+ 'CheckMember' : CheckMember,
+ 'CheckPkgConfig' : CheckPkgConfig,
+ 'CheckPythonLib' : CheckPythonLib,
})
conf = SCons.Script.Configure(env, *args, **kwargs)
The change was submitted with unreviewed changes in the following files:
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40866
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I1495e5370b60dcebb1c9ce38517e84d727abc2fd
Gerrit-Change-Number: 40866
Gerrit-PatchSet: 8
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s