ffi 1.10.0 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (332) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +165 -0
  3. data/Gemfile +6 -4
  4. data/README.md +38 -18
  5. data/Rakefile +36 -120
  6. data/ext/ffi_c/AbstractMemory.c +29 -34
  7. data/ext/ffi_c/Buffer.c +4 -9
  8. data/ext/ffi_c/Call.c +16 -48
  9. data/ext/ffi_c/Call.h +4 -7
  10. data/ext/ffi_c/ClosurePool.c +75 -25
  11. data/ext/ffi_c/ClosurePool.h +3 -1
  12. data/ext/ffi_c/DynamicLibrary.c +2 -7
  13. data/ext/ffi_c/Function.c +25 -129
  14. data/ext/ffi_c/FunctionInfo.c +3 -8
  15. data/ext/ffi_c/LastError.c +2 -6
  16. data/ext/ffi_c/LongDouble.c +12 -10
  17. data/ext/ffi_c/LongDouble.h +0 -4
  18. data/ext/ffi_c/MemoryPointer.c +3 -8
  19. data/ext/ffi_c/MethodHandle.c +21 -31
  20. data/ext/ffi_c/MethodHandle.h +3 -2
  21. data/ext/ffi_c/Platform.c +3 -54
  22. data/ext/ffi_c/Pointer.c +25 -26
  23. data/ext/ffi_c/Struct.c +49 -56
  24. data/ext/ffi_c/Struct.h +12 -6
  25. data/ext/ffi_c/StructByValue.c +2 -7
  26. data/ext/ffi_c/StructLayout.c +22 -19
  27. data/ext/ffi_c/Thread.c +4 -228
  28. data/ext/ffi_c/Thread.h +1 -20
  29. data/ext/ffi_c/Type.c +1 -19
  30. data/ext/ffi_c/Type.h +0 -1
  31. data/ext/ffi_c/Types.c +1 -1
  32. data/ext/ffi_c/Variadic.c +11 -22
  33. data/ext/ffi_c/compat.h +4 -0
  34. data/ext/ffi_c/extconf.rb +53 -30
  35. data/ext/ffi_c/ffi.c +3 -8
  36. data/ext/ffi_c/libffi.darwin.mk +1 -1
  37. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  38. data/ext/ffi_c/libffi/.gitattributes +4 -0
  39. data/ext/ffi_c/libffi/.travis.yml +51 -2
  40. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  41. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  42. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  43. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  44. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  45. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  46. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  47. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  48. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  49. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  50. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  51. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  52. data/ext/ffi_c/libffi/LICENSE +1 -1
  53. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  54. data/ext/ffi_c/libffi/Makefile.am +56 -72
  55. data/ext/ffi_c/libffi/README.md +33 -8
  56. data/ext/ffi_c/libffi/config.guess +552 -331
  57. data/ext/ffi_c/libffi/config.sub +1321 -1306
  58. data/ext/ffi_c/libffi/configure.ac +37 -12
  59. data/ext/ffi_c/libffi/configure.host +56 -27
  60. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  61. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  62. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  63. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  64. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  65. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  66. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  67. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  68. data/ext/ffi_c/libffi/libtool-version +1 -1
  69. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  70. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  71. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  72. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  73. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  74. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  75. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  76. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  77. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  78. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  79. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  80. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  81. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  82. data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
  83. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  84. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  85. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  86. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  89. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  90. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  91. data/ext/ffi_c/libffi/src/closures.c +69 -14
  92. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  93. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  94. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  95. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  96. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  97. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  98. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  99. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  100. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  101. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  102. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  103. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  104. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  105. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  106. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  107. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  108. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  109. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  110. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  111. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  112. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  113. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  114. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  115. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  116. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  117. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  118. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  119. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  120. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  121. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  122. data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
  123. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  124. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  125. data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
  126. data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
  127. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  128. data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
  129. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  130. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  131. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  132. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  133. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  134. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  135. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  136. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  139. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  140. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  141. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  142. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  143. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  219. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  220. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  221. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  222. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  223. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  224. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  225. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  226. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  227. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  228. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  229. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  230. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  231. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  232. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  233. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  234. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  235. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  236. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  237. data/ext/ffi_c/rbffi.h +0 -2
  238. data/ffi.gemspec +13 -6
  239. data/lib/ffi.rb +10 -2
  240. data/lib/ffi/abstract_memory.rb +44 -0
  241. data/lib/ffi/autopointer.rb +1 -1
  242. data/lib/ffi/data_converter.rb +67 -0
  243. data/lib/ffi/ffi.rb +3 -0
  244. data/lib/ffi/io.rb +3 -3
  245. data/lib/ffi/library.rb +11 -7
  246. data/lib/ffi/managedstruct.rb +2 -2
  247. data/lib/ffi/platform.rb +27 -9
  248. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  249. data/lib/ffi/platform/aarch64-freebsd/types.conf +89 -89
  250. data/lib/ffi/platform/aarch64-freebsd12/types.conf +89 -89
  251. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  252. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  253. data/lib/ffi/platform/arm-freebsd/types.conf +87 -87
  254. data/lib/ffi/platform/arm-freebsd12/types.conf +87 -87
  255. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  256. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  257. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  258. data/lib/ffi/platform/i386-freebsd/types.conf +87 -87
  259. data/lib/ffi/platform/i386-freebsd12/types.conf +87 -87
  260. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  261. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  262. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  263. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  264. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  265. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  266. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  267. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  268. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  269. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  270. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  271. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  272. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  273. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  274. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  275. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  276. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  277. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  278. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  279. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  280. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  281. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  282. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  283. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  284. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  285. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  286. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  287. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  288. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  289. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  290. data/lib/ffi/platform/x86_64-freebsd/types.conf +89 -89
  291. data/lib/ffi/platform/x86_64-freebsd12/types.conf +139 -109
  292. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  293. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  294. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  295. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  296. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  297. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  298. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  299. data/lib/ffi/pointer.rb +22 -15
  300. data/lib/ffi/struct.rb +13 -68
  301. data/lib/ffi/struct_by_reference.rb +72 -0
  302. data/lib/ffi/struct_layout.rb +96 -0
  303. data/lib/ffi/tools/const_generator.rb +5 -4
  304. data/lib/ffi/tools/generator.rb +47 -2
  305. data/lib/ffi/tools/generator_task.rb +13 -17
  306. data/lib/ffi/tools/struct_generator.rb +4 -4
  307. data/lib/ffi/tools/types_generator.rb +7 -4
  308. data/lib/ffi/types.rb +1 -1
  309. data/lib/ffi/variadic.rb +1 -1
  310. data/lib/ffi/version.rb +1 -1
  311. data/samples/getlogin.rb +1 -1
  312. data/samples/getpid.rb +1 -1
  313. data/samples/gettimeofday.rb +8 -8
  314. data/samples/hello.rb +2 -1
  315. data/samples/inotify.rb +1 -1
  316. data/samples/pty.rb +1 -2
  317. data/samples/qsort.rb +0 -1
  318. metadata +151 -122
  319. data/.gitignore +0 -22
  320. data/.gitmodules +0 -3
  321. data/.travis.yml +0 -43
  322. data/.yardopts +0 -5
  323. data/appveyor.yml +0 -22
  324. data/ext/ffi_c/DataConverter.c +0 -91
  325. data/ext/ffi_c/StructByReference.c +0 -190
  326. data/ext/ffi_c/StructByReference.h +0 -50
  327. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  328. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  329. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  330. data/ext/ffi_c/win32/stdbool.h +0 -8
  331. data/ext/ffi_c/win32/stdint.h +0 -201
  332. data/samples/sample_helper.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 108ea9d730d92bf5994912324af1cd21b23256c575d0344a7884990d8307baa7
4
- data.tar.gz: be60f268828396e8b67d1329ac95b136f4f03a229d37f95f73d35dcd1fb8908c
3
+ metadata.gz: 353f17e7189b732ee142f0fdc41abd08c4fd452ff66c8a8ac8f6f73fea51af61
4
+ data.tar.gz: dffb5ad7b577e129155fc17a27510a8b59c47b581f35a23feaecb8db1a8045ed
5
5
  SHA512:
6
- metadata.gz: eed04778f789f4216f78466bc8fb3f30efa96f3da66720fe3fcce1f5eba01213387c20fe0eb1bcd73146931cefdc68133a3d6a1723b921e1ce00adb58e8e6440
7
- data.tar.gz: 8c8c96560189bce8d0a95513872028692b89d181ed8ba68752085cbcac2cf957bde9b00c6666946646849acea167b300c28727fd9669098cfb83514fbcf29474
6
+ metadata.gz: 2ecd826778b07a85f78e85d029f7fddf3db2504662368e00dca0089eab598b0192327a9b32dde4219c2c74085a8df6b68c65e1b1f949cb958933dbef2c827fdd
7
+ data.tar.gz: 7eac3b6ba310ff47cc1fe4288a1efa9c0b4dda8f10be26c65d67d446cd83a4085cc99e60c965254165205d0345a03e56c39e8a2ab4e0cc48efbe1ba28c0c7bc2
@@ -1,3 +1,168 @@
1
+ 1.14.2 / 2020-12-21
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Fix builtin libffi on newer Ubuntu caused by an outdated Makefile.in . #863
6
+
7
+
8
+ 1.14.1 / 2020-12-19
9
+ -------------------
10
+
11
+ Changed:
12
+ * Revert changes to FFI::Pointer#write_string made in ffi-1.14.0.
13
+ It breaks compatibilty in a way that can cause hard to find errors. #857
14
+
15
+
16
+ 1.14.0 / 2020-12-18
17
+ -------------------
18
+
19
+ Added:
20
+ * Add types.conf for x86_64-msys, x86_64-haiku, aarch64-openbsd and aarch64-darwin (alias arm64-darwin)
21
+ * Add method AbstractMemory#size_limit? . #829
22
+ * Add new extconf option --enable-libffi-alloc which is enabled per default on Apple M1 (arm64-darwin).
23
+
24
+ Changed:
25
+ * Do NULL pointer check only when array length > 0 . #305
26
+ * Raise an error on an unknown order argument. #830
27
+ * Change FFI::Pointer#write_string to terminate with a NUL byte like other string methods. #805
28
+ * Update bundled libffi to latest master.
29
+
30
+ Removed:
31
+ * Remove win32/stdint.h and stdbool.h because of copyright issue. #693
32
+
33
+ Fixed:
34
+ * Fix possible UTF-8 load error in loader script interpretation. #792
35
+ * Fix segfault on non-array argument to #write_array_of_*
36
+ * Fix memory leak in MethodHandle . #815
37
+ * Fix possible segfault in combination with fiddle or other libffi using gems . #835
38
+ * Fix possibility to use ffi ruby gem with JRuby-9.3 . #763
39
+ * Fix a GC issue, when a callback Proc is used on more than 2 callback signatures. #820
40
+
41
+
42
+ 1.13.1 / 2020-06-09
43
+ -------------------
44
+
45
+ Changed:
46
+ * Revert use of `ucrtbase.dll` as default C library on Windows-MINGW.
47
+ `ucrtbase.dll` is still used on MSWIN target. #790
48
+ * Test for `ffi_prep_closure_loc()` to make sure we can use this function.
49
+ This fixes incorrect use of system libffi on MacOS Mojave (10.14). #787
50
+ * Update types.conf on x86_64-dragonflybsd
51
+
52
+
53
+ 1.13.0 / 2020-06-01
54
+ -------------------
55
+
56
+ Added:
57
+ * Add TruffleRuby support. Almost all specs are running on TruffleRuby and succeed. #768
58
+ * Add ruby source files to the java gem. This allows to ship the Ruby library code per platform java gem and add it as a default gem to JRuby. #763
59
+ * Add FFI::Platform::LONG_DOUBLE_SIZE
60
+ * Add bounds checks for writing to an inline char[] . #756
61
+ * Add long double as callback return value. #771
62
+ * Update type definitions and add types from stdint.h and stddef.h on i386-windows, x86_64-windows, x86_64-darwin, x86_64-linux, arm-linux, powerpc-linux. #749
63
+ * Add new type definitions for powerpc-openbsd and sparcv9-openbsd. #775, #778
64
+
65
+ Changed:
66
+ * Raise required ruby version to >= 2.3.
67
+ * Lots of cleanups and improvements in library, specs and benchmarks.
68
+ * Fix a lot of compiler warnings at the C-extension
69
+ * Fix several install issues on MacOS:
70
+ * Look for libffi in SDK paths, since recent versions of macOS removed it from `/usr/include` . #757
71
+ * Fix error `ld: library not found for -lgcc_s.10.4`
72
+ * Don't built for i386 architecture as it is deprecated
73
+ * Several fixes for MSVC build on Windows. #779
74
+ * Use `ucrtbase.dll` as default C library on Windows instead of old `msvcrt.dll`. #779
75
+ * Update builtin libffi to fix a Powerpc issue with parameters of type long
76
+ * Allow unmodified sourcing of (the ruby code of) this gem in JRuby and TruffleRuby as a default gem. #747
77
+ * Improve check to detect if a module has a #find_type method suitable for FFI. This fixes compatibility with stdlib `mkmf` . #776
78
+
79
+ Removed:
80
+ * Reject callback with `:string` return type at definition, because it didn't work so far and is not save to use. #751, #782
81
+
82
+
83
+ 1.12.2 / 2020-02-01
84
+ -------------------
85
+
86
+ * Fix possible segfault at FFI::Struct#[] and []= after GC.compact . #742
87
+
88
+
89
+ 1.12.1 / 2020-01-14
90
+ -------------------
91
+
92
+ Added:
93
+ * Add binary gem support for ruby-2.7 on Windows
94
+
95
+
96
+ 1.12.0 / 2020-01-14
97
+ -------------------
98
+
99
+ Added:
100
+ * FFI::VERSION is defined as part of `require 'ffi'` now.
101
+ It is no longer necessary to `require 'ffi/version'` .
102
+
103
+ Changed:
104
+ * Update libffi to latest master.
105
+
106
+ Deprecated:
107
+ * Overwriting struct layouts is now warned and will be disallowed in ffi-2.0. #734, #735
108
+
109
+
110
+ 1.11.3 / 2019-11-25
111
+ -------------------
112
+
113
+ Removed:
114
+ * Remove support for tainted objects which cause deprecation warnings in ruby-2.7. #730
115
+
116
+
117
+ 1.11.2 / 2019-11-11
118
+ -------------------
119
+
120
+ Added:
121
+ * Add DragonFlyBSD as a platform. #724
122
+
123
+ Changed:
124
+ * Sort all types.conf files, so that files and changes are easier to compare.
125
+ * Regenerated type conf for freebsd12 and x86_64-linux targets. #722
126
+ * Remove MACOSX_DEPLOYMENT_TARGET that was targeting very old version 10.4. #647
127
+ * Fix library name mangling for non glibc Linux/UNIX. #727
128
+ * Fix compiler warnings raised by ruby-2.7
129
+ * Update libffi to latest master.
130
+
131
+
132
+ 1.11.1 / 2019-05-20
133
+ -------------------
134
+
135
+ Changed:
136
+ * Raise required ruby version to >=2.0. #699, #700
137
+ * Fix a possible linker error on ruby < 2.3 on Linux.
138
+
139
+
140
+ 1.11.0 / 2019-05-17
141
+ -------------------
142
+ This version was yanked on 2019-05-20 to fix an install issue on ruby-1.9.3. #700
143
+
144
+ Added:
145
+ * Add ability to disable or force use of system libffi. #669
146
+ Use like `gem inst ffi -- --enable-system-libffi` .
147
+ * Add ability to call FFI callbacks from outside of FFI call frame. #584
148
+ * Add proper documentation to FFI::Generator and ::Task
149
+ * Add gemspec metadata. #696, #698
150
+
151
+ Changed:
152
+ * Fix stdcall on Win32. #649, #669
153
+ * Fix load paths for FFI::Generator::Task
154
+ * Fix FFI::Pointer#read_string(0) to return a binary String. #692
155
+ * Fix benchmark suite so that it runs on ruby-2.x
156
+ * Move FFI::Platform::CPU from C to Ruby. #663
157
+ * Move FFI::StructByReference to Ruby. #681
158
+ * Move FFI::DataConverter to Ruby (#661)
159
+ * Various cleanups and improvements of specs and benchmarks
160
+
161
+ Removed:
162
+ * Remove ruby-1.8 and 1.9 compatibility code. #683
163
+ * Remove unused spec files. #684
164
+
165
+
1
166
  1.10.0 / 2019-01-06
2
167
  -------------------
3
168
 
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'rake', '~> 10.1'
4
+ gem 'rake', '~> 13.0'
5
5
  gem 'rake-compiler', '~> 1.0.3'
6
- gem 'rake-compiler-dock', '~> 0.7.0'
6
+ gem 'rake-compiler-dock', '~> 1.0'
7
7
  gem 'rspec', '~> 3.0'
8
- gem 'rubygems-tasks', '~> 0.2.4', :require => 'rubygems/tasks'
9
- gem "rubysl", "~> 2.0", :platforms => 'rbx'
8
+ # irb is a dependency of rubygems-tasks 0.2.5.
9
+ # irb versions > 1.1.1 depend on reline,
10
+ # which sometimes causes 'bundle install' to fail on Ruby <= 2.4: https://github.com/rubygems/rubygems/issues/3463
11
+ gem 'rubygems-tasks', '>= 0.2', '< 0.2.5', :require => 'rubygems/tasks'
10
12
  end
11
13
 
12
14
  group :doc do
data/README.md CHANGED
@@ -1,19 +1,19 @@
1
- # ruby-ffi https://wiki.github.com/ffi/ffi [![Build Status](https://travis-ci.org/ffi/ffi.png?branch=master)](https://travis-ci.org/ffi/ffi) [![Build status Windows](https://ci.appveyor.com/api/projects/status/r8wxn1sd4s794gg1/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
1
+ # Ruby-FFI https://github.com/ffi/ffi/wiki [![Build Status](https://travis-ci.com/ffi/ffi.svg?branch=master)](https://travis-ci.com/ffi/ffi) [![Build status Windows](https://ci.appveyor.com/api/projects/status/r8wxn1sd4s794gg1/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
2
2
 
3
3
  ## Description
4
4
 
5
- Ruby-FFI is a ruby extension for programmatically loading dynamic
5
+ Ruby-FFI is a gem for programmatically loading dynamically-linked native
6
6
  libraries, binding functions within them, and calling those functions
7
7
  from Ruby code. Moreover, a Ruby-FFI extension works without changes
8
- on Ruby and JRuby. [Discover why you should write your next extension
9
- using Ruby-FFI](https://wiki.github.com/ffi/ffi/why-use-ffi).
8
+ on CRuby (MRI), JRuby, Rubinius and TruffleRuby. [Discover why you should write your next extension
9
+ using Ruby-FFI](https://github.com/ffi/ffi/wiki/why-use-ffi).
10
10
 
11
- ## Features/problems
11
+ ## Features
12
12
 
13
13
  * Intuitive DSL
14
14
  * Supports all C native types
15
15
  * C structs (also nested), enums and global variables
16
- * Callbacks from C to ruby
16
+ * Callbacks from C to Ruby
17
17
  * Automatic garbage collection of native memory
18
18
 
19
19
  ## Synopsis
@@ -30,20 +30,32 @@ end
30
30
  MyLib.puts 'Hello, World using libc!'
31
31
  ```
32
32
 
33
- For less minimalistic and more sane examples you may look at:
33
+ For less minimalistic and more examples you may look at:
34
34
 
35
- * the samples/ folder
36
- * the examples on the [wiki](https://wiki.github.com/ffi/ffi)
37
- * the projects using FFI listed on this page (https://wiki.github.com/ffi/ffi/projects-using-ffi)
35
+ * the `samples/` folder
36
+ * the examples on the [wiki](https://github.com/ffi/ffi/wiki)
37
+ * the projects using FFI listed on the wiki: https://github.com/ffi/ffi/wiki/projects-using-ffi
38
38
 
39
39
  ## Requirements
40
40
 
41
- You need a sane building environment in order to compile the extension.
42
- At a minimum, you will need:
43
- * A C compiler (e.g. Xcode on OSX, gcc on everything else)
44
- * libffi development library - this is commonly in the libffi-dev or libffi-devel
41
+ When installing the gem on CRuby (MRI), you will need:
42
+ * A C compiler (e.g., Xcode on macOS, `gcc` or `clang` on everything else)
43
+ Optionally (speeds up installation):
44
+ * The `libffi` library and development headers - this is commonly in the `libffi-dev` or `libffi-devel` packages
45
45
 
46
- On Linux systems running with [PaX](https://en.wikipedia.org/wiki/PaX) (Gentoo, Alpine, etc.) FFI may trigger `mprotect` errors. You may need to disable [mprotect](https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Restrict_mprotect.28.29) for ruby (`paxctl -m [/path/to/ruby]`) for the time being until a solution is found.
46
+ The ffi gem comes with a builtin libffi version, which is used, when the system libffi library is not available or too old.
47
+ Use of the system libffi can be enforced by:
48
+ ```
49
+ gem install ffi -- --enable-system-libffi # to install the gem manually
50
+ bundle config build.ffi --enable-system-libffi # for bundle install
51
+ ```
52
+ or prevented by `--disable-system-libffi`.
53
+
54
+ On Linux systems running with [PaX](https://en.wikipedia.org/wiki/PaX) (Gentoo, Alpine, etc.), FFI may trigger `mprotect` errors. You may need to disable [mprotect](https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Restrict_mprotect.28.29) for ruby (`paxctl -m [/path/to/ruby]`) for the time being until a solution is found.
55
+
56
+ On FreeBSD systems pkgconf must be installed for the gem to be able to compile using clang. Install either via packages `pkg install pkgconf` or from ports via `devel/pkgconf`.
57
+
58
+ On JRuby and TruffleRuby, there are no requirements to install the FFI gem, and `require 'ffi'` works even without installing the gem (i.e., the gem is preinstalled on these implementations).
47
59
 
48
60
  ## Installation
49
61
 
@@ -54,15 +66,22 @@ From rubygems:
54
66
  or from the git repository on github:
55
67
 
56
68
  git clone git://github.com/ffi/ffi.git
57
- git submodule update --init --recursive
58
69
  cd ffi
70
+ git submodule update --init --recursive
71
+ bundle install
59
72
  rake install
60
73
 
74
+ ### Install options:
75
+
76
+ * `--enable-system-libffi` : Force usage of system libffi
77
+ * `--disable-system-libffi` : Force usage of builtin libffi
78
+ * `--enable-libffi-alloc` : Force closure allocation by libffi
79
+ * `--disable-libffi-alloc` : Force closure allocation by builtin method
80
+
61
81
  ## License
62
82
 
63
83
  The ffi library is covered by the BSD license, also see the LICENSE file.
64
- The specs are shared with Rubyspec and are licensed by the same license
65
- as Rubyspec, see the LICENSE.SPECS file.
84
+ The specs are covered by the same license as [ruby/spec](https://github.com/ruby/spec), the MIT license.
66
85
 
67
86
  ## Credits
68
87
 
@@ -74,6 +93,7 @@ The following people have submitted code, bug reports, or otherwise contributed
74
93
  * Andreas Niederl <rico32@gmx.net>
75
94
  * Andrew Cholakian <andrew@andrewvc.com>
76
95
  * Antonio Terceiro <terceiro@softwarelivre.org>
96
+ * Benoit Daloze <eregontp@gmail.com>
77
97
  * Brian Candler <B.Candler@pobox.com>
78
98
  * Brian D. Burns <burns180@gmail.com>
79
99
  * Bryan Kearney <bkearney@redhat.com>
data/Rakefile CHANGED
@@ -1,12 +1,7 @@
1
1
  require 'rubygems/tasks'
2
2
  require 'rbconfig'
3
3
  require 'rake/clean'
4
- require File.expand_path("./lib/ffi/version")
5
-
6
- USE_RAKE_COMPILER = (RUBY_PLATFORM =~ /java/) ? false : true
7
- if USE_RAKE_COMPILER
8
- require 'rake/extensiontask'
9
- end
4
+ require_relative "lib/ffi/version"
10
5
 
11
6
  require 'date'
12
7
  require 'fileutils'
@@ -14,71 +9,6 @@ require 'rbconfig'
14
9
  require 'rspec/core/rake_task'
15
10
  require 'rubygems/package_task'
16
11
 
17
- LIBEXT = case RbConfig::CONFIG['host_os'].downcase
18
- when /darwin/
19
- "dylib"
20
- when /mswin|mingw/
21
- "dll"
22
- else
23
- RbConfig::CONFIG['DLEXT']
24
- end
25
-
26
- CPU = case RbConfig::CONFIG['host_cpu'].downcase
27
- when /i[3456]86/
28
- # Darwin always reports i686, even when running in 64bit mode
29
- if RbConfig::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum)
30
- "x86_64"
31
- else
32
- "i386"
33
- end
34
-
35
- when /amd64|x86_64/
36
- "x86_64"
37
-
38
- when /ppc64|powerpc64/
39
- "powerpc64"
40
-
41
- when /ppc|powerpc/
42
- "powerpc"
43
-
44
- when /^arm/
45
- "arm"
46
-
47
- else
48
- RbConfig::CONFIG['host_cpu']
49
- end
50
-
51
- OS = case RbConfig::CONFIG['host_os'].downcase
52
- when /linux/
53
- "linux"
54
- when /darwin/
55
- "darwin"
56
- when /freebsd/
57
- "freebsd"
58
- when /openbsd/
59
- "openbsd"
60
- when /sunos|solaris/
61
- "solaris"
62
- when /mswin|mingw/
63
- "win32"
64
- else
65
- RbConfig::CONFIG['host_os'].downcase
66
- end
67
-
68
- def which(name)
69
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
70
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
71
- exts.each do |ext|
72
- app = File.join(path, name+ext)
73
- return app if File.executable? app
74
- end
75
- end
76
- nil
77
- end
78
-
79
- GMAKE = which('gmake').nil? ? 'make' : 'gmake'
80
-
81
- LIBTEST = "build/libtest.#{LIBEXT}"
82
12
  BUILD_DIR = "build"
83
13
  BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
84
14
 
@@ -86,17 +16,8 @@ def gem_spec
86
16
  @gem_spec ||= Gem::Specification.load('ffi.gemspec')
87
17
  end
88
18
 
89
- TEST_DEPS = [ LIBTEST ]
90
- if RUBY_PLATFORM == "java"
91
- RSpec::Core::RakeTask.new(:spec) do |config|
92
- config.rspec_opts = YAML.load_file 'spec/spec.opts'
93
- end
94
- else
95
- RSpec::Core::RakeTask.new(:spec => :compile) do |config|
96
- config.rspec_opts = YAML.load_file 'spec/spec.opts'
97
- end
98
-
99
- TEST_DEPS.unshift :compile
19
+ RSpec::Core::RakeTask.new(:spec => :compile) do |config|
20
+ config.rspec_opts = YAML.load_file 'spec/spec.opts'
100
21
  end
101
22
 
102
23
  desc "Build all packages"
@@ -110,21 +31,20 @@ CLEAN.include 'build'
110
31
  CLEAN.include 'conftest.dSYM'
111
32
  CLEAN.include 'spec/ffi/fixtures/libtest.{dylib,so,dll}'
112
33
  CLEAN.include 'spec/ffi/fixtures/*.o'
34
+ CLEAN.include 'spec/ffi/embed-test/ext/*.{o,def}'
35
+ CLEAN.include 'spec/ffi/embed-test/ext/Makefile'
113
36
  CLEAN.include "pkg/ffi-*-{mingw32,java}"
114
37
  CLEAN.include 'lib/1.*'
115
38
  CLEAN.include 'lib/2.*'
116
- CLEAN.include 'bin'
117
39
 
118
- task :distclean => :clobber
40
+ # clean all shipped files, that are not in git
41
+ CLEAN.include(
42
+ gem_spec.files -
43
+ `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0").map { |f| File.join("ext/ffi_c/libffi", f) } -
44
+ `git ls-files -z`.split("\x0")
45
+ )
119
46
 
120
- desc "Build the native test lib"
121
- file "build/libtest.#{LIBEXT}" => FileList['libtest/**/*.[ch]'] do
122
- sh %{#{GMAKE} -f libtest/GNUmakefile CPU=#{CPU} OS=#{OS} }
123
- end
124
-
125
-
126
- desc "Build test helper lib"
127
- task :libtest => "build/libtest.#{LIBEXT}"
47
+ task :distclean => :clobber
128
48
 
129
49
  desc "Test the extension"
130
50
  task :test => [ :spec ]
@@ -132,37 +52,29 @@ task :test => [ :spec ]
132
52
 
133
53
  namespace :bench do
134
54
  ITER = ENV['ITER'] ? ENV['ITER'].to_i : 100000
135
- bench_libs = "-Ilib -I#{BUILD_DIR}" unless RUBY_PLATFORM == "java"
136
- bench_files = Dir["bench/bench_*.rb"].reject { |f| f == "bench_helper.rb" }
55
+ bench_files = Dir["bench/bench_*.rb"].sort.reject { |f| f == "bench/bench_helper.rb" }
137
56
  bench_files.each do |bench|
138
- task File.basename(bench, ".rb")[6..-1] => TEST_DEPS do
139
- sh %{#{Gem.ruby} #{bench_libs} #{bench} #{ITER}}
57
+ task File.basename(bench, ".rb")[6..-1] => :compile do
58
+ sh %{#{Gem.ruby} #{bench} #{ITER}}
140
59
  end
141
60
  end
142
- task :all => TEST_DEPS do
61
+ task :all => :compile do
143
62
  bench_files.each do |bench|
144
- sh %{#{Gem.ruby} #{bench_libs} #{bench}}
63
+ sh %{#{Gem.ruby} #{bench}}
145
64
  end
146
65
  end
147
66
  end
148
67
 
149
- task 'spec:run' => TEST_DEPS
150
- task 'spec:specdoc' => TEST_DEPS
68
+ task 'spec:run' => :compile
69
+ task 'spec:specdoc' => :compile
151
70
 
152
71
  task :default => :spec
153
72
 
154
73
  namespace 'java' do
155
74
 
156
- java_gem_spec = Gem::Specification.new do |s|
157
- s.name = gem_spec.name
158
- s.version = gem_spec.version
159
- s.author = gem_spec.author
160
- s.email = gem_spec.email
161
- s.homepage = gem_spec.homepage
162
- s.summary = gem_spec.summary
163
- s.description = gem_spec.description
164
- s.files = %w(LICENSE COPYING README.md CHANGELOG.md Rakefile)
165
- s.license = gem_spec.license
75
+ java_gem_spec = gem_spec.dup.tap do |s|
76
+ s.files.reject! { |f| File.fnmatch?("ext/*", f) }
77
+ s.extensions = []
166
78
  s.platform = 'java'
167
79
  end
168
80
 
@@ -175,8 +87,8 @@ end
175
87
 
176
88
  task 'gem:java' => 'java:gem'
177
89
 
178
-
179
- if USE_RAKE_COMPILER
90
+ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
91
+ require 'rake/extensiontask'
180
92
  Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
181
93
  ext.name = 'ffi_c' # indicate the name of the extension.
182
94
  # ext.lib_dir = BUILD_DIR # put binaries into this folder.
@@ -198,13 +110,17 @@ if USE_RAKE_COMPILER
198
110
  sh "x86_64-w64-mingw32-strip -S build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
199
111
  end
200
112
  end
113
+ else
114
+ task :compile do
115
+ STDERR.puts "Nothing to compile on #{RUBY_ENGINE}"
116
+ end
201
117
  end
202
118
 
203
119
  desc "build a windows gem without all the ceremony"
204
120
  task "gem:windows" do
205
121
  require "rake_compiler_dock"
206
122
  sh "bundle package"
207
- RakeCompilerDock.sh "sudo apt-get update && sudo apt-get install -y libltdl-dev && bundle --local && rake cross native gem MAKE='nice make -j`nproc`'"
123
+ RakeCompilerDock.sh "sudo apt-get update && sudo apt-get install -y libltdl-dev && bundle --local && rake cross native gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.2.2/}"
208
124
  end
209
125
 
210
126
  directory "ext/ffi_c/libffi"
@@ -212,6 +128,7 @@ file "ext/ffi_c/libffi/autogen.sh" => "ext/ffi_c/libffi" do
212
128
  warn "Downloading libffi ..."
213
129
  sh "git submodule update --init --recursive"
214
130
  end
131
+ task :libffi => "ext/ffi_c/libffi/autogen.sh"
215
132
 
216
133
  LIBFFI_GIT_FILES = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0")
217
134
 
@@ -231,16 +148,15 @@ end.each do |f|
231
148
  end
232
149
  end
233
150
 
234
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
235
- require 'ffi/platform'
151
+ require_relative "lib/ffi/platform"
236
152
  types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
237
153
  logfile = File.join(File.dirname(__FILE__), 'types_log')
238
154
 
239
- file types_conf => File.join("lib", "ffi", "version.rb") do |task|
155
+ task types_conf do |task|
240
156
  require 'fileutils'
241
- require 'ffi/tools/types_generator'
157
+ require_relative "lib/ffi/tools/types_generator"
242
158
  options = {}
243
- FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 })
159
+ FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 )
244
160
  File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
245
161
  f.puts FFI::TypesGenerator.generate(options)
246
162
  end
@@ -249,8 +165,8 @@ file types_conf => File.join("lib", "ffi", "version.rb") do |task|
249
165
  end
250
166
  end
251
167
 
252
- task :types_conf => types_conf do
253
- end
168
+ desc "Create or update type information for platform #{FFI::Platform::NAME}"
169
+ task :types_conf => types_conf
254
170
 
255
171
  Gem::Tasks.new do |t|
256
172
  t.scm.tag.format = '%s'