ffi 1.9.25 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (339) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +212 -0
  3. data/Gemfile +3 -4
  4. data/README.md +38 -18
  5. data/Rakefile +55 -146
  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 -49
  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 +47 -131
  14. data/ext/ffi_c/Function.h +0 -4
  15. data/ext/ffi_c/FunctionInfo.c +3 -8
  16. data/ext/ffi_c/LastError.c +49 -8
  17. data/ext/ffi_c/LongDouble.c +12 -10
  18. data/ext/ffi_c/LongDouble.h +0 -4
  19. data/ext/ffi_c/MemoryPointer.c +3 -8
  20. data/ext/ffi_c/MemoryPointer.h +0 -4
  21. data/ext/ffi_c/MethodHandle.c +21 -31
  22. data/ext/ffi_c/MethodHandle.h +3 -2
  23. data/ext/ffi_c/Platform.c +3 -54
  24. data/ext/ffi_c/Pointer.c +25 -26
  25. data/ext/ffi_c/Pointer.h +0 -4
  26. data/ext/ffi_c/Struct.c +49 -56
  27. data/ext/ffi_c/Struct.h +12 -6
  28. data/ext/ffi_c/StructByValue.c +2 -7
  29. data/ext/ffi_c/StructLayout.c +22 -20
  30. data/ext/ffi_c/Thread.c +4 -228
  31. data/ext/ffi_c/Thread.h +1 -20
  32. data/ext/ffi_c/Type.c +1 -19
  33. data/ext/ffi_c/Type.h +0 -1
  34. data/ext/ffi_c/Types.c +7 -8
  35. data/ext/ffi_c/Types.h +3 -4
  36. data/ext/ffi_c/Variadic.c +23 -24
  37. data/ext/ffi_c/compat.h +4 -0
  38. data/ext/ffi_c/extconf.rb +53 -30
  39. data/ext/ffi_c/ffi.c +3 -8
  40. data/ext/ffi_c/libffi.darwin.mk +1 -1
  41. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  42. data/ext/ffi_c/libffi/.gitattributes +4 -0
  43. data/ext/ffi_c/libffi/.travis.yml +51 -2
  44. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  45. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  46. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  47. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  48. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  49. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  50. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  51. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  52. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  53. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  54. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  55. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  56. data/ext/ffi_c/libffi/LICENSE +1 -1
  57. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  58. data/ext/ffi_c/libffi/Makefile.am +56 -72
  59. data/ext/ffi_c/libffi/README.md +33 -8
  60. data/ext/ffi_c/libffi/config.guess +552 -331
  61. data/ext/ffi_c/libffi/config.sub +1321 -1306
  62. data/ext/ffi_c/libffi/configure.ac +37 -12
  63. data/ext/ffi_c/libffi/configure.host +56 -27
  64. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  65. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  66. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  67. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  68. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  69. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  70. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  71. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  72. data/ext/ffi_c/libffi/libtool-version +1 -1
  73. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  74. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  75. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  76. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  77. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  78. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  79. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  80. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  81. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  82. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  83. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  84. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  85. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  86. data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
  87. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  88. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  89. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  90. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  91. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  92. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  93. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  94. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  95. data/ext/ffi_c/libffi/src/closures.c +69 -14
  96. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  97. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  98. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  99. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  100. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  101. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  102. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  103. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  104. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  105. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  108. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  109. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  110. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  111. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  112. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  113. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  114. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  115. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  116. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  117. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  118. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  119. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  120. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  121. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  122. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  123. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  124. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  125. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  126. data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
  127. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  128. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  129. data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
  131. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  132. data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
  133. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  134. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  135. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  136. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  137. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  138. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  139. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  143. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  220. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  221. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  222. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  223. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  224. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  225. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  226. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  227. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  228. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  229. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  230. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  231. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  232. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  233. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  234. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  235. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  236. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  237. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  238. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  239. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  240. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  241. data/ext/ffi_c/rbffi.h +0 -2
  242. data/ffi.gemspec +13 -6
  243. data/lib/ffi.rb +10 -2
  244. data/lib/ffi/abstract_memory.rb +44 -0
  245. data/lib/ffi/autopointer.rb +1 -1
  246. data/lib/ffi/data_converter.rb +67 -0
  247. data/lib/ffi/ffi.rb +3 -0
  248. data/lib/ffi/io.rb +3 -3
  249. data/lib/ffi/library.rb +12 -8
  250. data/lib/ffi/managedstruct.rb +2 -2
  251. data/lib/ffi/platform.rb +34 -10
  252. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  253. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  254. data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
  255. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  256. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  257. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  258. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  259. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  260. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  261. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  262. data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
  263. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  264. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  265. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  266. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  267. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  268. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  269. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  270. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  271. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  272. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  273. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  274. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  275. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  276. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  277. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  278. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  279. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  280. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  281. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  282. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  283. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  284. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  285. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  286. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  287. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  288. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  289. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  290. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  291. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  292. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  293. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  294. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  295. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  296. data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -90
  297. data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
  298. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  299. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  300. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  301. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  302. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  303. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  304. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  305. data/lib/ffi/pointer.rb +26 -20
  306. data/lib/ffi/struct.rb +13 -68
  307. data/lib/ffi/struct_by_reference.rb +72 -0
  308. data/lib/ffi/struct_layout.rb +96 -0
  309. data/lib/ffi/tools/const_generator.rb +5 -4
  310. data/lib/ffi/tools/generator.rb +47 -2
  311. data/lib/ffi/tools/generator_task.rb +13 -17
  312. data/lib/ffi/tools/struct_generator.rb +4 -4
  313. data/lib/ffi/tools/types_generator.rb +7 -4
  314. data/lib/ffi/types.rb +1 -1
  315. data/lib/ffi/variadic.rb +1 -10
  316. data/lib/ffi/version.rb +1 -1
  317. data/rakelib/ffi_gem_helper.rb +65 -0
  318. data/samples/getlogin.rb +1 -1
  319. data/samples/getpid.rb +1 -1
  320. data/samples/gettimeofday.rb +8 -8
  321. data/samples/hello.rb +2 -1
  322. data/samples/inotify.rb +1 -1
  323. data/samples/pty.rb +1 -2
  324. data/samples/qsort.rb +0 -1
  325. metadata +160 -122
  326. data/.gitignore +0 -22
  327. data/.gitmodules +0 -3
  328. data/.travis.yml +0 -52
  329. data/.yardopts +0 -5
  330. data/appveyor.yml +0 -22
  331. data/ext/ffi_c/DataConverter.c +0 -91
  332. data/ext/ffi_c/StructByReference.c +0 -190
  333. data/ext/ffi_c/StructByReference.h +0 -50
  334. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  335. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  336. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  337. data/ext/ffi_c/win32/stdbool.h +0 -8
  338. data/ext/ffi_c/win32/stdint.h +0 -201
  339. data/samples/sample_helper.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf13d7fccdcd65b73b5286e04fc25a174b7b855ab1803995eaa4564d5d65456a
4
- data.tar.gz: 187c8d21dd770d08e7e123ead2a727fc3e9e384d35ff2b5d37fc3a0df712f37e
3
+ metadata.gz: aa4ec9f3d594a52a39d6ed09a73f1b25f912306d86447e183008adfedd8ef112
4
+ data.tar.gz: b998fa031983d27bc0bfb698e8284e8bc2fa931bd72e8fc21b761828d688f49d
5
5
  SHA512:
6
- metadata.gz: 06eb5d5d2c033e0b7ade6d75957f835d7831aca9b492ac752e7d2b4760707ecb07981e1cd366f0059b67c1b2f3a9b5964e70388d123f4997efa0f5c691baede8
7
- data.tar.gz: e050bf8673f3bb19afbe78646f18f452c4fa2d70fc2a8f9f8efb073cd0658f6a7e0f1737dd6a05076422533ecf22e9952f08d407bdd0480bbde31fd55eef52de
6
+ metadata.gz: e2352da0e9bf497be6000ebf0dc9f2714c2fa8b4a4d379d7e05d0cfcb51d002e0a83f47463f54284f561b2a7250ddb73e82ea6a13d90c1e84fe1e7277fe5993f
7
+ data.tar.gz: 750d28e73978ec4bc9f2546a66a9293b610200aec7e91165b226b6a6ba1b6c3bc409cf30841f9d21ade246c4e5c7d39d89ea5a3d858649319ea381718e4dafb8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,211 @@
1
+ 1.15.0 / 2021-03-05
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Fix MSVC build
6
+ * Fix async callbacks in conjunction with fork(). #884
7
+
8
+ Added:
9
+ * Allow to pass callbacks in varargs. #885
10
+ * Name the threads for FFI callback dispatcher and async thread calls for easier debugging. #883
11
+ The name can be retrieved by Thread.name and is shown by Thread.list.inspect etc.
12
+ Even gdb shows the thread name on supported operating systems.
13
+ * Add types.conf for powerpc64le-linux
14
+ * Add types.conf for riscv64-linux
15
+ * More release automation of ffi gems
16
+
17
+ Changed:
18
+ * Switch from rubygems-tasks to bundler/gem_helper
19
+
20
+ Removed:
21
+ * Remove unused VariadicInvoker#init
22
+
23
+
24
+ 1.14.2 / 2020-12-21
25
+ -------------------
26
+
27
+ Fixed:
28
+ * Fix builtin libffi on newer Ubuntu caused by an outdated Makefile.in . #863
29
+
30
+
31
+ 1.14.1 / 2020-12-19
32
+ -------------------
33
+
34
+ Changed:
35
+ * Revert changes to FFI::Pointer#write_string made in ffi-1.14.0.
36
+ It breaks compatibilty in a way that can cause hard to find errors. #857
37
+
38
+
39
+ 1.14.0 / 2020-12-18
40
+ -------------------
41
+
42
+ Added:
43
+ * Add types.conf for x86_64-msys, x86_64-haiku, aarch64-openbsd and aarch64-darwin (alias arm64-darwin)
44
+ * Add method AbstractMemory#size_limit? . #829
45
+ * Add new extconf option --enable-libffi-alloc which is enabled per default on Apple M1 (arm64-darwin).
46
+
47
+ Changed:
48
+ * Do NULL pointer check only when array length > 0 . #305
49
+ * Raise an error on an unknown order argument. #830
50
+ * Change FFI::Pointer#write_string to terminate with a NUL byte like other string methods. #805
51
+ * Update bundled libffi to latest master.
52
+
53
+ Removed:
54
+ * Remove win32/stdint.h and stdbool.h because of copyright issue. #693
55
+
56
+ Fixed:
57
+ * Fix possible UTF-8 load error in loader script interpretation. #792
58
+ * Fix segfault on non-array argument to #write_array_of_*
59
+ * Fix memory leak in MethodHandle . #815
60
+ * Fix possible segfault in combination with fiddle or other libffi using gems . #835
61
+ * Fix possibility to use ffi ruby gem with JRuby-9.3 . #763
62
+ * Fix a GC issue, when a callback Proc is used on more than 2 callback signatures. #820
63
+
64
+
65
+ 1.13.1 / 2020-06-09
66
+ -------------------
67
+
68
+ Changed:
69
+ * Revert use of `ucrtbase.dll` as default C library on Windows-MINGW.
70
+ `ucrtbase.dll` is still used on MSWIN target. #790
71
+ * Test for `ffi_prep_closure_loc()` to make sure we can use this function.
72
+ This fixes incorrect use of system libffi on MacOS Mojave (10.14). #787
73
+ * Update types.conf on x86_64-dragonflybsd
74
+
75
+
76
+ 1.13.0 / 2020-06-01
77
+ -------------------
78
+
79
+ Added:
80
+ * Add TruffleRuby support. Almost all specs are running on TruffleRuby and succeed. #768
81
+ * 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
82
+ * Add FFI::Platform::LONG_DOUBLE_SIZE
83
+ * Add bounds checks for writing to an inline char[] . #756
84
+ * Add long double as callback return value. #771
85
+ * 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
86
+ * Add new type definitions for powerpc-openbsd and sparcv9-openbsd. #775, #778
87
+
88
+ Changed:
89
+ * Raise required ruby version to >= 2.3.
90
+ * Lots of cleanups and improvements in library, specs and benchmarks.
91
+ * Fix a lot of compiler warnings at the C-extension
92
+ * Fix several install issues on MacOS:
93
+ * Look for libffi in SDK paths, since recent versions of macOS removed it from `/usr/include` . #757
94
+ * Fix error `ld: library not found for -lgcc_s.10.4`
95
+ * Don't built for i386 architecture as it is deprecated
96
+ * Several fixes for MSVC build on Windows. #779
97
+ * Use `ucrtbase.dll` as default C library on Windows instead of old `msvcrt.dll`. #779
98
+ * Update builtin libffi to fix a Powerpc issue with parameters of type long
99
+ * Allow unmodified sourcing of (the ruby code of) this gem in JRuby and TruffleRuby as a default gem. #747
100
+ * Improve check to detect if a module has a #find_type method suitable for FFI. This fixes compatibility with stdlib `mkmf` . #776
101
+
102
+ Removed:
103
+ * Reject callback with `:string` return type at definition, because it didn't work so far and is not save to use. #751, #782
104
+
105
+
106
+ 1.12.2 / 2020-02-01
107
+ -------------------
108
+
109
+ * Fix possible segfault at FFI::Struct#[] and []= after GC.compact . #742
110
+
111
+
112
+ 1.12.1 / 2020-01-14
113
+ -------------------
114
+
115
+ Added:
116
+ * Add binary gem support for ruby-2.7 on Windows
117
+
118
+
119
+ 1.12.0 / 2020-01-14
120
+ -------------------
121
+
122
+ Added:
123
+ * FFI::VERSION is defined as part of `require 'ffi'` now.
124
+ It is no longer necessary to `require 'ffi/version'` .
125
+
126
+ Changed:
127
+ * Update libffi to latest master.
128
+
129
+ Deprecated:
130
+ * Overwriting struct layouts is now warned and will be disallowed in ffi-2.0. #734, #735
131
+
132
+
133
+ 1.11.3 / 2019-11-25
134
+ -------------------
135
+
136
+ Removed:
137
+ * Remove support for tainted objects which cause deprecation warnings in ruby-2.7. #730
138
+
139
+
140
+ 1.11.2 / 2019-11-11
141
+ -------------------
142
+
143
+ Added:
144
+ * Add DragonFlyBSD as a platform. #724
145
+
146
+ Changed:
147
+ * Sort all types.conf files, so that files and changes are easier to compare.
148
+ * Regenerated type conf for freebsd12 and x86_64-linux targets. #722
149
+ * Remove MACOSX_DEPLOYMENT_TARGET that was targeting very old version 10.4. #647
150
+ * Fix library name mangling for non glibc Linux/UNIX. #727
151
+ * Fix compiler warnings raised by ruby-2.7
152
+ * Update libffi to latest master.
153
+
154
+
155
+ 1.11.1 / 2019-05-20
156
+ -------------------
157
+
158
+ Changed:
159
+ * Raise required ruby version to >=2.0. #699, #700
160
+ * Fix a possible linker error on ruby < 2.3 on Linux.
161
+
162
+
163
+ 1.11.0 / 2019-05-17
164
+ -------------------
165
+ This version was yanked on 2019-05-20 to fix an install issue on ruby-1.9.3. #700
166
+
167
+ Added:
168
+ * Add ability to disable or force use of system libffi. #669
169
+ Use like `gem inst ffi -- --enable-system-libffi` .
170
+ * Add ability to call FFI callbacks from outside of FFI call frame. #584
171
+ * Add proper documentation to FFI::Generator and ::Task
172
+ * Add gemspec metadata. #696, #698
173
+
174
+ Changed:
175
+ * Fix stdcall on Win32. #649, #669
176
+ * Fix load paths for FFI::Generator::Task
177
+ * Fix FFI::Pointer#read_string(0) to return a binary String. #692
178
+ * Fix benchmark suite so that it runs on ruby-2.x
179
+ * Move FFI::Platform::CPU from C to Ruby. #663
180
+ * Move FFI::StructByReference to Ruby. #681
181
+ * Move FFI::DataConverter to Ruby (#661)
182
+ * Various cleanups and improvements of specs and benchmarks
183
+
184
+ Removed:
185
+ * Remove ruby-1.8 and 1.9 compatibility code. #683
186
+ * Remove unused spec files. #684
187
+
188
+
189
+ 1.10.0 / 2019-01-06
190
+ -------------------
191
+
192
+ Added:
193
+ * Add /opt/local/lib/ to ffi's fallback library search path. #638
194
+ * Add binary gem support for ruby-2.6 on Windows
195
+ * Add FreeBSD on AArch64 and ARM support. #644
196
+ * Add FFI::LastError.winapi_error on Windows native or Cygwin. #633
197
+
198
+ Changed:
199
+ * Update to rake-compiler-dock-0.7.0
200
+ * Use 64-bit inodes on FreeBSD >= 12. #644
201
+ * Switch time_t and suseconds_t types to long on FreeBSD. #627
202
+ * Make register_t long_long on 64-bit FreeBSD. #644
203
+ * Fix Pointer#write_array_of_type #637
204
+
205
+ Removed:
206
+ * Drop binary gem support for ruby-2.0 and 2.1 on Windows
207
+
208
+
1
209
  1.9.25 / 2018-06-03
2
210
  -------------------
3
211
 
@@ -9,6 +217,10 @@ Changed:
9
217
  1.9.24 / 2018-06-02
10
218
  -------------------
11
219
 
220
+ Security Note:
221
+
222
+ This update addresses vulnerability CVE-2018-1000201: DLL loading issue which can be hijacked on Windows OS, when a Symbol is used as DLL name instead of a String. Found by Matthew Bush.
223
+
12
224
  Added:
13
225
  * Added a CHANGELOG file
14
226
  * Add mips64(eb) support, and mips r6 support. (#601)
data/Gemfile CHANGED
@@ -1,12 +1,11 @@
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.6.2'
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
+ gem 'bundler', '~> 2.0'
10
9
  end
11
10
 
12
11
  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,102 +1,20 @@
1
- require 'rubygems/tasks'
2
1
  require 'rbconfig'
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
10
-
11
2
  require 'date'
12
3
  require 'fileutils'
13
4
  require 'rbconfig'
14
5
  require 'rspec/core/rake_task'
15
6
  require 'rubygems/package_task'
7
+ require 'rake/extensiontask'
8
+ require_relative "lib/ffi/version"
9
+ require_relative "rakelib/ffi_gem_helper"
16
10
 
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
11
  BUILD_DIR = "build"
83
12
  BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
84
13
 
85
- def gem_spec
86
- @gem_spec ||= Gem::Specification.load('ffi.gemspec')
87
- end
88
-
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
14
+ gem_spec = Bundler.load_gemspec('ffi.gemspec')
98
15
 
99
- TEST_DEPS.unshift :compile
16
+ RSpec::Core::RakeTask.new(:spec => :compile) do |config|
17
+ config.rspec_opts = YAML.load_file 'spec/spec.opts'
100
18
  end
101
19
 
102
20
  desc "Build all packages"
@@ -110,21 +28,20 @@ CLEAN.include 'build'
110
28
  CLEAN.include 'conftest.dSYM'
111
29
  CLEAN.include 'spec/ffi/fixtures/libtest.{dylib,so,dll}'
112
30
  CLEAN.include 'spec/ffi/fixtures/*.o'
31
+ CLEAN.include 'spec/ffi/embed-test/ext/*.{o,def}'
32
+ CLEAN.include 'spec/ffi/embed-test/ext/Makefile'
113
33
  CLEAN.include "pkg/ffi-*-{mingw32,java}"
114
34
  CLEAN.include 'lib/1.*'
115
35
  CLEAN.include 'lib/2.*'
116
- CLEAN.include 'bin'
117
-
118
- task :distclean => :clobber
119
-
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
36
 
37
+ # clean all shipped files, that are not in git
38
+ CLEAN.include(
39
+ gem_spec.files -
40
+ `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0").map { |f| File.join("ext/ffi_c/libffi", f) } -
41
+ `git ls-files -z`.split("\x0")
42
+ )
125
43
 
126
- desc "Build test helper lib"
127
- task :libtest => "build/libtest.#{LIBEXT}"
44
+ task :distclean => :clobber
128
45
 
129
46
  desc "Test the extension"
130
47
  task :test => [ :spec ]
@@ -132,38 +49,29 @@ task :test => [ :spec ]
132
49
 
133
50
  namespace :bench do
134
51
  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" }
52
+ bench_files = Dir["bench/bench_*.rb"].sort.reject { |f| f == "bench/bench_helper.rb" }
137
53
  bench_files.each do |bench|
138
- task File.basename(bench, ".rb")[6..-1] => TEST_DEPS do
139
- sh %{#{Gem.ruby} #{bench_libs} #{bench} #{ITER}}
54
+ task File.basename(bench, ".rb")[6..-1] => :compile do
55
+ sh %{#{Gem.ruby} #{bench} #{ITER}}
140
56
  end
141
57
  end
142
- task :all => TEST_DEPS do
58
+ task :all => :compile do
143
59
  bench_files.each do |bench|
144
- sh %{#{Gem.ruby} #{bench_libs} #{bench}}
60
+ sh %{#{Gem.ruby} #{bench}}
145
61
  end
146
62
  end
147
63
  end
148
64
 
149
- task 'spec:run' => TEST_DEPS
150
- task 'spec:specdoc' => TEST_DEPS
65
+ task 'spec:run' => :compile
66
+ task 'spec:specdoc' => :compile
151
67
 
152
68
  task :default => :spec
153
69
 
154
70
  namespace 'java' do
155
71
 
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.has_rdoc = false
166
- s.license = gem_spec.license
72
+ java_gem_spec = gem_spec.dup.tap do |s|
73
+ s.files.reject! { |f| File.fnmatch?("ext/*", f) }
74
+ s.extensions = []
167
75
  s.platform = 'java'
168
76
  end
169
77
 
@@ -176,46 +84,47 @@ end
176
84
 
177
85
  task 'gem:java' => 'java:gem'
178
86
 
87
+ FfiGemHelper.install_tasks
88
+ # Register windows gems to be pushed to rubygems.org
89
+ Bundler::GemHelper.instance.cross_platforms = %w[x86-mingw32 x64-mingw32]
179
90
 
180
- if USE_RAKE_COMPILER
91
+ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
92
+ require 'rake/extensiontask'
181
93
  Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
182
94
  ext.name = 'ffi_c' # indicate the name of the extension.
183
95
  # ext.lib_dir = BUILD_DIR # put binaries into this folder.
184
96
  ext.tmp_dir = BUILD_DIR # temporary folder used during compilation.
185
97
  ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
186
- ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
98
+ ext.cross_platform = Bundler::GemHelper.instance.cross_platforms
187
99
  ext.cross_compiling do |spec|
188
100
  spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
189
101
  end
190
- end
191
-
192
- # To reduce the gem file size strip mingw32 dlls before packaging
193
- ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
194
- task "build/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so" do |t|
195
- sh "i686-w64-mingw32-strip -S build/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
196
- end
197
102
 
198
- task "build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so" do |t|
199
- sh "x86_64-w64-mingw32-strip -S build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
200
- end
201
103
  end
202
-
203
- desc "build a windows gem without all the ceremony."
204
- task "gem:windows" do
205
- require "rake_compiler_dock"
206
- RakeCompilerDock.sh "sudo apt-get update && sudo apt-get install -y libltdl-dev && bundle && rake cross native gem MAKE='nice make -j`nproc`'"
104
+ else
105
+ task :compile do
106
+ STDERR.puts "Nothing to compile on #{RUBY_ENGINE}"
207
107
  end
208
108
  end
209
109
 
110
+
111
+ desc "build a windows gem without all the ceremony"
112
+ task "gem:windows" do
113
+ require "rake_compiler_dock"
114
+ sh "bundle package"
115
+ 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/}"
116
+ end
117
+
210
118
  directory "ext/ffi_c/libffi"
211
119
  file "ext/ffi_c/libffi/autogen.sh" => "ext/ffi_c/libffi" do
212
120
  warn "Downloading libffi ..."
213
121
  sh "git submodule update --init --recursive"
214
122
  end
123
+ task :libffi => "ext/ffi_c/libffi/autogen.sh"
215
124
 
216
125
  LIBFFI_GIT_FILES = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0")
217
126
 
218
- # Generate files in gemspec but not in libffi's git repo by running autogen.sh
127
+ # Generate files which are in the gemspec but not in libffi's git repo by running autogen.sh
219
128
  gem_spec.files.select do |f|
220
129
  f =~ /ext\/ffi_c\/libffi\/(.*)/ && !LIBFFI_GIT_FILES.include?($1)
221
130
  end.each do |f|
@@ -231,16 +140,20 @@ end.each do |f|
231
140
  end
232
141
  end
233
142
 
234
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
235
- require 'ffi/platform'
143
+ # Make sure we have all gemspec files before packaging
144
+ task :build => gem_spec.files
145
+ task :gem => :build
146
+
147
+
148
+ require_relative "lib/ffi/platform"
236
149
  types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
237
150
  logfile = File.join(File.dirname(__FILE__), 'types_log')
238
151
 
239
- file types_conf => File.join("lib", "ffi", "version.rb") do |task|
152
+ task types_conf do |task|
240
153
  require 'fileutils'
241
- require 'ffi/tools/types_generator'
154
+ require_relative "lib/ffi/tools/types_generator"
242
155
  options = {}
243
- FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 })
156
+ FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 )
244
157
  File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
245
158
  f.puts FFI::TypesGenerator.generate(options)
246
159
  end
@@ -249,12 +162,8 @@ file types_conf => File.join("lib", "ffi", "version.rb") do |task|
249
162
  end
250
163
  end
251
164
 
252
- task :types_conf => types_conf do
253
- end
254
-
255
- Gem::Tasks.new do |t|
256
- t.scm.tag.format = '%s'
257
- end
165
+ desc "Create or update type information for platform #{FFI::Platform::NAME}"
166
+ task :types_conf => types_conf
258
167
 
259
168
  begin
260
169
  require 'yard'