scons: Disable protobuf if pkg-config and CheckLib fails
This patch changes the use of pkg-config such that protobuf is still evaluated with CheckLib even if it fails. This is to allow setups where libprotobuf is available, but not configured through protobuf. Moreover, if CheckLib fails to use libprotobuf then all the tracing is disabled, but scons is allowed to continue with a warning.
This commit is contained in:
parent
1429d21244
commit
62544f938a
1 changed files with 27 additions and 15 deletions
42
SConstruct
42
SConstruct
|
@ -637,21 +637,32 @@ if len(protoc_version) < 2 or protoc_version[0] != 'libprotoc':
|
||||||
termcap.Normal
|
termcap.Normal
|
||||||
main['PROTOC'] = False
|
main['PROTOC'] = False
|
||||||
else:
|
else:
|
||||||
# Determine the appropriate include path and library path using
|
|
||||||
# pkg-config, that means we also need to check for pkg-config
|
|
||||||
if not readCommand(['pkg-config', '--version'], exception=''):
|
|
||||||
print 'Error: pkg-config not found. Please install and retry.'
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
main.ParseConfig('pkg-config --cflags --libs-only-L protobuf')
|
|
||||||
|
|
||||||
# Based on the availability of the compress stream wrappers,
|
# Based on the availability of the compress stream wrappers,
|
||||||
# require 2.1.0
|
# require 2.1.0
|
||||||
min_protoc_version = '2.1.0'
|
min_protoc_version = '2.1.0'
|
||||||
if compareVersions(protoc_version[1], min_protoc_version) < 0:
|
if compareVersions(protoc_version[1], min_protoc_version) < 0:
|
||||||
print 'Error: protoc version', min_protoc_version, 'or newer required.'
|
print termcap.Yellow + termcap.Bold + \
|
||||||
print ' Installed version:', protoc_version[1]
|
'Warning: protoc version', min_protoc_version, \
|
||||||
Exit(1)
|
'or newer required.\n' + \
|
||||||
|
' Installed version:', protoc_version[1], \
|
||||||
|
termcap.Normal
|
||||||
|
main['PROTOC'] = False
|
||||||
|
else:
|
||||||
|
# Attempt to determine the appropriate include path and
|
||||||
|
# library path using pkg-config, that means we also need to
|
||||||
|
# check for pkg-config. Note that it is possible to use
|
||||||
|
# protobuf without the involvement of pkg-config. Later on we
|
||||||
|
# check go a library config check and at that point the test
|
||||||
|
# will fail if libprotobuf cannot be found.
|
||||||
|
if readCommand(['pkg-config', '--version'], exception=''):
|
||||||
|
try:
|
||||||
|
# Attempt to establish what linking flags to add for protobuf
|
||||||
|
# using pkg-config
|
||||||
|
main.ParseConfig('pkg-config --cflags --libs-only-L protobuf')
|
||||||
|
except:
|
||||||
|
print termcap.Yellow + termcap.Bold + \
|
||||||
|
'Warning: pkg-config could not get protobuf flags.' + \
|
||||||
|
termcap.Normal
|
||||||
|
|
||||||
# Check for SWIG
|
# Check for SWIG
|
||||||
if not main.has_key('SWIG'):
|
if not main.has_key('SWIG'):
|
||||||
|
@ -846,11 +857,12 @@ main['HAVE_PROTOBUF'] = main['PROTOC'] and \
|
||||||
conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
|
conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
|
||||||
'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
|
'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
|
||||||
|
|
||||||
# If we have the compiler but not the library, treat it as an error.
|
# If we have the compiler but not the library, print another warning.
|
||||||
if main['PROTOC'] and not main['HAVE_PROTOBUF']:
|
if main['PROTOC'] and not main['HAVE_PROTOBUF']:
|
||||||
print 'Error: did not find protocol buffer library and/or headers.'
|
print termcap.Yellow + termcap.Bold + \
|
||||||
print ' Please install libprotobuf-dev and try again.'
|
'Warning: did not find protocol buffer library and/or headers.\n' + \
|
||||||
Exit(1)
|
' Please install libprotobuf-dev for tracing support.' + \
|
||||||
|
termcap.Normal
|
||||||
|
|
||||||
# Check for librt.
|
# Check for librt.
|
||||||
have_posix_clock = \
|
have_posix_clock = \
|
||||||
|
|
Loading…
Reference in a new issue