1
0

uv.gyp 16 KB

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