1
0

uv.gyp 16 KB

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