diff options
5 files changed, 52 insertions, 32 deletions
diff --git a/src/mongo/db/query/collation/SConscript b/src/mongo/db/query/collation/SConscript index 6569cfb832a..ff2fd28e387 100644 --- a/src/mongo/db/query/collation/SConscript +++ b/src/mongo/db/query/collation/SConscript @@ -6,14 +6,6 @@ Import("use_system_version_of_library") env = env.Clone() -env.InjectThirdPartyIncludePaths("icu") - -env.Append( - CPPDEFINES=[ - 'U_USING_ICU_NAMESPACE=0', - ], -) - env.Library( target="collator_interface", source=[ @@ -131,8 +123,30 @@ env.CppUnitTest( ], ) +env.CppUnitTest( + target="collator_interface_icu_test", + source=[ + "collator_interface_icu_test.cpp", + ], + LIBDEPS=[ + "collator_icu", + ], +) + +env.CppUnitTest( + target="collator_factory_icu_test", + source=[ + "collator_factory_icu_test.cpp", + ], + LIBDEPS=[ + "collator_icu", + ], +) + +icuEnv = env.Clone() + if not use_system_version_of_library("icu"): - generateICUInit = env.Command( + generateICUInit = icuEnv.Command( target="icu_init.cpp", source=[ "generate_icu_init_cpp.py", @@ -143,9 +157,24 @@ if not use_system_version_of_library("icu"): action="$PYTHON ${SOURCES[0]} -o $TARGET -i ${SOURCES[1]}", ) - env.Alias("generated-sources", generateICUInit) + icuEnv.Alias("generated-sources", generateICUInit) -env.Library( + icuEnv.InjectThirdPartyIncludePaths("icu") + + # Since we are injecting the third-party ICU headers, we must also copy the same defines that we + # use to configure ICU when building ICU sources. See comment in + # src/third_party/icu4c-57.1/source/SConscript. + icuEnv.Append( + CPPDEFINES=[ + ("UCONFIG_ONLY_COLLATION", 1), + ("U_CHARSET_IS_UTF8", 1), + ("U_DISABLE_RENAMING", 1), + ("U_STATIC_IMPLEMENTATION", 1), + ("U_USING_ICU_NAMESPACE", 0), + ], + ) + +icuEnv.Library( target="collator_icu", source=[ "collator_factory_icu.cpp", @@ -159,23 +188,3 @@ env.Library( "collator_factory_interface", ], ) - -env.CppUnitTest( - target="collator_interface_icu_test", - source=[ - "collator_interface_icu_test.cpp", - ], - LIBDEPS=[ - "collator_icu", - ], -) - -env.CppUnitTest( - target="collator_factory_icu_test", - source=[ - "collator_factory_icu_test.cpp", - ], - LIBDEPS=[ - "collator_icu", - ], -) diff --git a/src/mongo/db/query/collation/collator_factory_icu.cpp b/src/mongo/db/query/collation/collator_factory_icu.cpp index 395c6300a8e..c4088b38cda 100644 --- a/src/mongo/db/query/collation/collator_factory_icu.cpp +++ b/src/mongo/db/query/collation/collator_factory_icu.cpp @@ -30,7 +30,9 @@ #include "mongo/db/query/collation/collator_factory_icu.h" +#include <unicode/coll.h> #include <unicode/errorcode.h> +#include <unicode/ucol.h> #include "mongo/bson/bsonobj.h" #include "mongo/bson/util/bson_extract.h" diff --git a/src/mongo/db/query/collation/collator_interface_icu.cpp b/src/mongo/db/query/collation/collator_interface_icu.cpp index 08c5f74c900..12498d12712 100644 --- a/src/mongo/db/query/collation/collator_interface_icu.cpp +++ b/src/mongo/db/query/collation/collator_interface_icu.cpp @@ -30,6 +30,7 @@ #include "mongo/db/query/collation/collator_interface_icu.h" +#include <unicode/coll.h> #include <unicode/sortkey.h> #include "mongo/stdx/memory.h" diff --git a/src/mongo/db/query/collation/collator_interface_icu.h b/src/mongo/db/query/collation/collator_interface_icu.h index 76074628c87..9bb83824891 100644 --- a/src/mongo/db/query/collation/collator_interface_icu.h +++ b/src/mongo/db/query/collation/collator_interface_icu.h @@ -31,7 +31,10 @@ #include "mongo/db/query/collation/collator_interface.h" #include <memory> -#include <unicode/coll.h> + +namespace icu { +class Collator; +} // namespace icu namespace mongo { diff --git a/src/third_party/icu4c-57.1/source/SConscript b/src/third_party/icu4c-57.1/source/SConscript index de0be5acf60..7923fa47a67 100644 --- a/src/third_party/icu4c-57.1/source/SConscript +++ b/src/third_party/icu4c-57.1/source/SConscript @@ -4,11 +4,16 @@ Import('env') env = env.Clone() +# The below list of defines are used to configure ICU. They must be duplicated exactly in every +# library that injects the third-party ICU headers. If this list is changed here, it must be changed +# in other such libraries as well. env.Append( CPPDEFINES=[ ('UCONFIG_ONLY_COLLATION', 1), ('U_CHARSET_IS_UTF8', 1), + ('U_DISABLE_RENAMING', 1), ('U_STATIC_IMPLEMENTATION', 1), + ('U_USING_ICU_NAMESPACE', 0), ], ) |