diff --git a/README.md b/README.md index 46d28bf..6c54ca5 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,7 @@ LuaJIT bindings for Crystal - [Mac](https://www.google.com/search?q=install+luajit+mac) - `brew install luajit` - [Windows](https://www.google.com/search?q=install+luajit+windows) - - Execute `.\scripts\build.ps1` - - See output for `--link-flags` - - Add to crystal commands, e.g. `crystal run --link-flags="/LIBPATH:" src/example.cr` + - [See below](#windows) 2. Add the dependency to your `shard.yml`: @@ -24,6 +22,38 @@ dependencies: 3. Run `shards install` +### Windows + +#### Simple + +1. Run `.\scripts\build.ps1` +2. Check output for `--link-flags` +3. Add `--link-flags` to existing `crystal` commands + +Example (powershell): + +``` +.\scripts\build.ps1 +# ...build output... +# Add the following to any crystal commands: +# --link-flags=/LIBPATH:C:\Lua +crystal run --link-flags=/LIBPATH:C:\Lua src\example.cr +``` + +#### Advanced + +There are a couple ways to avoid needing to add linker flags on every command, +but they require a little more work. + +- Modify `.\scripts\build.ps1` to install to a more global directory (e.g. `C:\Lua`) + - Add global directory to environment variable `CRYSTAL_LIBRARY_PATH` + - NOTE: make sure to still include Crystal's compiler directory as well (can be found by running `crystal env CRYSTAL_LIBRARY_PATH`) + - Add global directory to PATH + - This isn't completely necessary, but if you plan to leverage `-Dpreview_dll` it's required +- Modify `.\scripts\build.ps1` to install to Crystal's compiler directory (e.g. where stdlib lives) + - This has the benefit of not modifying any environment variables + - However, newer versions of Crystal might require a reinstall + ## Usage ```crystal diff --git a/shard.yml b/shard.yml index 0f7bb00..e73527d 100644 --- a/shard.yml +++ b/shard.yml @@ -1,11 +1,19 @@ name: luajit version: 0.4.0 +description: "LuaJIT bindings for Crystal" + +repository: "https://github.com/mdwagner/luajit.cr" license: MIT +documentation: "https://crystaldoc.info/github/mdwagner/luajit.cr/v0.4.0" authors: - Michael Wagner crystal: ~> 1.8 +libraries: + libluajit51: "~> 2.1" + lua51: "*" + crystalline: main: spec/spec_helper.cr diff --git a/src/luajit/lib_luajit.cr b/src/luajit/lib_luajit.cr index 788ae8e..68a0efa 100644 --- a/src/luajit/lib_luajit.cr +++ b/src/luajit/lib_luajit.cr @@ -1,6 +1,6 @@ module Luajit {% if flag?(:win32) %} - # NOTE: Looks up "lua51.lib", "lua51-static.lib", or "lua51-dynamic.lib" + # NOTE: Looks up either "lua51.lib", "lua51-static.lib", or "lua51-dynamic.lib" @[Link("lua51")] {% else %} @[Link("luajit")]