SConstruct 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. import atexit
  4. import sys
  5. import time
  6. import methods
  7. # Enable ANSI escape code support on Windows 10 and later (for colored console output).
  8. # <https://github.com/python/cpython/issues/73245>
  9. if sys.stdout.isatty() and sys.platform == "win32":
  10. try:
  11. from ctypes import WinError, byref, windll # type: ignore
  12. from ctypes.wintypes import DWORD # type: ignore
  13. stdout_handle = windll.kernel32.GetStdHandle(DWORD(-11))
  14. mode = DWORD(0)
  15. if not windll.kernel32.GetConsoleMode(stdout_handle, byref(mode)):
  16. raise WinError()
  17. mode = DWORD(mode.value | 4)
  18. if not windll.kernel32.SetConsoleMode(stdout_handle, mode):
  19. raise WinError()
  20. except Exception as e:
  21. methods._colorize = False
  22. methods.print_error(f"Failed to enable ANSI escape code support, disabling color output.\n{e}")
  23. # For the reference:
  24. # - CCFLAGS are compilation flags shared between C and C++
  25. # - CFLAGS are for C-specific compilation flags
  26. # - CXXFLAGS are for C++-specific compilation flags
  27. # - CPPFLAGS are for pre-processor flags
  28. # - CPPDEFINES are for pre-processor defines
  29. # - LINKFLAGS are for linking flags
  30. time_at_start = time.time()
  31. env = SConscript("./godot-cpp/SConstruct")
  32. env.__class__.disable_warnings = methods.disable_warnings
  33. opts = Variables([], ARGUMENTS)
  34. opts.Add(BoolVariable("brotli_enabled", "Use Brotli library", True))
  35. opts.Add(BoolVariable("freetype_enabled", "Use FreeType library", True))
  36. opts.Add(BoolVariable("msdfgen_enabled", "Use MSDFgen library (require FreeType)", True))
  37. opts.Add(BoolVariable("graphite_enabled", "Use Graphite library (require FreeType)", True))
  38. opts.Add(BoolVariable("thorvg_enabled", "Use ThorVG library (require FreeType)", True))
  39. opts.Add(BoolVariable("static_icu_data", "Use built-in ICU data", True))
  40. opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
  41. opts.Update(env)
  42. if not env["verbose"]:
  43. methods.no_verbose(env)
  44. if env["platform"] == "windows" and not env["use_mingw"]:
  45. env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.
  46. # ThorVG
  47. if env["thorvg_enabled"] and env["freetype_enabled"]:
  48. env_tvg = env.Clone()
  49. env_tvg.disable_warnings()
  50. thirdparty_tvg_dir = "../../../thirdparty/thorvg/"
  51. thirdparty_tvg_sources = [
  52. # common
  53. "src/common/tvgCompressor.cpp",
  54. "src/common/tvgLines.cpp",
  55. "src/common/tvgMath.cpp",
  56. "src/common/tvgStr.cpp",
  57. # SVG parser
  58. "src/loaders/svg/tvgSvgCssStyle.cpp",
  59. "src/loaders/svg/tvgSvgLoader.cpp",
  60. "src/loaders/svg/tvgSvgPath.cpp",
  61. "src/loaders/svg/tvgSvgSceneBuilder.cpp",
  62. "src/loaders/svg/tvgSvgUtil.cpp",
  63. "src/loaders/svg/tvgXmlParser.cpp",
  64. "src/loaders/raw/tvgRawLoader.cpp",
  65. # image loaders
  66. "src/loaders/external_png/tvgPngLoader.cpp",
  67. "src/loaders/jpg/tvgJpgd.cpp",
  68. "src/loaders/jpg/tvgJpgLoader.cpp",
  69. # renderer common
  70. "src/renderer/tvgAccessor.cpp",
  71. # "src/renderer/tvgAnimation.cpp",
  72. "src/renderer/tvgCanvas.cpp",
  73. "src/renderer/tvgFill.cpp",
  74. # "src/renderer/tvgGlCanvas.cpp",
  75. "src/renderer/tvgInitializer.cpp",
  76. "src/renderer/tvgLoader.cpp",
  77. "src/renderer/tvgPaint.cpp",
  78. "src/renderer/tvgPicture.cpp",
  79. "src/renderer/tvgRender.cpp",
  80. # "src/renderer/tvgSaver.cpp",
  81. "src/renderer/tvgScene.cpp",
  82. "src/renderer/tvgShape.cpp",
  83. "src/renderer/tvgSwCanvas.cpp",
  84. "src/renderer/tvgTaskScheduler.cpp",
  85. "src/renderer/tvgText.cpp",
  86. # "src/renderer/tvgWgCanvas.cpp",
  87. # renderer sw_engine
  88. "src/renderer/sw_engine/tvgSwFill.cpp",
  89. "src/renderer/sw_engine/tvgSwImage.cpp",
  90. "src/renderer/sw_engine/tvgSwMath.cpp",
  91. "src/renderer/sw_engine/tvgSwMemPool.cpp",
  92. "src/renderer/sw_engine/tvgSwRaster.cpp",
  93. "src/renderer/sw_engine/tvgSwRenderer.cpp",
  94. "src/renderer/sw_engine/tvgSwRle.cpp",
  95. "src/renderer/sw_engine/tvgSwShape.cpp",
  96. "src/renderer/sw_engine/tvgSwStroke.cpp",
  97. ]
  98. thirdparty_tvg_sources = [thirdparty_tvg_dir + file for file in thirdparty_tvg_sources]
  99. env_tvg.Append(
  100. CPPPATH=[
  101. "../../../thirdparty/thorvg/inc",
  102. "../../../thirdparty/thorvg/src/common",
  103. "../../../thirdparty/thorvg/src/renderer",
  104. "../../../thirdparty/thorvg/src/renderer/sw_engine",
  105. "../../../thirdparty/thorvg/src/loaders/svg",
  106. "../../../thirdparty/thorvg/src/loaders/raw",
  107. "../../../thirdparty/thorvg/src/loaders/external_png",
  108. "../../../thirdparty/thorvg/src/loaders/jpg",
  109. "../../../thirdparty/libpng",
  110. ]
  111. )
  112. # Enable ThorVG static object linking.
  113. env_tvg.Append(CPPDEFINES=["TVG_STATIC"])
  114. env.Append(
  115. CPPPATH=[
  116. "../../../thirdparty/thorvg/inc",
  117. "../../../thirdparty/thorvg/src/common",
  118. "../../../thirdparty/thorvg/src/renderer",
  119. ]
  120. )
  121. env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"])
  122. lib = env_tvg.Library(
  123. f'tvg_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
  124. thirdparty_tvg_sources,
  125. )
  126. env.Append(LIBS=[lib])
  127. # MSDFGEN
  128. if env["msdfgen_enabled"] and env["freetype_enabled"]:
  129. env_msdfgen = env.Clone()
  130. env_msdfgen.disable_warnings()
  131. thirdparty_msdfgen_dir = "../../../thirdparty/msdfgen/"
  132. thirdparty_msdfgen_sources = [
  133. "core/Contour.cpp",
  134. "core/EdgeHolder.cpp",
  135. "core/MSDFErrorCorrection.cpp",
  136. "core/Projection.cpp",
  137. "core/Scanline.cpp",
  138. "core/Shape.cpp",
  139. "core/contour-combiners.cpp",
  140. "core/edge-coloring.cpp",
  141. "core/edge-segments.cpp",
  142. "core/edge-selectors.cpp",
  143. "core/equation-solver.cpp",
  144. "core/msdf-error-correction.cpp",
  145. "core/msdfgen.cpp",
  146. "core/rasterization.cpp",
  147. "core/render-sdf.cpp",
  148. "core/sdf-error-estimation.cpp",
  149. "core/shape-description.cpp",
  150. ]
  151. thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
  152. env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
  153. env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
  154. env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
  155. env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
  156. env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
  157. lib = env_msdfgen.Library(
  158. f'msdfgen_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
  159. thirdparty_msdfgen_sources,
  160. )
  161. env.Append(LIBS=[lib])
  162. # FreeType
  163. if env["freetype_enabled"]:
  164. env_freetype = env.Clone()
  165. env_freetype.disable_warnings()
  166. thirdparty_freetype_dir = "../../../thirdparty/freetype/"
  167. thirdparty_freetype_sources = [
  168. "src/autofit/autofit.c",
  169. "src/base/ftbase.c",
  170. "src/base/ftbbox.c",
  171. "src/base/ftbdf.c",
  172. "src/base/ftbitmap.c",
  173. "src/base/ftcid.c",
  174. "src/base/ftdebug.c",
  175. "src/base/ftfstype.c",
  176. "src/base/ftgasp.c",
  177. "src/base/ftglyph.c",
  178. "src/base/ftgxval.c",
  179. "src/base/ftinit.c",
  180. "src/base/ftmm.c",
  181. "src/base/ftotval.c",
  182. "src/base/ftpatent.c",
  183. "src/base/ftpfr.c",
  184. "src/base/ftstroke.c",
  185. "src/base/ftsynth.c",
  186. "src/base/ftsystem.c",
  187. "src/base/fttype1.c",
  188. "src/base/ftwinfnt.c",
  189. "src/bdf/bdf.c",
  190. "src/bzip2/ftbzip2.c",
  191. "src/cache/ftcache.c",
  192. "src/cff/cff.c",
  193. "src/cid/type1cid.c",
  194. "src/gxvalid/gxvalid.c",
  195. "src/gzip/ftgzip.c",
  196. "src/lzw/ftlzw.c",
  197. "src/otvalid/otvalid.c",
  198. "src/pcf/pcf.c",
  199. "src/pfr/pfr.c",
  200. "src/psaux/psaux.c",
  201. "src/pshinter/pshinter.c",
  202. "src/psnames/psnames.c",
  203. "src/raster/raster.c",
  204. "src/sdf/sdf.c",
  205. "src/svg/svg.c",
  206. "src/smooth/smooth.c",
  207. "src/truetype/truetype.c",
  208. "src/type1/type1.c",
  209. "src/type42/type42.c",
  210. "src/winfonts/winfnt.c",
  211. "src/sfnt/sfnt.c",
  212. ]
  213. thirdparty_freetype_sources = [thirdparty_freetype_dir + file for file in thirdparty_freetype_sources]
  214. thirdparty_png_dir = "../../../thirdparty/libpng/"
  215. thirdparty_png_sources = [
  216. "png.c",
  217. "pngerror.c",
  218. "pngget.c",
  219. "pngmem.c",
  220. "pngpread.c",
  221. "pngread.c",
  222. "pngrio.c",
  223. "pngrtran.c",
  224. "pngrutil.c",
  225. "pngset.c",
  226. "pngtrans.c",
  227. "pngwio.c",
  228. "pngwrite.c",
  229. "pngwtran.c",
  230. "pngwutil.c",
  231. ]
  232. thirdparty_freetype_sources += [thirdparty_png_dir + file for file in thirdparty_png_sources]
  233. thirdparty_zlib_dir = "../../../thirdparty/zlib/"
  234. thirdparty_zlib_sources = [
  235. "adler32.c",
  236. "compress.c",
  237. "crc32.c",
  238. "deflate.c",
  239. "inffast.c",
  240. "inflate.c",
  241. "inftrees.c",
  242. "trees.c",
  243. "uncompr.c",
  244. "zutil.c",
  245. ]
  246. thirdparty_freetype_sources += [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
  247. if env["brotli_enabled"]:
  248. thirdparty_brotli_dir = "../../../thirdparty/brotli/"
  249. thirdparty_brotli_sources = [
  250. "common/constants.c",
  251. "common/context.c",
  252. "common/dictionary.c",
  253. "common/platform.c",
  254. "common/shared_dictionary.c",
  255. "common/transform.c",
  256. "dec/bit_reader.c",
  257. "dec/decode.c",
  258. "dec/huffman.c",
  259. "dec/state.c",
  260. ]
  261. thirdparty_freetype_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
  262. env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
  263. env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
  264. env.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
  265. env_freetype.Append(CPPPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir])
  266. env.Append(CPPPATH=[thirdparty_freetype_dir + "/include"])
  267. env_freetype.Append(
  268. CPPDEFINES=[
  269. "FT2_BUILD_LIBRARY",
  270. "FT_CONFIG_OPTION_USE_PNG",
  271. "FT_CONFIG_OPTION_SYSTEM_ZLIB",
  272. ]
  273. )
  274. if env.dev_build:
  275. env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"])
  276. env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"])
  277. lib = env_freetype.Library(
  278. f'freetype_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
  279. thirdparty_freetype_sources,
  280. )
  281. env.Append(LIBS=[lib])
  282. # HarfBuzz
  283. env_harfbuzz = env.Clone()
  284. env_harfbuzz.disable_warnings()
  285. thirdparty_harfbuzz_dir = "../../../thirdparty/harfbuzz/"
  286. thirdparty_harfbuzz_sources = [
  287. "src/hb-aat-layout.cc",
  288. "src/hb-aat-map.cc",
  289. "src/hb-blob.cc",
  290. "src/hb-buffer-serialize.cc",
  291. "src/hb-buffer-verify.cc",
  292. "src/hb-buffer.cc",
  293. # "src/hb-cairo-utils.cc",
  294. # "src/hb-cairo.cc",
  295. "src/hb-common.cc",
  296. # "src/hb-coretext.cc",
  297. # "src/hb-directwrite.cc",
  298. "src/hb-draw.cc",
  299. "src/hb-face-builder.cc",
  300. "src/hb-face.cc",
  301. "src/hb-fallback-shape.cc",
  302. "src/hb-font.cc",
  303. # "src/hb-gdi.cc",
  304. # "src/hb-glib.cc",
  305. # "src/hb-gobject-structs.cc",
  306. "src/hb-icu.cc",
  307. "src/hb-map.cc",
  308. "src/hb-number.cc",
  309. "src/hb-ot-cff1-table.cc",
  310. "src/hb-ot-cff2-table.cc",
  311. "src/hb-ot-color.cc",
  312. "src/hb-ot-face.cc",
  313. "src/hb-ot-font.cc",
  314. "src/hb-ot-layout.cc",
  315. "src/hb-ot-map.cc",
  316. "src/hb-ot-math.cc",
  317. "src/hb-ot-meta.cc",
  318. "src/hb-ot-metrics.cc",
  319. "src/hb-ot-name.cc",
  320. "src/hb-ot-shaper-arabic.cc",
  321. "src/hb-ot-shaper-default.cc",
  322. "src/hb-ot-shaper-hangul.cc",
  323. "src/hb-ot-shaper-hebrew.cc",
  324. "src/hb-ot-shaper-indic-table.cc",
  325. "src/hb-ot-shaper-indic.cc",
  326. "src/hb-ot-shaper-khmer.cc",
  327. "src/hb-ot-shaper-myanmar.cc",
  328. "src/hb-ot-shaper-syllabic.cc",
  329. "src/hb-ot-shaper-thai.cc",
  330. "src/hb-ot-shaper-use.cc",
  331. "src/hb-ot-shaper-vowel-constraints.cc",
  332. "src/hb-ot-shape-fallback.cc",
  333. "src/hb-ot-shape-normalize.cc",
  334. "src/hb-ot-shape.cc",
  335. "src/hb-ot-tag.cc",
  336. "src/hb-ot-var.cc",
  337. "src/hb-outline.cc",
  338. "src/hb-paint-extents.cc",
  339. "src/hb-paint.cc",
  340. "src/hb-set.cc",
  341. "src/hb-shape-plan.cc",
  342. "src/hb-shape.cc",
  343. "src/hb-shaper.cc",
  344. "src/hb-static.cc",
  345. "src/hb-style.cc",
  346. "src/hb-subset-cff-common.cc",
  347. "src/hb-subset-cff1.cc",
  348. "src/hb-subset-cff2.cc",
  349. "src/hb-subset-input.cc",
  350. "src/hb-subset-instancer-iup.cc",
  351. "src/hb-subset-instancer-solver.cc",
  352. "src/hb-subset-plan.cc",
  353. "src/hb-subset-repacker.cc",
  354. "src/hb-subset.cc",
  355. "src/hb-ucd.cc",
  356. "src/hb-unicode.cc",
  357. # "src/hb-uniscribe.cc",
  358. "src/OT/Var/VARC/VARC.cc",
  359. ]
  360. if env["freetype_enabled"]:
  361. thirdparty_harfbuzz_sources += [
  362. "src/hb-ft.cc",
  363. "src/hb-graphite2.cc",
  364. ]
  365. thirdparty_harfbuzz_sources = [thirdparty_harfbuzz_dir + file for file in thirdparty_harfbuzz_sources]
  366. env_harfbuzz.Append(
  367. CPPPATH=[
  368. "../../../thirdparty/harfbuzz/src",
  369. "../../../thirdparty/icu4c/common/",
  370. "../../../thirdparty/icu4c/i18n/",
  371. ]
  372. )
  373. if env["freetype_enabled"]:
  374. env_harfbuzz.Append(
  375. CPPPATH=[
  376. "../../../thirdparty/freetype/include",
  377. "../../../thirdparty/graphite/include",
  378. ]
  379. )
  380. if env["platform"] == "android" or env["platform"] == "linuxbsd":
  381. env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"])
  382. env_harfbuzz.Append(
  383. CCFLAGS=[
  384. "-DU_STATIC_IMPLEMENTATION",
  385. "-DU_HAVE_LIB_SUFFIX=1",
  386. "-DU_LIB_SUFFIX_C_NAME=_godot",
  387. "-DHAVE_ICU_BUILTIN",
  388. "-DHAVE_ICU",
  389. ]
  390. )
  391. if env["freetype_enabled"]:
  392. env_harfbuzz.Append(
  393. CCFLAGS=[
  394. "-DHAVE_FREETYPE",
  395. "-DHAVE_GRAPHITE2",
  396. "-DGRAPHITE2_STATIC",
  397. ]
  398. )
  399. env.Append(CPPPATH=["../../../thirdparty/harfbuzz/src"])
  400. lib = env_harfbuzz.Library(
  401. f'harfbuzz_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
  402. thirdparty_harfbuzz_sources,
  403. )
  404. env.Prepend(LIBS=[lib])
  405. # Graphite
  406. if env["graphite_enabled"] and env["freetype_enabled"]:
  407. env_graphite = env.Clone()
  408. env_graphite.disable_warnings()
  409. thirdparty_graphite_dir = "../../../thirdparty/graphite/"
  410. thirdparty_graphite_sources = [
  411. "src/gr_char_info.cpp",
  412. "src/gr_face.cpp",
  413. "src/gr_features.cpp",
  414. "src/gr_font.cpp",
  415. "src/gr_logging.cpp",
  416. "src/gr_segment.cpp",
  417. "src/gr_slot.cpp",
  418. "src/CmapCache.cpp",
  419. "src/Code.cpp",
  420. "src/Collider.cpp",
  421. "src/Decompressor.cpp",
  422. "src/Face.cpp",
  423. #'src/FileFace.cpp',
  424. "src/FeatureMap.cpp",
  425. "src/Font.cpp",
  426. "src/GlyphCache.cpp",
  427. "src/GlyphFace.cpp",
  428. "src/Intervals.cpp",
  429. "src/Justifier.cpp",
  430. "src/NameTable.cpp",
  431. "src/Pass.cpp",
  432. "src/Position.cpp",
  433. "src/Segment.cpp",
  434. "src/Silf.cpp",
  435. "src/Slot.cpp",
  436. "src/Sparse.cpp",
  437. "src/TtfUtil.cpp",
  438. "src/UtfCodec.cpp",
  439. "src/FileFace.cpp",
  440. "src/json.cpp",
  441. ]
  442. if env["platform"] != "windows" or env["use_mingw"]:
  443. thirdparty_graphite_sources += ["src/direct_machine.cpp"]
  444. else:
  445. thirdparty_graphite_sources += ["src/call_machine.cpp"]
  446. thirdparty_graphite_sources = [thirdparty_graphite_dir + file for file in thirdparty_graphite_sources]
  447. env_graphite.Append(CPPPATH=["../../../thirdparty/graphite/src", "../../../thirdparty/graphite/include"])
  448. env_graphite.Append(
  449. CCFLAGS=[
  450. "-DGRAPHITE2_STATIC",
  451. "-DGRAPHITE2_NTRACING",
  452. "-DGRAPHITE2_NFILEFACE",
  453. ]
  454. )
  455. lib = env_graphite.Library(
  456. f'graphite_builtin{env["suffix"]}{env["LIBSUFFIX"]}',
  457. thirdparty_graphite_sources,
  458. )
  459. env.Append(LIBS=[lib])
  460. # ICU
  461. env_icu = env.Clone()
  462. env_icu.disable_warnings()
  463. thirdparty_icu_dir = "../../../thirdparty/icu4c/"
  464. thirdparty_icu_sources = [
  465. "common/appendable.cpp",
  466. "common/bmpset.cpp",
  467. "common/brkeng.cpp",
  468. "common/brkiter.cpp",
  469. "common/bytesinkutil.cpp",
  470. "common/bytestream.cpp",
  471. "common/bytestrie.cpp",
  472. "common/bytestriebuilder.cpp",
  473. "common/bytestrieiterator.cpp",
  474. "common/caniter.cpp",
  475. "common/characterproperties.cpp",
  476. "common/chariter.cpp",
  477. "common/charstr.cpp",
  478. "common/cmemory.cpp",
  479. "common/cstr.cpp",
  480. "common/cstring.cpp",
  481. "common/cwchar.cpp",
  482. "common/dictbe.cpp",
  483. "common/dictionarydata.cpp",
  484. "common/dtintrv.cpp",
  485. "common/edits.cpp",
  486. "common/emojiprops.cpp",
  487. "common/errorcode.cpp",
  488. "common/filteredbrk.cpp",
  489. "common/filterednormalizer2.cpp",
  490. "common/icudataver.cpp",
  491. "common/icuplug.cpp",
  492. "common/loadednormalizer2impl.cpp",
  493. "common/localebuilder.cpp",
  494. "common/localematcher.cpp",
  495. "common/localeprioritylist.cpp",
  496. "common/locavailable.cpp",
  497. "common/locbased.cpp",
  498. "common/locdispnames.cpp",
  499. "common/locdistance.cpp",
  500. "common/locdspnm.cpp",
  501. "common/locid.cpp",
  502. "common/loclikely.cpp",
  503. "common/loclikelysubtags.cpp",
  504. "common/locmap.cpp",
  505. "common/locresdata.cpp",
  506. "common/locutil.cpp",
  507. "common/lsr.cpp",
  508. "common/lstmbe.cpp",
  509. "common/messagepattern.cpp",
  510. "common/mlbe.cpp",
  511. "common/normalizer2.cpp",
  512. "common/normalizer2impl.cpp",
  513. "common/normlzr.cpp",
  514. "common/parsepos.cpp",
  515. "common/patternprops.cpp",
  516. "common/pluralmap.cpp",
  517. "common/propname.cpp",
  518. "common/propsvec.cpp",
  519. "common/punycode.cpp",
  520. "common/putil.cpp",
  521. "common/rbbi.cpp",
  522. "common/rbbi_cache.cpp",
  523. "common/rbbidata.cpp",
  524. "common/rbbinode.cpp",
  525. "common/rbbirb.cpp",
  526. "common/rbbiscan.cpp",
  527. "common/rbbisetb.cpp",
  528. "common/rbbistbl.cpp",
  529. "common/rbbitblb.cpp",
  530. "common/resbund.cpp",
  531. "common/resbund_cnv.cpp",
  532. "common/resource.cpp",
  533. "common/restrace.cpp",
  534. "common/ruleiter.cpp",
  535. "common/schriter.cpp",
  536. "common/serv.cpp",
  537. "common/servlk.cpp",
  538. "common/servlkf.cpp",
  539. "common/servls.cpp",
  540. "common/servnotf.cpp",
  541. "common/servrbf.cpp",
  542. "common/servslkf.cpp",
  543. "common/sharedobject.cpp",
  544. "common/simpleformatter.cpp",
  545. "common/static_unicode_sets.cpp",
  546. "common/stringpiece.cpp",
  547. "common/stringtriebuilder.cpp",
  548. "common/uarrsort.cpp",
  549. "common/ubidi.cpp",
  550. "common/ubidi_props.cpp",
  551. "common/ubidiln.cpp",
  552. "common/ubiditransform.cpp",
  553. "common/ubidiwrt.cpp",
  554. "common/ubrk.cpp",
  555. "common/ucase.cpp",
  556. "common/ucasemap.cpp",
  557. "common/ucasemap_titlecase_brkiter.cpp",
  558. "common/ucat.cpp",
  559. "common/uchar.cpp",
  560. "common/ucharstrie.cpp",
  561. "common/ucharstriebuilder.cpp",
  562. "common/ucharstrieiterator.cpp",
  563. "common/uchriter.cpp",
  564. "common/ucln_cmn.cpp",
  565. "common/ucmndata.cpp",
  566. "common/ucnv.cpp",
  567. "common/ucnv2022.cpp",
  568. "common/ucnv_bld.cpp",
  569. "common/ucnv_cb.cpp",
  570. "common/ucnv_cnv.cpp",
  571. "common/ucnv_ct.cpp",
  572. "common/ucnv_err.cpp",
  573. "common/ucnv_ext.cpp",
  574. "common/ucnv_io.cpp",
  575. "common/ucnv_lmb.cpp",
  576. "common/ucnv_set.cpp",
  577. "common/ucnv_u16.cpp",
  578. "common/ucnv_u32.cpp",
  579. "common/ucnv_u7.cpp",
  580. "common/ucnv_u8.cpp",
  581. "common/ucnvbocu.cpp",
  582. "common/ucnvdisp.cpp",
  583. "common/ucnvhz.cpp",
  584. "common/ucnvisci.cpp",
  585. "common/ucnvlat1.cpp",
  586. "common/ucnvmbcs.cpp",
  587. "common/ucnvscsu.cpp",
  588. "common/ucnvsel.cpp",
  589. "common/ucol_swp.cpp",
  590. "common/ucptrie.cpp",
  591. "common/ucurr.cpp",
  592. "common/udata.cpp",
  593. "common/udatamem.cpp",
  594. "common/udataswp.cpp",
  595. "common/uenum.cpp",
  596. "common/uhash.cpp",
  597. "common/uhash_us.cpp",
  598. "common/uidna.cpp",
  599. "common/uinit.cpp",
  600. "common/uinvchar.cpp",
  601. "common/uiter.cpp",
  602. "common/ulist.cpp",
  603. "common/uloc.cpp",
  604. "common/uloc_keytype.cpp",
  605. "common/uloc_tag.cpp",
  606. "common/ulocale.cpp",
  607. "common/ulocbuilder.cpp",
  608. "common/umapfile.cpp",
  609. "common/umath.cpp",
  610. "common/umutablecptrie.cpp",
  611. "common/umutex.cpp",
  612. "common/unames.cpp",
  613. "common/unifiedcache.cpp",
  614. "common/unifilt.cpp",
  615. "common/unifunct.cpp",
  616. "common/uniset.cpp",
  617. "common/uniset_closure.cpp",
  618. "common/uniset_props.cpp",
  619. "common/unisetspan.cpp",
  620. "common/unistr.cpp",
  621. "common/unistr_case.cpp",
  622. "common/unistr_case_locale.cpp",
  623. "common/unistr_cnv.cpp",
  624. "common/unistr_props.cpp",
  625. "common/unistr_titlecase_brkiter.cpp",
  626. "common/unorm.cpp",
  627. "common/unormcmp.cpp",
  628. "common/uobject.cpp",
  629. "common/uprops.cpp",
  630. "common/ures_cnv.cpp",
  631. "common/uresbund.cpp",
  632. "common/uresdata.cpp",
  633. "common/usc_impl.cpp",
  634. "common/uscript.cpp",
  635. "common/uscript_props.cpp",
  636. "common/uset.cpp",
  637. "common/uset_props.cpp",
  638. "common/usetiter.cpp",
  639. # "common/ushape.cpp",
  640. "common/usprep.cpp",
  641. "common/ustack.cpp",
  642. "common/ustr_cnv.cpp",
  643. "common/ustr_titlecase_brkiter.cpp",
  644. "common/ustr_wcs.cpp",
  645. "common/ustrcase.cpp",
  646. "common/ustrcase_locale.cpp",
  647. "common/ustrenum.cpp",
  648. "common/ustrfmt.cpp",
  649. "common/ustring.cpp",
  650. "common/ustrtrns.cpp",
  651. "common/utext.cpp",
  652. "common/utf_impl.cpp",
  653. "common/util.cpp",
  654. "common/util_props.cpp",
  655. "common/utrace.cpp",
  656. "common/utrie.cpp",
  657. "common/utrie2.cpp",
  658. "common/utrie2_builder.cpp",
  659. "common/utrie_swap.cpp",
  660. "common/uts46.cpp",
  661. "common/utypes.cpp",
  662. "common/uvector.cpp",
  663. "common/uvectr32.cpp",
  664. "common/uvectr64.cpp",
  665. "common/wintz.cpp",
  666. "i18n/scriptset.cpp",
  667. "i18n/ucln_in.cpp",
  668. "i18n/uspoof.cpp",
  669. "i18n/uspoof_impl.cpp",
  670. ]
  671. thirdparty_icu_sources = [thirdparty_icu_dir + file for file in thirdparty_icu_sources]
  672. icu_data_name = "icudt76l.dat"
  673. if env["static_icu_data"]:
  674. env_icu.Depends("../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/" + icu_data_name)
  675. env_icu.Command(
  676. "../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/" + icu_data_name, methods.make_icu_data
  677. )
  678. env.Append(CXXFLAGS=["-DICU_STATIC_DATA"])
  679. env.Append(CPPPATH=["../../../thirdparty/icu4c/"])
  680. else:
  681. thirdparty_icu_sources += ["../icu_data/icudata_stub.cpp"]
  682. env_icu.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])
  683. env_icu.Append(
  684. CXXFLAGS=[
  685. "-DU_STATIC_IMPLEMENTATION",
  686. "-DU_COMMON_IMPLEMENTATION",
  687. "-DUCONFIG_NO_COLLATION",
  688. "-DUCONFIG_NO_CONVERSION",
  689. "-DUCONFIG_NO_FORMATTING",
  690. "-DUCONFIG_NO_SERVICE",
  691. "-DUCONFIG_NO_IDNA",
  692. "-DUCONFIG_NO_FILE_IO",
  693. "-DUCONFIG_NO_TRANSLITERATION",
  694. "-DPKGDATA_MODE=static",
  695. "-DU_ENABLE_DYLOAD=0",
  696. "-DU_HAVE_LIB_SUFFIX=1",
  697. "-DU_LIB_SUFFIX_C_NAME=_godot",
  698. "-DICU_DATA_NAME=" + icu_data_name,
  699. ]
  700. )
  701. env.Append(
  702. CXXFLAGS=[
  703. "-DU_STATIC_IMPLEMENTATION",
  704. "-DU_HAVE_LIB_SUFFIX=1",
  705. "-DU_LIB_SUFFIX_C_NAME=_godot",
  706. "-DICU_DATA_NAME=" + icu_data_name,
  707. ]
  708. )
  709. env.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])
  710. if env["platform"] == "windows":
  711. env.Append(LIBS=["advapi32"])
  712. lib = env_icu.Library(f'icu_builtin{env["suffix"]}{env["LIBSUFFIX"]}', thirdparty_icu_sources)
  713. env.Append(LIBS=[lib])
  714. env.Append(CPPDEFINES=["GDEXTENSION"])
  715. env.Append(CPPPATH=["../"])
  716. sources = Glob("../*.cpp")
  717. if env["platform"] == "macos":
  718. methods.write_macos_plist(
  719. f'./bin/libtextserver_advanced.macos.{env["target"]}.framework',
  720. f'libtextserver_advanced.macos.{env["target"]}',
  721. "org.godotengine.textserver_advanced",
  722. "ICU / HarfBuzz / Graphite Text Server",
  723. )
  724. library = env.SharedLibrary(
  725. f'./bin/libtextserver_advanced.macos.{env["target"]}.framework/libtextserver_advanced.macos.{env["target"]}',
  726. source=sources,
  727. )
  728. else:
  729. library = env.SharedLibrary(
  730. f'./bin/libtextserver_advanced{env["suffix"]}{env["SHLIBSUFFIX"]}',
  731. source=sources,
  732. )
  733. Default(library)
  734. def print_elapsed_time():
  735. elapsed_time_sec = round(time.time() - time_at_start, 2)
  736. time_centiseconds = round((elapsed_time_sec % 1) * 100)
  737. print(
  738. "{}[Time elapsed: {}.{:02}]{}".format(
  739. methods.ANSI.GRAY,
  740. time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)),
  741. time_centiseconds,
  742. methods.ANSI.RESET,
  743. )
  744. )
  745. atexit.register(print_elapsed_time)