From e637c55d502be103ab00a1726539f19c17c17c05 Mon Sep 17 00:00:00 2001 From: loonycyborg Date: Tue, 13 Mar 2018 18:22:49 +0300 Subject: [PATCH] scons: added a check for icu support in boost locale --- SConstruct | 3 +++ scons/boost.py | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 677612e2f41..290d7c11988 100755 --- a/SConstruct +++ b/SConstruct @@ -374,6 +374,9 @@ if env["prereqs"]: conf.CheckBoost("locale") \ and Info("Base prerequisites are met")) \ or Warning("Base prerequisites are not met") + if(have_server_prereqs and not env["host"]): + conf.CheckBoostLocaleBackends(["icu", "winapi"]) \ + or Warning("Only icu and winapi backends of Boost Locale are supported. Bugs/crashes are very likely with other backends") env = conf.Finish() diff --git a/scons/boost.py b/scons/boost.py index 1df5036c6ed..3e055ccfa54 100644 --- a/scons/boost.py +++ b/scons/boost.py @@ -181,4 +181,44 @@ def CheckBoostIostreamsBZip2(context): context.Result("no") return False -config_checks = { "CheckBoost" : CheckBoost, "CheckBoostIostreamsGZip" : CheckBoostIostreamsGZip, "CheckBoostIostreamsBZip2" : CheckBoostIostreamsBZip2 } +def CheckBoostLocaleBackends(context, backends): + env = context.env + backup = env.Clone().Dictionary() + + context.Message("Checking for available Boost Locale backends... ") + test_program = """ + #include + #include + #include + + int main() + { + auto manager { boost::locale::localization_backend_manager::global() }; + auto backends { manager.get_all_backends() }; + assert(backends.size() >= 1); + for(auto backend : backends) { + std::cout << backend << std::endl; + } + } + \n""" + + if(env["PLATFORM"] != "win32"): + env.Append(LIBS = ["icudata", "icui18n", "icuuc"]) + + res, output = context.TryRun(test_program, ".cpp") + result = False + found_backends = "no" + if res: + supported_backends = output.splitlines() + result = bool(set(backends).intersection(supported_backends)) + found_backends = ",".join(supported_backends) + + context.Result(found_backends) + if result: + return True + else: + env.Replace(**backup) + + return False + +config_checks = { "CheckBoost" : CheckBoost, "CheckBoostIostreamsGZip" : CheckBoostIostreamsGZip, "CheckBoostIostreamsBZip2" : CheckBoostIostreamsBZip2, "CheckBoostLocaleBackends" : CheckBoostLocaleBackends }