__init__.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import os
  2. import os.path
  3. import shutil
  4. from devtools.yamaker.modules import Linkable, Switch
  5. from devtools.yamaker.project import GNUMakeNixProject
  6. def libevent_post_install(self):
  7. own_compat = os.path.join(self.arcdir, "compat")
  8. for p, m in self.yamakes.items():
  9. if own_compat in m.ADDINCL:
  10. m.ADDINCL.remove(own_compat)
  11. m.PEERDIR.add("contrib/libs/libc_compat")
  12. m.CFLAGS.append("-DEVENT__HAVE_STRLCPY=1")
  13. shutil.rmtree(os.path.join(self.dstdir, "compat"))
  14. os.remove(os.path.join(self.dstdir, "strlcpy.c"))
  15. with self.yamakes["event_core"] as m:
  16. m.SRCS -= {"epoll.c", "poll.c", "select.c", "strlcpy.c"}
  17. m.after(
  18. "SRCS",
  19. Switch(
  20. OS_WINDOWS=Linkable(
  21. SRCS=[
  22. "buffer_iocp.c",
  23. "bufferevent_async.c",
  24. "event_iocp.c",
  25. "win32select.c",
  26. ],
  27. ),
  28. default=Linkable(
  29. SRCS=[
  30. "poll.c",
  31. "select.c",
  32. ],
  33. ),
  34. ),
  35. )
  36. m.after(
  37. "SRCS",
  38. Switch(
  39. OS_LINUX=Linkable(
  40. SRCS=["epoll.c"],
  41. )
  42. ),
  43. )
  44. m.after(
  45. "SRCS",
  46. Switch(
  47. {
  48. "OS_FREEBSD OR OS_DARWIN": Linkable(
  49. SRCS=["kqueue.c"],
  50. )
  51. }
  52. ),
  53. )
  54. with self.yamakes["event_thread"] as m:
  55. orig_srcs = m.SRCS
  56. m.SRCS = {}
  57. m.after(
  58. "SRCS",
  59. Switch(
  60. OS_WINDOWS=Linkable(
  61. SRCS=["evthread_win32.c"],
  62. ),
  63. default=Linkable(SRCS=orig_srcs),
  64. ),
  65. )
  66. with self.yamakes["."] as m:
  67. m.SRCS = {}
  68. m.PEERDIR = [
  69. os.path.join(self.arcdir, p)
  70. for p in (
  71. "event_core",
  72. "event_extra",
  73. "event_openssl",
  74. "event_thread",
  75. )
  76. ]
  77. libevent = GNUMakeNixProject(
  78. owners=["g:cpp-contrib", "dldmitry"],
  79. arcdir="contrib/libs/libevent",
  80. nixattr="libevent",
  81. ignore_commands=["bash", "sed"],
  82. license="BSD-3-Clause",
  83. copy_sources=[
  84. "include/**/*.h",
  85. "*.c",
  86. "*.h",
  87. "whatsnew-2.0.txt",
  88. ],
  89. put={
  90. "event-2.1": ".",
  91. "event_core-2.1": "event_core",
  92. "event_extra-2.1": "event_extra",
  93. "event_pthreads-2.1": "event_thread",
  94. "event_openssl-2.1": "event_openssl",
  95. },
  96. ignore_targets={
  97. "bench",
  98. "bench_cascade",
  99. "bench_http",
  100. "bench_httpclient",
  101. "dns-example",
  102. "event-read-fifo",
  103. "hello-world",
  104. "http-connect",
  105. "http-server",
  106. "https-client",
  107. "le-proxy",
  108. "regress",
  109. "signal-test",
  110. "test-changelist",
  111. "test-closed",
  112. "test-dumpevents",
  113. "test-eof",
  114. "test-fdleak",
  115. "test-init",
  116. "test-ratelim",
  117. "test-time",
  118. "test-weof",
  119. "time-test",
  120. },
  121. platform_dispatchers=["include/event2/event-config.h"],
  122. addincl_global={".": {"./include"}},
  123. post_install=libevent_post_install,
  124. disable_includes=["afunix.h", "netinet/in6.h", "vproc.h"],
  125. )