Fix build issues with including <unicode/utf8.h> on case-insensitive filesystems
On case insensitive filesystems, the include path <unicode/utf8.h> was getting
resolved to Source/WTF/wtf/unicode/UTF8.h, which is not what the includer ever
wanted. To resolve this, this avoids exposing the Source/WTF/wtf and other
WTF-internal include dirs to code that merely depends on WTF, like
JavaScriptCore, and manually inserts the ICU include dirs earlier into the
include path for targets inside WTF.
Change-Id: I2f05d64f8348a4983e428492c1279be0c33fdeb6
diff --git a/BUILD.gn b/BUILD.gn
index e6a94d3..84ea11e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -381,6 +381,25 @@
config("wtf_config") {
include_dirs = [
"Source/WTF",
+ ]
+ }
+
+ config("wtf_private_config") {
+ # WTF has Source/WTF/wtf/unicode/UTF8.h and Source/WTF/wtf on the include
+ # path. The ICU library, which WTF depends on, has <unicode/utf8.h> in its
+ # include path. This means on case-insensitive filesystems, #includes for
+ # <unicode/utf8.h> will match Soruce/WTF/wtf/unicode/UTF8.h, which will
+ # internally include ICU's <unicode/utf8.h>.
+
+ # To get around all this, we manually add ICU's include path to our
+ # include_dirs before adding the WTF headers so includes for
+ # <unicode/utf8.h> match ICU regardless of the case sensitivity of the
+ # filesystem. As it turns out, all of the includes of UTF8.h (uppercase) are
+ # written <wtf/unicode/UTF8.h> so they will unambiguously resolve to
+ # Source/WTF/wtf/unicode/UTF8.h even with this include path first.
+ include_dirs = [ "//third_party/icu/source/common"]
+
+ include_dirs += [
"Source/WTF/wtf",
"Source/WTF/wtf/dtoa",
"Source/WTF/wtf/text",
@@ -401,6 +420,7 @@
configs += [
":features",
":flags",
+ ":wtf_private_config",
]
configs -= [
"//build/config/fuchsia:safestack",