BUILD.gn 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # Copyright 2016 Google Inc.
  2. #
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. import("../../gn/skia.gni")
  6. import("../third_party.gni")
  7. import("icu.gni")
  8. declare_args() {
  9. skia_use_system_icu = is_official_build
  10. }
  11. if (skia_use_system_icu) {
  12. system("icu") {
  13. libs = [ "icuuc" ]
  14. defines = [ "U_USING_ICU_NAMESPACE=0" ]
  15. }
  16. } else {
  17. if (target_cpu == "wasm") {
  18. data_assembly = "$target_gen_dir/icudtl_dat.cpp"
  19. } else {
  20. data_assembly = "$target_gen_dir/icudtl_dat.S"
  21. }
  22. data_dir = "../externals/icu/"
  23. if (target_cpu == "wasm") {
  24. # Use a super super super stripped down version for wasm,
  25. # which is the same thing flutter is using.
  26. data_dir += "flutter"
  27. } else if (is_android) {
  28. data_dir += "android"
  29. } else if (is_ios) {
  30. data_dir += "ios"
  31. } else {
  32. data_dir += "common"
  33. }
  34. action("make_data_assembly") {
  35. if (target_cpu == "wasm") {
  36. _u_icu_version_major_num = "63" # defined in source/common/unicode/uvernum.h
  37. script = "make_data_cpp.py"
  38. inputs = [
  39. "$data_dir/icudtl.dat",
  40. ]
  41. outputs = [
  42. data_assembly,
  43. ]
  44. args = [
  45. "icudt${_u_icu_version_major_num}_dat",
  46. rebase_path(inputs[0], root_build_dir),
  47. rebase_path(data_assembly, root_build_dir),
  48. ]
  49. } else {
  50. script = "../externals/icu/scripts/make_data_assembly.py"
  51. inputs = [
  52. "$data_dir/icudtl.dat",
  53. ]
  54. outputs = [
  55. "$data_assembly",
  56. ]
  57. args = [
  58. rebase_path(inputs[0], root_build_dir),
  59. rebase_path(data_assembly, root_build_dir),
  60. ]
  61. if (is_mac || is_ios) {
  62. args += [ "--mac" ]
  63. }
  64. }
  65. }
  66. third_party("icu") {
  67. public_include_dirs = [
  68. "../externals/icu/source/common",
  69. "../externals/icu/source/i18n",
  70. ".",
  71. ]
  72. public_defines = [
  73. "U_USING_ICU_NAMESPACE=0",
  74. "SK_USING_THIRD_PARTY_ICU",
  75. ]
  76. configs -= [ "//gn:no_rtti" ]
  77. defines = [
  78. # http://userguide.icu-project.org/howtouseicu
  79. "U_COMMON_IMPLEMENTATION",
  80. "U_STATIC_IMPLEMENTATION",
  81. "U_ENABLE_DYLOAD=0",
  82. "U_I18N_IMPLEMENTATION",
  83. ]
  84. if (target_cpu == "wasm") {
  85. # Tell ICU that we are a 32 bit platform, otherwise,
  86. # double-conversion-utils.h doesn't know how to operate.
  87. defines += [ "__i386__" ]
  88. }
  89. sources = icu_sources
  90. if (is_win) {
  91. deps = [
  92. ":icudata",
  93. ]
  94. public_defines += [
  95. "U_NOEXCEPT=",
  96. "U_STATIC_IMPLEMENTATION",
  97. ]
  98. libs = [ "Advapi32.lib" ]
  99. sources += [
  100. "../externals/icu/source/stubdata/stubdata.cpp",
  101. "SkLoadICU.cpp",
  102. ]
  103. } else {
  104. sources += [ "$data_assembly" ]
  105. deps = [
  106. ":make_data_assembly",
  107. ]
  108. }
  109. }
  110. copy("icudata") {
  111. sources = [
  112. "../externals/icu/common/icudtl.dat",
  113. ]
  114. outputs = [
  115. "$root_out_dir/icudtl.dat",
  116. ]
  117. data = [
  118. "$root_out_dir/icudtl.dat",
  119. ]
  120. }
  121. }