Skip to content

Latest commit

 

History

History
77 lines (57 loc) · 2.32 KB

readme.md

File metadata and controls

77 lines (57 loc) · 2.32 KB

FFI Experiments

C++ + luajit FFI = horrible cross-platform messes.

BadMutex

A global mutex.

PreciseTimer

Measure times down to the nanosecond. Except not really.

DownloadManager

Download things with libcurl without blocking Lua.

requireffi

Load C libraries using package.path.

Building

The preferred build system is meson, but a basic makefile is also provided for those who do not wish to install it.

You will need:

  • A recent version of meson.
  • A working c99 compiler.
  • A working c++11 compiler.
  • libcurl installed in some place meson/your linker will think to look for it.

Building on OSX and Linux should be as simple as running the following:

cd /path/to/ffi-experiments
meson build
cd build
ninja

Should you wish to statically link dependencies, simply include -Dstatic_deps=true with the meson build command.

If you are on an operating system managed by a hulking corporate abomination, things are a little bit more complicated. The following instructions are for building with a recent version of Visual Studio.

You'll need a directory containing two subdirectories, include and lib, containing the header files and a statically built libcurl respectively. libcurl should be built with the same settings you intend to use for DownloadManager.

Launch the relevant VS native tools command prompt. Be sure that if you want a 64-bit built, you're using the one labeled x64. Then run the following:

powershell
cd C:\Path\To\ffi-experiments
meson -Dlibcurl_path="C:\Path\To\libcurl" build
cd build
ninja

You can then launch the solution, pick a god and pray, and then attempt to build the three projects.

The companion lua scripts are not built by default, for two reasons. The first reason is that the generated lua scripts are platform independent, so you can just download the release versions like everyone else. The second reason is that the lua build process assumes it is running in a Posix environment with the programs bash, cpp, perl, moonc, and true all being available to the user. If in an appropriate environment, the lua scripts can be generated by additionally running ninja lua (if using meson) or make lua (if using the makefile). These targets will not be available on Windows.