__init__.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. from devtools.yamaker import fileutil
  2. from devtools.yamaker import pathutil
  3. from devtools.yamaker.platform_macros import make_llvm_nixattr
  4. from devtools.yamaker.modules import Library
  5. from devtools.yamaker.project import NixSourceProject
  6. def post_install(self):
  7. # libcxxabi-parts is built from libcxxabi sources
  8. # Update VERSION and ORIGINAL_SOURCE values upon libcxxabi update.
  9. fileutil.re_sub_file(
  10. f"{self.ctx.arc}/contrib/libs/cxxsupp/libcxxabi-parts/ya.make",
  11. r"ORIGINAL_SOURCE\(.*\)",
  12. f"ORIGINAL_SOURCE({self.source_url})",
  13. )
  14. fileutil.re_sub_file(
  15. f"{self.ctx.arc}/contrib/libs/cxxsupp/libcxxabi-parts/ya.make",
  16. r"VERSION\(.*\)",
  17. f"VERSION({self.version})",
  18. )
  19. self.yamakes["."] = self.module(
  20. Library,
  21. NO_UTIL=True,
  22. NO_RUNTIME=True,
  23. NO_COMPILER_WARNINGS=True,
  24. # Files are distributed between libcxxabi and libcxx in a weird manner
  25. # but we can not peerdir the latter to avoid loops (see below)
  26. # FIXME: sort includes open moving glibcxx-shims into its own dir
  27. SRCS=fileutil.files(self.dstdir, rel=True, test=pathutil.is_source),
  28. ADDINCL=[
  29. f"{self.arcdir}/include",
  30. "contrib/libs/cxxsupp/libcxx/include",
  31. # libcxxabi includes libcxx's private "include/refstring.h" header from src subdirectory
  32. "contrib/libs/cxxsupp/libcxx/src",
  33. ],
  34. PEERDIR=[
  35. "contrib/libs/libunwind",
  36. ],
  37. CFLAGS=[
  38. "-D_LIBCPP_BUILDING_LIBRARY",
  39. "-D_LIBCXXABI_BUILDING_LIBRARY",
  40. ],
  41. )
  42. with self.yamakes["."] as libcxxabi:
  43. # As of 1.2.3, musl libc does not provide __cxa_thread_atexit_impl
  44. libcxxabi.after(
  45. "SRCS",
  46. """
  47. IF (NOT MUSL)
  48. CFLAGS(
  49. -DHAVE___CXA_THREAD_ATEXIT_IMPL
  50. )
  51. ENDIF()
  52. """,
  53. )
  54. libcxxabi.after(
  55. "SRCS",
  56. """
  57. IF (OS_EMSCRIPTEN AND ARCH_WASM64)
  58. CFLAGS(
  59. -D_LIBCPP_SAFE_STATIC=
  60. -D_LIBCXXABI_DTOR_FUNC=
  61. -D__WASM_EXCEPTIONS__
  62. )
  63. ELSEIF (OS_EMSCRIPTEN AND ARCH_WASM32)
  64. CFLAGS(
  65. -D_LIBCPP_SAFE_STATIC=
  66. -D_LIBCXXABI_DTOR_FUNC=
  67. -D__WASM_EXCEPTIONS__
  68. )
  69. ENDIF()
  70. """,
  71. )
  72. libcxxabi.PEERDIR.add("library/cpp/sanitizer/include")
  73. libcxxabi = NixSourceProject(
  74. owners=["g:cpp-committee", "g:cpp-contrib"],
  75. arcdir="contrib/libs/cxxsupp/libcxxabi",
  76. # nixos-24.05 merged libcxx and libcxxabi.
  77. # Use the primer and override sourceRoot in override.nix as aworkaround.
  78. nixattr=make_llvm_nixattr("libcxx"),
  79. copy_sources=[
  80. "include/__cxxabi_config.h",
  81. "include/cxxabi.h",
  82. "src/*.cpp",
  83. "src/*.h",
  84. "src/demangle/*.cpp",
  85. "src/demangle/*.def",
  86. "src/demangle/*.h",
  87. ],
  88. copy_sources_except=[
  89. # fake exception implementation which just invokes std::terminate
  90. "src/cxa_noexception.cpp",
  91. ],
  92. disable_includes=[
  93. "aix_state_tab_eh.inc",
  94. "ptrauth.h",
  95. "sys/futex.h",
  96. ],
  97. post_install=post_install,
  98. )