SConstruct: fixup ICU min version check

- "Say what you mean." The check is for version >= 4.0, not 4.2
- call .Message before .TryRun
- don't silence .Result
This commit is contained in:
Mickey Rose 2018-06-27 23:04:39 +02:00
parent a2af3a53fa
commit a17de02ce4

View file

@ -1008,8 +1008,9 @@ int main()
context.Result(ret) context.Result(ret)
return ret return ret
def icu_at_least_four_two(context): def icu_at_least(context, min_version_str):
ret = context.TryRun(""" context.Message('Checking for ICU version >= %s... ' % min_version_str)
ret, out = context.TryRun("""
#include <unicode/uversion.h> #include <unicode/uversion.h>
#include <iostream> #include <iostream>
@ -1021,20 +1022,19 @@ int main()
} }
""", '.cpp') """, '.cpp')
# hack to avoid printed output try:
context.Message('Checking for ICU version >= 4.2... ') found_version_str = out.strip()
context.did_show_result=1 found_version = tuple(map(int, found_version_str.split('.')))
result = ret[1].strip() min_version = tuple(map(int, min_version_str.split('.')))
if not result: except:
context.Result('error, could not get major and minor version from unicode/uversion.h') context.Result('error (could not get version from unicode/uversion.h)')
return False return False
major, minor = map(int,result.split('.')) if found_version >= min_version:
if major >= 4 and minor >= 0: context.Result('yes (found ICU %s)' % found_version_str)
color_print(4,'found: icu %s' % result)
return True return True
color_print(1,'\nFound insufficient icu version... %s' % result) context.Result('no (found ICU %s)' % found_version_str)
return False return False
def harfbuzz_version(context): def harfbuzz_version(context):
@ -1204,7 +1204,7 @@ conf_tests = { 'prioritize_paths' : prioritize_paths,
'ogr_enabled' : ogr_enabled, 'ogr_enabled' : ogr_enabled,
'get_pkg_lib' : get_pkg_lib, 'get_pkg_lib' : get_pkg_lib,
'rollback_option' : rollback_option, 'rollback_option' : rollback_option,
'icu_at_least_four_two' : icu_at_least_four_two, 'icu_at_least' : icu_at_least,
'harfbuzz_version' : harfbuzz_version, 'harfbuzz_version' : harfbuzz_version,
'harfbuzz_with_freetype_support': harfbuzz_with_freetype_support, 'harfbuzz_with_freetype_support': harfbuzz_with_freetype_support,
'boost_regex_has_icu' : boost_regex_has_icu, 'boost_regex_has_icu' : boost_regex_has_icu,
@ -1526,7 +1526,7 @@ if not preconfigured:
else: else:
if libname == env['ICU_LIB_NAME']: if libname == env['ICU_LIB_NAME']:
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']: if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
if not conf.icu_at_least_four_two(): if not conf.icu_at_least("4.0"):
# expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2 # expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2
env['MISSING_DEPS'].append(env['ICU_LIB_NAME']) env['MISSING_DEPS'].append(env['ICU_LIB_NAME'])
elif libname == 'harfbuzz': elif libname == 'harfbuzz':