cryptol/tests/ffi/ffi-reload.icry
Ryan Scott 27ac8d9717 Support FFI on Windows
This patch:

* Adds the appropriate conditional logic to use the `Win32` library to
  dynamically load shared libraries on Windows.
* Tweaks some FFI-related test cases to make them work portably on Windows. I
  have left comments describing each of the non-obvious tweaks that I had to
  make.
* Updates the reference manual accordingly.

Fixes #1394.
2022-09-24 11:21:03 -04:00

23 lines
1.1 KiB
Plaintext

// Double quotes must be used to make the command below work on Windows.
// This is because Windows treats <triangle brackets> specially in scripts
// under most circumstances, and single quotes aren't enough to escape the
// special triangle bracket treatment. We also use printf rather than echo
// to avoid including the double quotes in the file contents.
:! printf "#include <stdint.h>\nuint8_t test() { return 0; }" > ffi-reload.c
:! make -s ffi-reload
:l ffi-reload.cry
test ()
:! sleep 1
:! sed -i.bak 's/return 0/return 1/' ffi-reload.c
// Very confusingly, the ffi-reload.dll file that this script creates on
// Windows will not have the permissions you expect it to, which will cause
// 'Permission denied' errors when trying to overwrite it later in the script.
// The simplest workaround that I have found is to delete the file and then
// recompile it. (Yes, you have the permissions to delete it, but not to
// overwrite it. I have no idea why.)
:! rm -f ffi-reload.so ffi-reload.dylib ffi-reload.dll
:! make -s ffi-reload
:r
test ()
:! rm ffi-reload.c ffi-reload.c.bak