1
0

libuv.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. module.exports = (builder, js) => {
  2. var files = [
  3. 'include/uv.h',
  4. 'include/tree.h',
  5. 'include/uv-errno.h',
  6. 'src/fs-poll.c',
  7. 'src/inet.c',
  8. 'src/queue.h',
  9. 'src/uv-common.c',
  10. 'src/uv-common.h',
  11. 'src/version.c'
  12. ];
  13. var cflags = ['-DHAVE_CONFIG_H'];
  14. // Normally this is built using -std=gnu89 but we're building everything
  15. // with -std=c99 so adding _GNU_SOURCE fixes this issue.
  16. cflags.push('-D_GNU_SOURCE');
  17. if (builder.config.systemName === 'win32') {
  18. cflags.push(
  19. '-D_WIN32_WINNT=0x0600',
  20. '-D_GNU_SOURCE',
  21. )
  22. files.push(
  23. 'include/uv-win.h',
  24. 'src/win/async.c',
  25. 'src/win/atomicops-inl.h',
  26. 'src/win/core.c',
  27. 'src/win/dl.c',
  28. 'src/win/error.c',
  29. 'src/win/fs.c',
  30. 'src/win/fs-event.c',
  31. 'src/win/getaddrinfo.c',
  32. 'src/win/handle.c',
  33. 'src/win/handle-inl.h',
  34. 'src/win/internal.h',
  35. 'src/win/iocp.c',
  36. 'src/win/loop-watcher.c',
  37. 'src/win/pipe.c',
  38. 'src/win/thread.c',
  39. 'src/win/poll.c',
  40. 'src/win/process.c',
  41. 'src/win/process-stdio.c',
  42. 'src/win/req.c',
  43. 'src/win/req-inl.h',
  44. 'src/win/signal.c',
  45. 'src/win/stream.c',
  46. 'src/win/stream-inl.h',
  47. 'src/win/tcp.c',
  48. 'src/win/tty.c',
  49. 'src/win/threadpool.c',
  50. 'src/win/timer.c',
  51. 'src/win/udp.c',
  52. 'src/win/util.c',
  53. 'src/win/winapi.c',
  54. 'src/win/winapi.h',
  55. 'src/win/winsock.c',
  56. 'src/win/winsock.h',
  57. );
  58. } else {
  59. cflags.push(
  60. '-D_LARGEFILE_SOURCE',
  61. '-D_FILE_OFFSET_BITS=64',
  62. );
  63. files.push(
  64. 'include/uv-unix.h',
  65. 'include/uv-linux.h',
  66. 'include/uv-sunos.h',
  67. 'include/uv-darwin.h',
  68. 'include/uv-bsd.h',
  69. 'src/unix/async.c',
  70. 'src/unix/atomic-ops.h',
  71. 'src/unix/core.c',
  72. 'src/unix/dl.c',
  73. 'src/unix/fs.c',
  74. 'src/unix/getaddrinfo.c',
  75. 'src/unix/internal.h',
  76. 'src/unix/loop.c',
  77. 'src/unix/loop-watcher.c',
  78. 'src/unix/pipe.c',
  79. 'src/unix/poll.c',
  80. 'src/unix/process.c',
  81. 'src/unix/signal.c',
  82. 'src/unix/spinlock.h',
  83. 'src/unix/stream.c',
  84. 'src/unix/tcp.c',
  85. 'src/unix/thread.c',
  86. 'src/unix/threadpool.c',
  87. 'src/unix/timer.c',
  88. 'src/unix/tty.c',
  89. 'src/unix/udp.c',
  90. )
  91. }
  92. var android = /android/i.test(builder.config.gcc);
  93. if (['linux','darwin'].indexOf(builder.config.systemName)) {
  94. files.push('src/unix/proctitle.c');
  95. }
  96. if (builder.config.systemName === 'darwin') {
  97. cflags.push('-D_DARWIN_USE_64_BIT_INODE=1');
  98. files.push(
  99. 'src/unix/darwin.c',
  100. 'src/unix/fsevents.c',
  101. 'src/unix/darwin-proctitle.c',
  102. );
  103. }
  104. if (builder.config.systemName === 'linux') {
  105. cflags.push('-D_POSIX_C_SOURCE=200112');
  106. files.push(
  107. 'src/unix/linux-core.c',
  108. 'src/unix/linux-inotify.c',
  109. 'src/unix/linux-syscalls.c',
  110. 'src/unix/linux-syscalls.h',
  111. );
  112. if (android) {
  113. files.push('src/unix/pthread-fixes.c');
  114. }
  115. }
  116. switch (builder.config.systemName) {
  117. case 'sunos': files.push('src/unix/sunos.c'); break;
  118. case 'dragonflybsd':
  119. case 'freebsd': files.push('src/unix/freebsd.c'); break;
  120. case 'openbsd': files.push('src/unix/openbsd.c'); break;
  121. case 'netbsd': files.push('src/unix/netbsd.c'); break;
  122. }
  123. if (['darwin', 'freebsd', 'dragonflybsd', 'openbsd', 'netbsd'].indexOf(builder.config.systemName) > -1) {
  124. files.push('src/unix/kqueue.c');
  125. }
  126. for (f of files) {
  127. if (f.endsWith(".c")) {
  128. console.log("DEPENDENCY " + f);
  129. const file = "node_build/dependencies/libuv/" + f;
  130. js.linkerDependency(file);
  131. builder.fileCflags[file] = builder.fileCflags[file] || [];
  132. builder.fileCflags[file].push(...cflags);
  133. }
  134. }
  135. }