1
0

uv.gyp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. {
  2. 'variables': {
  3. 'uv_use_dtrace%': 'false',
  4. # uv_parent_path is the relative path to libuv in the parent project
  5. # this is only relevant when dtrace is enabled and libuv is a child project
  6. # as it's necessary to correctly locate the object files for post
  7. # processing.
  8. 'uv_parent_path': '',
  9. },
  10. 'target_defaults': {
  11. 'conditions': [
  12. ['OS != "win"', {
  13. 'defines': [
  14. '_LARGEFILE_SOURCE',
  15. '_FILE_OFFSET_BITS=64',
  16. '_GNU_SOURCE',
  17. ],
  18. 'conditions': [
  19. ['OS=="solaris"', {
  20. 'cflags': [ '-pthreads' ],
  21. }, {
  22. 'cflags': [ '-pthread' ],
  23. }],
  24. ],
  25. }],
  26. ],
  27. },
  28. 'targets': [
  29. {
  30. 'target_name': 'libuv',
  31. 'type': '<(library)',
  32. 'include_dirs': [
  33. 'include',
  34. 'include/uv-private',
  35. 'src/',
  36. ],
  37. 'direct_dependent_settings': {
  38. 'include_dirs': [ 'include' ],
  39. 'conditions': [
  40. ['OS != "win"', {
  41. 'defines': [
  42. '_LARGEFILE_SOURCE',
  43. '_FILE_OFFSET_BITS=64',
  44. ],
  45. }],
  46. ['OS == "mac"', {
  47. 'defines': [ '_DARWIN_USE_64_BIT_INODE=1' ],
  48. }],
  49. ['OS == "linux"', {
  50. 'defines': [ '_POSIX_C_SOURCE=200112' ],
  51. }],
  52. ],
  53. },
  54. 'defines': [
  55. 'HAVE_CONFIG_H'
  56. ],
  57. 'sources': [
  58. 'common.gypi',
  59. 'include/uv.h',
  60. 'include/uv-private/ngx-queue.h',
  61. 'include/uv-private/tree.h',
  62. 'src/fs-poll.c',
  63. 'src/inet.c',
  64. 'src/uv-common.c',
  65. 'src/uv-common.h',
  66. 'src/version.c'
  67. ],
  68. 'conditions': [
  69. [ 'OS=="win"', {
  70. 'defines': [
  71. '_WIN32_WINNT=0x0600',
  72. '_GNU_SOURCE',
  73. ],
  74. 'sources': [
  75. 'include/uv-private/uv-win.h',
  76. 'src/win/async.c',
  77. 'src/win/atomicops-inl.h',
  78. 'src/win/core.c',
  79. 'src/win/dl.c',
  80. 'src/win/error.c',
  81. 'src/win/fs.c',
  82. 'src/win/fs-event.c',
  83. 'src/win/getaddrinfo.c',
  84. 'src/win/handle.c',
  85. 'src/win/handle-inl.h',
  86. 'src/win/internal.h',
  87. 'src/win/loop-watcher.c',
  88. 'src/win/pipe.c',
  89. 'src/win/thread.c',
  90. 'src/win/poll.c',
  91. 'src/win/process.c',
  92. 'src/win/process-stdio.c',
  93. 'src/win/req.c',
  94. 'src/win/req-inl.h',
  95. 'src/win/signal.c',
  96. 'src/win/stream.c',
  97. 'src/win/stream-inl.h',
  98. 'src/win/tcp.c',
  99. 'src/win/tty.c',
  100. 'src/win/threadpool.c',
  101. 'src/win/timer.c',
  102. 'src/win/udp.c',
  103. 'src/win/util.c',
  104. 'src/win/winapi.c',
  105. 'src/win/winapi.h',
  106. 'src/win/winsock.c',
  107. 'src/win/winsock.h',
  108. ],
  109. 'link_settings': {
  110. 'libraries': [
  111. '-ladvapi32.lib',
  112. '-liphlpapi.lib',
  113. '-lpsapi.lib',
  114. '-lshell32.lib',
  115. '-lws2_32.lib'
  116. ],
  117. },
  118. }, { # Not Windows i.e. POSIX
  119. 'cflags': [
  120. '-g',
  121. '--std=gnu89',
  122. '-pedantic',
  123. '-Wall',
  124. '-Wextra',
  125. '-Wno-unused-parameter',
  126. ],
  127. 'sources': [
  128. 'include/uv-private/uv-unix.h',
  129. 'include/uv-private/uv-linux.h',
  130. 'include/uv-private/uv-sunos.h',
  131. 'include/uv-private/uv-darwin.h',
  132. 'include/uv-private/uv-bsd.h',
  133. 'src/unix/async.c',
  134. 'src/unix/core.c',
  135. 'src/unix/dl.c',
  136. 'src/unix/error.c',
  137. 'src/unix/fs.c',
  138. 'src/unix/getaddrinfo.c',
  139. 'src/unix/internal.h',
  140. 'src/unix/loop.c',
  141. 'src/unix/loop-watcher.c',
  142. 'src/unix/pipe.c',
  143. 'src/unix/poll.c',
  144. 'src/unix/process.c',
  145. 'src/unix/signal.c',
  146. 'src/unix/stream.c',
  147. 'src/unix/tcp.c',
  148. 'src/unix/thread.c',
  149. 'src/unix/threadpool.c',
  150. 'src/unix/timer.c',
  151. 'src/unix/tty.c',
  152. 'src/unix/udp.c',
  153. ],
  154. 'link_settings': {
  155. 'libraries': [ '-lm' ],
  156. 'conditions': [
  157. ['OS=="solaris"', {
  158. 'ldflags': [ '-pthreads' ],
  159. }, {
  160. 'ldflags': [ '-pthread' ],
  161. }],
  162. ],
  163. },
  164. 'conditions': [
  165. ['library=="shared_library"', {
  166. 'cflags': [ '-fPIC' ],
  167. }],
  168. ['library=="shared_library" and OS!="mac"', {
  169. 'link_settings': {
  170. # Must correspond with UV_VERSION_MAJOR and UV_VERSION_MINOR
  171. # in src/version.c
  172. 'libraries': [ '-Wl,-soname,libuv.so.0.10' ],
  173. },
  174. }],
  175. ],
  176. }],
  177. [ 'OS=="linux" or OS=="mac"', {
  178. 'sources': [ 'src/unix/proctitle.c' ],
  179. }],
  180. [ 'OS=="mac"', {
  181. 'sources': [
  182. 'src/unix/darwin.c',
  183. 'src/unix/fsevents.c',
  184. 'src/unix/darwin-proctitle.c',
  185. ],
  186. 'link_settings': {
  187. 'libraries': [
  188. '$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
  189. '$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
  190. '$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
  191. ],
  192. },
  193. 'defines': [
  194. '_DARWIN_USE_64_BIT_INODE=1',
  195. ]
  196. }],
  197. [ 'OS!="mac"', {
  198. # Enable on all platforms except OS X. The antique gcc/clang that
  199. # ships with Xcode emits waaaay too many false positives.
  200. 'cflags': [ '-Wstrict-aliasing' ],
  201. }],
  202. [ 'OS=="linux"', {
  203. 'sources': [
  204. 'src/unix/linux-core.c',
  205. 'src/unix/linux-inotify.c',
  206. 'src/unix/linux-syscalls.c',
  207. 'src/unix/linux-syscalls.h',
  208. ],
  209. 'link_settings': {
  210. 'libraries': [ '-ldl', '-lrt' ],
  211. },
  212. }],
  213. [ 'OS=="solaris"', {
  214. 'sources': [ 'src/unix/sunos.c' ],
  215. 'defines': [
  216. '__EXTENSIONS__',
  217. '_XOPEN_SOURCE=500',
  218. ],
  219. 'link_settings': {
  220. 'libraries': [
  221. '-lkstat',
  222. '-lnsl',
  223. '-lsendfile',
  224. '-lsocket',
  225. ],
  226. },
  227. }],
  228. [ 'OS=="aix"', {
  229. 'include_dirs': [ 'src/ares/config_aix' ],
  230. 'sources': [ 'src/unix/aix.c' ],
  231. 'defines': [
  232. '_ALL_SOURCE',
  233. '_XOPEN_SOURCE=500',
  234. ],
  235. 'link_settings': {
  236. 'libraries': [
  237. '-lperfstat',
  238. ],
  239. },
  240. }],
  241. [ 'OS=="freebsd" or OS=="dragonflybsd"', {
  242. 'sources': [ 'src/unix/freebsd.c' ],
  243. }],
  244. [ 'OS=="openbsd"', {
  245. 'sources': [ 'src/unix/openbsd.c' ],
  246. }],
  247. [ 'OS=="netbsd"', {
  248. 'sources': [ 'src/unix/netbsd.c' ],
  249. }],
  250. [ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', {
  251. 'link_settings': {
  252. 'libraries': [ '-lkvm' ],
  253. },
  254. }],
  255. [ 'OS in "mac freebsd dragonflybsd openbsd netbsd".split()', {
  256. 'sources': [ 'src/unix/kqueue.c' ],
  257. }],
  258. ['library=="shared_library"', {
  259. 'defines': [ 'BUILDING_UV_SHARED=1' ]
  260. }],
  261. ['uv_use_dtrace=="true"', {
  262. 'defines': [ 'HAVE_DTRACE=1' ],
  263. 'dependencies': [ 'uv_dtrace_header' ],
  264. 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
  265. 'conditions': [
  266. ['OS != "mac"', {
  267. 'sources': ['src/unix/dtrace.c' ],
  268. }],
  269. ],
  270. }],
  271. ]
  272. },
  273. {
  274. 'target_name': 'run-tests',
  275. 'type': 'executable',
  276. 'dependencies': [ 'libuv' ],
  277. 'sources': [
  278. 'test/blackhole-server.c',
  279. 'test/echo-server.c',
  280. 'test/run-tests.c',
  281. 'test/runner.c',
  282. 'test/runner.h',
  283. 'test/test-get-loadavg.c',
  284. 'test/task.h',
  285. 'test/test-util.c',
  286. 'test/test-active.c',
  287. 'test/test-async.c',
  288. 'test/test-callback-stack.c',
  289. 'test/test-callback-order.c',
  290. 'test/test-connection-fail.c',
  291. 'test/test-cwd-and-chdir.c',
  292. 'test/test-delayed-accept.c',
  293. 'test/test-error.c',
  294. 'test/test-embed.c',
  295. 'test/test-fail-always.c',
  296. 'test/test-fs.c',
  297. 'test/test-fs-event.c',
  298. 'test/test-get-currentexe.c',
  299. 'test/test-get-memory.c',
  300. 'test/test-getaddrinfo.c',
  301. 'test/test-getsockname.c',
  302. 'test/test-hrtime.c',
  303. 'test/test-idle.c',
  304. 'test/test-ipc.c',
  305. 'test/test-ipc-send-recv.c',
  306. 'test/test-list.h',
  307. 'test/test-loop-handles.c',
  308. 'test/test-loop-stop.c',
  309. 'test/test-walk-handles.c',
  310. 'test/test-multiple-listen.c',
  311. 'test/test-osx-select.c',
  312. 'test/test-pass-always.c',
  313. 'test/test-ping-pong.c',
  314. 'test/test-pipe-bind-error.c',
  315. 'test/test-pipe-connect-error.c',
  316. 'test/test-platform-output.c',
  317. 'test/test-poll.c',
  318. 'test/test-poll-close.c',
  319. 'test/test-process-title.c',
  320. 'test/test-ref.c',
  321. 'test/test-run-nowait.c',
  322. 'test/test-run-once.c',
  323. 'test/test-semaphore.c',
  324. 'test/test-shutdown-close.c',
  325. 'test/test-shutdown-eof.c',
  326. 'test/test-signal.c',
  327. 'test/test-signal-multiple-loops.c',
  328. 'test/test-spawn.c',
  329. 'test/test-fs-poll.c',
  330. 'test/test-stdio-over-pipes.c',
  331. 'test/test-tcp-bind-error.c',
  332. 'test/test-tcp-bind6-error.c',
  333. 'test/test-tcp-close.c',
  334. 'test/test-tcp-close-while-connecting.c',
  335. 'test/test-tcp-connect-error-after-write.c',
  336. 'test/test-tcp-shutdown-after-write.c',
  337. 'test/test-tcp-flags.c',
  338. 'test/test-tcp-connect-error.c',
  339. 'test/test-tcp-connect-timeout.c',
  340. 'test/test-tcp-connect6-error.c',
  341. 'test/test-tcp-open.c',
  342. 'test/test-tcp-write-to-half-open-connection.c',
  343. 'test/test-tcp-writealot.c',
  344. 'test/test-tcp-unexpected-read.c',
  345. 'test/test-tcp-read-stop.c',
  346. 'test/test-threadpool.c',
  347. 'test/test-threadpool-cancel.c',
  348. 'test/test-mutexes.c',
  349. 'test/test-thread.c',
  350. 'test/test-barrier.c',
  351. 'test/test-condvar.c',
  352. 'test/test-timer-again.c',
  353. 'test/test-timer.c',
  354. 'test/test-tty.c',
  355. 'test/test-udp-dgram-too-big.c',
  356. 'test/test-udp-ipv6.c',
  357. 'test/test-udp-open.c',
  358. 'test/test-udp-options.c',
  359. 'test/test-udp-send-and-recv.c',
  360. 'test/test-udp-multicast-join.c',
  361. 'test/test-dlerror.c',
  362. 'test/test-udp-multicast-ttl.c',
  363. ],
  364. 'conditions': [
  365. [ 'OS=="win"', {
  366. 'sources': [
  367. 'test/runner-win.c',
  368. 'test/runner-win.h'
  369. ],
  370. 'libraries': [ 'ws2_32.lib' ]
  371. }, { # POSIX
  372. 'defines': [ '_GNU_SOURCE' ],
  373. 'sources': [
  374. 'test/runner-unix.c',
  375. 'test/runner-unix.h',
  376. ],
  377. }],
  378. [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE
  379. 'defines': [
  380. '__EXTENSIONS__',
  381. '_XOPEN_SOURCE=500',
  382. ],
  383. }],
  384. [ 'OS=="aix"', { # make test-fs.c compile, needs _POSIX_C_SOURCE
  385. 'defines': [
  386. '_ALL_SOURCE',
  387. '_XOPEN_SOURCE=500',
  388. ],
  389. }],
  390. ],
  391. 'msvs-settings': {
  392. 'VCLinkerTool': {
  393. 'SubSystem': 1, # /subsystem:console
  394. },
  395. },
  396. },
  397. {
  398. 'target_name': 'run-benchmarks',
  399. 'type': 'executable',
  400. 'dependencies': [ 'libuv' ],
  401. 'sources': [
  402. 'test/benchmark-async.c',
  403. 'test/benchmark-async-pummel.c',
  404. 'test/benchmark-fs-stat.c',
  405. 'test/benchmark-getaddrinfo.c',
  406. 'test/benchmark-list.h',
  407. 'test/benchmark-loop-count.c',
  408. 'test/benchmark-million-async.c',
  409. 'test/benchmark-million-timers.c',
  410. 'test/benchmark-multi-accept.c',
  411. 'test/benchmark-ping-pongs.c',
  412. 'test/benchmark-pound.c',
  413. 'test/benchmark-pump.c',
  414. 'test/benchmark-sizes.c',
  415. 'test/benchmark-spawn.c',
  416. 'test/benchmark-thread.c',
  417. 'test/benchmark-tcp-write-batch.c',
  418. 'test/benchmark-udp-pummel.c',
  419. 'test/dns-server.c',
  420. 'test/echo-server.c',
  421. 'test/blackhole-server.c',
  422. 'test/run-benchmarks.c',
  423. 'test/runner.c',
  424. 'test/runner.h',
  425. 'test/task.h',
  426. ],
  427. 'conditions': [
  428. [ 'OS=="win"', {
  429. 'sources': [
  430. 'test/runner-win.c',
  431. 'test/runner-win.h',
  432. ],
  433. 'libraries': [ 'ws2_32.lib' ]
  434. }, { # POSIX
  435. 'defines': [ '_GNU_SOURCE' ],
  436. 'sources': [
  437. 'test/runner-unix.c',
  438. 'test/runner-unix.h',
  439. ]
  440. }]
  441. ],
  442. 'msvs-settings': {
  443. 'VCLinkerTool': {
  444. 'SubSystem': 1, # /subsystem:console
  445. },
  446. },
  447. },
  448. {
  449. 'target_name': 'uv_dtrace_header',
  450. 'type': 'none',
  451. 'conditions': [
  452. [ 'uv_use_dtrace=="true"', {
  453. 'actions': [
  454. {
  455. 'action_name': 'uv_dtrace_header',
  456. 'inputs': [ 'src/unix/uv-dtrace.d' ],
  457. 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/uv-dtrace.h' ],
  458. 'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
  459. '-o', '<@(_outputs)' ],
  460. },
  461. ],
  462. }],
  463. ],
  464. },
  465. {
  466. 'target_name': 'uv_dtrace_provider',
  467. 'type': 'none',
  468. 'conditions': [
  469. [ 'uv_use_dtrace=="true" and OS!="mac"', {
  470. 'actions': [
  471. {
  472. 'action_name': 'uv_dtrace_o',
  473. 'inputs': [
  474. 'src/unix/uv-dtrace.d',
  475. '<(PRODUCT_DIR)/obj.target/libuv/<(uv_parent_path)/src/unix/core.o',
  476. ],
  477. 'outputs': [
  478. '<(PRODUCT_DIR)/obj.target/libuv/<(uv_parent_path)/src/unix/dtrace.o',
  479. ],
  480. 'action': [ 'dtrace', '-G', '-xnolibs', '-s', '<@(_inputs)',
  481. '-o', '<@(_outputs)' ]
  482. }
  483. ]
  484. } ]
  485. ]
  486. },
  487. ]
  488. }