scons: switch to regex to find and parse the (potentially custom) gdal libname from gdal-config - this is specifically to support debian naming of gdal pkgs
This commit is contained in:
parent
2399d61c4b
commit
67fe8b2c34
1 changed files with 23 additions and 11 deletions
34
SConstruct
34
SConstruct
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
import platform
|
import platform
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
@ -254,6 +255,20 @@ def parse_config(context, config, checks='--libs --cflags'):
|
||||||
context.Result( ret )
|
context.Result( ret )
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def get_pkg_lib(context, config, lib):
|
||||||
|
libpattern = r'-l([^\s]*)'
|
||||||
|
libname = None
|
||||||
|
env = context.env
|
||||||
|
context.Message( 'Checking for name of %s library... ' % lib)
|
||||||
|
cmd = '%s --libs' % env[config]
|
||||||
|
ret = context.TryAction(cmd)[0]
|
||||||
|
if ret:
|
||||||
|
libnames = re.findall(libpattern,call(cmd))
|
||||||
|
if libnames:
|
||||||
|
libname = libnames[0]
|
||||||
|
context.Result( libname )
|
||||||
|
return ret
|
||||||
|
|
||||||
def parse_pg_config(context, config):
|
def parse_pg_config(context, config):
|
||||||
env = context.env
|
env = context.env
|
||||||
tool = config.lower()
|
tool = config.lower()
|
||||||
|
@ -357,6 +372,7 @@ conf_tests = { 'CheckPKGConfig' : CheckPKGConfig,
|
||||||
'parse_config' : parse_config,
|
'parse_config' : parse_config,
|
||||||
'parse_pg_config' : parse_pg_config,
|
'parse_pg_config' : parse_pg_config,
|
||||||
'ogr_enabled':ogr_enabled,
|
'ogr_enabled':ogr_enabled,
|
||||||
|
'get_pkg_lib':get_pkg_lib,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -567,11 +583,9 @@ if not env.GetOption('clean'):
|
||||||
if plugin == 'gdal':
|
if plugin == 'gdal':
|
||||||
if conf.parse_config('GDAL_CONFIG',checks='--libs'):
|
if conf.parse_config('GDAL_CONFIG',checks='--libs'):
|
||||||
conf.parse_config('GDAL_CONFIG',checks='--cflags')
|
conf.parse_config('GDAL_CONFIG',checks='--cflags')
|
||||||
lib_result = call('gdal-config --libs')
|
libname = conf.get_pkg_lib('GDAL_CONFIG','gdal')
|
||||||
if lib_result:
|
if libname:
|
||||||
details['lib'] = lib_result.split(' ')[1].lstrip('-l')
|
details['lib'] = libname
|
||||||
else:
|
|
||||||
color_print(1,'Problem encountered parsing gdal lib name')
|
|
||||||
elif plugin == 'postgis':
|
elif plugin == 'postgis':
|
||||||
conf.parse_pg_config('PG_CONFIG')
|
conf.parse_pg_config('PG_CONFIG')
|
||||||
elif plugin == 'ogr':
|
elif plugin == 'ogr':
|
||||||
|
@ -579,12 +593,10 @@ if not env.GetOption('clean'):
|
||||||
if not 'gdal' in env['REQUESTED_PLUGINS']:
|
if not 'gdal' in env['REQUESTED_PLUGINS']:
|
||||||
conf.parse_config('GDAL_CONFIG',checks='--libs')
|
conf.parse_config('GDAL_CONFIG',checks='--libs')
|
||||||
conf.parse_config('GDAL_CONFIG',checks='--cflags')
|
conf.parse_config('GDAL_CONFIG',checks='--cflags')
|
||||||
lib_result = call('gdal-config --libs')
|
libname = conf.get_pkg_lib('GDAL_CONFIG','gdal')
|
||||||
if lib_result:
|
if libname:
|
||||||
details['lib'] = lib_result.split(' ')[1].lstrip('-l')
|
details['lib'] = libname
|
||||||
else:
|
|
||||||
color_print(1,'Problem encountered parsing gdal lib name')
|
|
||||||
|
|
||||||
elif details['path'] and details['lib'] and details['inc']:
|
elif details['path'] and details['lib'] and details['inc']:
|
||||||
backup = env.Clone().Dictionary()
|
backup = env.Clone().Dictionary()
|
||||||
# Note, the 'delete_existing' keyword makes sure that these paths are prepended
|
# Note, the 'delete_existing' keyword makes sure that these paths are prepended
|
||||||
|
|
Loading…
Reference in a new issue