LuaRocks plugin adds * package "luarocks" * several packages with rocks (lpeg, luasocket, llthreads2, lua-rapidjson) * plugins/luarocks/README.md * virtual rock "all-rocks" depending on all rocks * short test for rocks
Unified · Split
| @@ -0,0 +1,94 @@ | |||
| 1 | LuaRocks plugin | ||
| 2 | =============== | ||
| 3 | |||
| 4 | Short description of LuaRocks | ||
| 5 | ----------------------------- | ||
| 6 | |||
| 7 | Hundreds of [Lua][lua] packages are distributed via [LuaRocks][luarocks]. | ||
| 8 | LuaRocks is the package manager for Lua. It allows you to create and | ||
| 9 | install Luamodules as self-contained packages called rocks. You can | ||
| 10 | download and install LuaRocks on Unix and Windows. | ||
| 11 | |||
| 12 | Lua rocks are similar to Ruby gems, Python eggs or JavaScript NPM. Command | ||
| 13 | `luarocks install <rock>` downloads a rock from [luarocks.org][luarocks] | ||
| 14 | (or other luarocks server), compiles C files (modules) to shared libraries | ||
| 15 | and installs (copies) shared libraries and Lua files to the directory | ||
| 16 | where luarocks is installed. Installed rocks can be loaded from Lua with | ||
| 17 | function `require`. | ||
| 18 | |||
| 19 | Example: | ||
| 20 | ``` | ||
| 21 | $ luarocks install luasocket | ||
| 22 | $ lua -e 'http = require "socket.http"; print(http.request("http://mxe.cc"))' | ||
| 23 | <!DOCTYPE html> | ||
| 24 | .... | ||
| 25 | ``` | ||
| 26 | |||
| 27 | LuaRocks can used with `make`, `cmake`, custom or builtin | ||
| 28 | [back-ends][backends]. | ||
| 29 | |||
| 30 | LuaRocks in MXE | ||
| 31 | --------------- | ||
| 32 | |||
| 33 | LuaRocks and some popular rocks were ported to MXE as a plugin. | ||
| 34 | LuaRocks can now be used in the same way as CMake or Make. | ||
| 35 | |||
| 36 | Package `lua` installs native executable usr/bin/lua and | ||
| 37 | cross-compiled lua executable usr/<target>/bin/lua.exe. Native | ||
| 38 | executable is needed since LuaRocks is written in Lua. Cross-compiled | ||
| 39 | one is needed to run Lua scripts loading cross-compiled lua modules. | ||
| 40 | |||
| 41 | Package `luarocks` was added. Luarocks was patched to support new | ||
| 42 | platform `mxe`, inherited from platform `unix`. It uses mix of system | ||
| 43 | tools (e.g., `openssl`, `ln`, `mkdir`), MXE build chain | ||
| 44 | (`i686-w64-mingw32.shared-gcc`, `i686-w64-mingw32.shared-cmake`) and some | ||
| 45 | Windows variables (e.g., "dll" extension for shared libraries). The | ||
| 46 | package is shared-only because Lua loads modules in runtime. It | ||
| 47 | creates prefixed luarocks tool in `usr/bin`. It also creates prefixed | ||
| 48 | wine+lua wrapper aware of locations of dll and lua files installed. | ||
| 49 | This script can be used to test modules in Linux as if running them in | ||
| 50 | Windows. | ||
| 51 | |||
| 52 | There was a difficult choice if `mxe` platform of luarocks is inherited | ||
| 53 | from `windows` or `unix` platform. I tried both and it is less patching | ||
| 54 | for `unix`. For `windows` even build tools differ, while for `unix` a | ||
| 55 | typical rock builds without patching or with minor patching | ||
| 56 | (as other MXE packages). | ||
| 57 | |||
| 58 | LuaRocks can be used to install rocks. With ideal rock it works as follows: | ||
| 59 | |||
| 60 | ``` | ||
| 61 | $ i686-w64-mingw32.shared-luarocks install <rock> | ||
| 62 | ``` | ||
| 63 | |||
| 64 | This command downloads rockspeck, downloads sources, verifies checksum | ||
| 65 | (useless thing, because checksum is compared to the value from rockspec | ||
| 66 | file, which itself is neither verified nor signed), builds and installs. | ||
| 67 | |||
| 68 | LuaRocks is not used to download source tarballs (as said | ||
| 69 | above, it doesn't verify checksums properly) using MXE's downloading | ||
| 70 | and verifying facilities instead. Luarocks is used as builder, | ||
| 71 | installer and Lua library (it installs Lua files to | ||
| 72 | `usr/i686-w64-mingw32.shared/share/lua/5.3/luarocks/`). | ||
| 73 | |||
| 74 | Build all rocks: | ||
| 75 | ``` | ||
| 76 | $ make all-rocks MXE_PLUGIN_DIRS=plugins/luarocks MXE_TARGETS='i686-w64-mingw32.shared x86_64-w64-mingw32.shared' | ||
| 77 | ``` | ||
| 78 | |||
| 79 | Run tests (requires wine): | ||
| 80 | ``` | ||
| 81 | $ ./usr/bin/i686-w64-mingw32.shared-lua plugins/luarocks/test.lua | ||
| 82 | ``` | ||
| 83 | |||
| 84 | See also: | ||
| 85 | |||
| 86 | * [LuaRocks site][luarocks] | ||
| 87 | * [LuaRocks wiki][wiki] | ||
| 88 | * [the thread in MXE mailing list about LuaRocks in MXE][thread] | ||
| 89 | |||
| 90 | [lua]:http://lua.org/ | ||
| 91 | [luarocks]:https://luarocks.org/ | ||
| 92 | [backends]:https://github.com/keplerproject/luarocks/wiki/Rockspec-format#Build_backends | ||
| 93 | [wiki]:https://github.com/keplerproject/luarocks/wiki/ | ||
| 94 | [thread]:http://lists.nongnu.org/archive/html/mingw-cross-env-list/2015-10/msg00008.html | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | # This file is part of MXE. | ||
| 2 | # See index.html for further information. | ||
| 3 | |||
| 4 | PKG := all-rocks | ||
| 5 | $(PKG)_DEPS := lpeg luasocket llthreads2 lua-rapidjson | ||
| @@ -0,0 +1,33 @@ | |||
| 1 | This file is part of MXE. | ||
| 2 | See index.html for further information. | ||
| 3 | |||
| 4 | From 1d8e959ee39e7a46e150e722af12252448c7ac22 Mon Sep 17 00:00:00 2001 | ||
| 5 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 6 | Date: Sun, 11 Oct 2015 01:56:36 +0100 | ||
| 7 | Subject: [PATCH] link with kernel32 on MXE | ||
| 8 | |||
| 9 | --- | ||
| 10 | rockspecs/lua-llthreads2-scm-0.rockspec | 7 +++++++ | ||
| 11 | 1 file changed, 7 insertions(+) | ||
| 12 | |||
| 13 | diff --git a/rockspecs/lua-llthreads2-scm-0.rockspec b/rockspecs/lua-llthreads2-scm-0.rockspec | ||
| 14 | index 8f907b8..26d5b80 100644 | ||
| 15 | --- a/rockspecs/lua-llthreads2-scm-0.rockspec | ||
| 16 | +++ b/rockspecs/lua-llthreads2-scm-0.rockspec | ||
| 17 | @@ -27,6 +27,13 @@ build = { | ||
| 18 | } | ||
| 19 | } | ||
| 20 | }, | ||
| 21 | + mxe = { | ||
| 22 | + modules = { | ||
| 23 | + llthreads2 = { | ||
| 24 | + libraries = {"kernel32"}, | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + }, | ||
| 28 | windows = { | ||
| 29 | modules = { | ||
| 30 | llthreads2 = { | ||
| 31 | -- | ||
| 32 | 2.1.4 | ||
| 33 | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | # This file is part of MXE. | ||
| 2 | # See index.html for further information. | ||
| 3 | |||
| 4 | PKG := llthreads2 | ||
| 5 | $(PKG)_IGNORE := | ||
| 6 | $(PKG)_VERSION := 0.1.3 | ||
| 7 | $(PKG)_CHECKSUM := 8c6fc7966cdcc15ae2f89f66ae72f6727a985e7d254f139ecf75a50956a3e8e4 | ||
| 8 | $(PKG)_SUBDIR := lua-$(PKG)-$($(PKG)_VERSION) | ||
| 9 | $(PKG)_FILE := $($(PKG)_SUBDIR).tar.gz | ||
| 10 | $(PKG)_URL := https://github.com/moteus/lua-llthreads2/archive/v$($(PKG)_VERSION).tar.gz | ||
| 11 | $(PKG)_DEPS := gcc luarocks | ||
| 12 | |||
| 13 | define $(PKG)_UPDATE | ||
| 14 | $(call MXE_GET_GITHUB_TAGS, moteus/lua-llthreads2) | \ | ||
| 15 | $(SED) 's,^v,,g' | ||
| 16 | endef | ||
| 17 | |||
| 18 | # shared-only because luarocks is shared-only | ||
| 19 | |||
| 20 | define $(PKG)_BUILD_SHARED | ||
| 21 | cd '$(1)' && '$(TARGET)-luarocks' make \ | ||
| 22 | rockspecs/lua-llthreads2-scm-0.rockspec | ||
| 23 | endef | ||
| @@ -0,0 +1,55 @@ | |||
| 1 | This file is part of MXE. | ||
| 2 | See index.html for further information. | ||
| 3 | |||
| 4 | From f271a094f8add34df3f31ac6fb12c9fe683f763a Mon Sep 17 00:00:00 2001 | ||
| 5 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 6 | Date: Sat, 10 Oct 2015 16:40:35 +0100 | ||
| 7 | Subject: [PATCH] add rockspec | ||
| 8 | |||
| 9 | Source:https://luarocks.org/modules/gvvaughan/lpeg/1.0.0-1 | ||
| 10 | --- | ||
| 11 | lpeg-1.0.0-1.rockspec | 32 ++++++++++++++++++++++++++++++++ | ||
| 12 | 1 file changed, 32 insertions(+) | ||
| 13 | create mode 100644 lpeg-1.0.0-1.rockspec | ||
| 14 | |||
| 15 | diff --git a/lpeg-1.0.0-1.rockspec b/lpeg-1.0.0-1.rockspec | ||
| 16 | new file mode 100644 | ||
| 17 | index 0000000..b4fdd27 | ||
| 18 | --- /dev/null | ||
| 19 | +++ b/lpeg-1.0.0-1.rockspec | ||
| 20 | @@ -0,0 +1,32 @@ | ||
| 21 | +package = "LPeg" | ||
| 22 | +version = "1.0.0-1" | ||
| 23 | +source = { | ||
| 24 | + url = "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.0.tar.gz", | ||
| 25 | + md5 = "0aec64ccd13996202ad0c099e2877ece", | ||
| 26 | +} | ||
| 27 | +description = { | ||
| 28 | + summary = "Parsing Expression Grammars For Lua", | ||
| 29 | + detailed = [[ | ||
| 30 | + LPeg is a new pattern-matching library for Lua, based on Parsing | ||
| 31 | + Expression Grammars (PEGs). The nice thing about PEGs is that it | ||
| 32 | + has a formal basis (instead of being an ad-hoc set of features), | ||
| 33 | + allows an efficient and simple implementation, and does most things | ||
| 34 | + we expect from a pattern-matching library (and more, as we can | ||
| 35 | + define entire grammars). | ||
| 36 | + ]], | ||
| 37 | + homepage = "http://www.inf.puc-rio.br/~roberto/lpeg.html", | ||
| 38 | + maintainer = "Gary V. Vaughan <gary@vaughan.pe>", | ||
| 39 | + license = "MIT/X11" | ||
| 40 | +} | ||
| 41 | +dependencies = { | ||
| 42 | + "lua >= 5.1" | ||
| 43 | +} | ||
| 44 | +build = { | ||
| 45 | + type = "builtin", | ||
| 46 | + modules = { | ||
| 47 | + lpeg = { | ||
| 48 | + "lpcap.c", "lpcode.c", "lpprint.c", "lptree.c", "lpvm.c" | ||
| 49 | + }, | ||
| 50 | + re = "re.lua" | ||
| 51 | + } | ||
| 52 | +} | ||
| 53 | -- | ||
| 54 | 2.1.4 | ||
| 55 | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | # This file is part of MXE. | ||
| 2 | # See index.html for further information. | ||
| 3 | |||
| 4 | PKG := lpeg | ||
| 5 | $(PKG)_IGNORE := | ||
| 6 | $(PKG)_VERSION := 1.0.0 | ||
| 7 | $(PKG)_CHECKSUM := 10190ae758a22a16415429a9eb70344cf29cbda738a6962a9f94a732340abf8e | ||
| 8 | $(PKG)_SUBDIR := lpeg-$($(PKG)_VERSION) | ||
| 9 | $(PKG)_FILE := $($(PKG)_SUBDIR).tar.gz | ||
| 10 | $(PKG)_URL := http://www.inf.puc-rio.br/~roberto/$(PKG)/$($(PKG)_FILE) | ||
| 11 | $(PKG)_DEPS := gcc luarocks | ||
| 12 | |||
| 13 | define $(PKG)_UPDATE | ||
| 14 | $(WGET) -q -O- 'http://www.inf.puc-rio.br/~roberto/lpeg/' | \ | ||
| 15 | $(SED) -n 's,.*lpeg-\([0-9][^>]*\)\.tar.*,\1,p' | \ | ||
| 16 | sort -h | tail -1 | ||
| 17 | endef | ||
| 18 | |||
| 19 | # shared-only because luarocks is shared-only | ||
| 20 | |||
| 21 | define $(PKG)_BUILD_SHARED | ||
| 22 | cd '$(1)' && '$(TARGET)-luarocks' make | ||
| 23 | endef | ||
| @@ -0,0 +1,82 @@ | |||
| 1 | This file is part of MXE. | ||
| 2 | See index.html for further information. | ||
| 3 | |||
| 4 | From dbedfa6c3b350b6cb2c13d17790a17129ce28721 Mon Sep 17 00:00:00 2001 | ||
| 5 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 6 | Date: Sun, 11 Oct 2015 22:47:50 +0200 | ||
| 7 | Subject: [PATCH 1/2] use Unix file functions on MinGW | ||
| 8 | |||
| 9 | --- | ||
| 10 | src/rapidjson.cpp | 4 ++-- | ||
| 11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
| 12 | |||
| 13 | diff --git a/src/rapidjson.cpp b/src/rapidjson.cpp | ||
| 14 | index 3b5b129..955009f 100644 | ||
| 15 | --- a/src/rapidjson.cpp | ||
| 16 | +++ b/src/rapidjson.cpp | ||
| 17 | @@ -54,7 +54,7 @@ static void setfuncs(lua_State* L, const luaL_Reg *funcs) | ||
| 18 | FILE* openForRead(const char* filename) | ||
| 19 | { | ||
| 20 | FILE* fp = NULL; | ||
| 21 | -#if WIN32 | ||
| 22 | +#if WIN32 && !defined(__MINGW32__) | ||
| 23 | fopen_s(&fp, filename, "rb"); | ||
| 24 | #else | ||
| 25 | fp = fopen(filename, "r"); | ||
| 26 | @@ -66,7 +66,7 @@ FILE* openForRead(const char* filename) | ||
| 27 | FILE* openForWrite(const char* filename) | ||
| 28 | { | ||
| 29 | FILE* fp = NULL; | ||
| 30 | -#if WIN32 | ||
| 31 | +#if WIN32 && !defined(__MINGW32__) | ||
| 32 | fopen_s(&fp, filename, "wb"); | ||
| 33 | #else | ||
| 34 | fp = fopen(filename, "w"); | ||
| 35 | -- | ||
| 36 | 1.7.10.4 | ||
| 37 | |||
| 38 | |||
| 39 | From ad7426ad156f90dcf2b051fe125900caf5b8b2da Mon Sep 17 00:00:00 2001 | ||
| 40 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 41 | Date: Sun, 11 Oct 2015 22:48:26 +0200 | ||
| 42 | Subject: [PATCH 2/2] link with Lua libraries on MinGW and MXE | ||
| 43 | |||
| 44 | --- | ||
| 45 | rapidjson-0.2.2-1.rockspec | 15 ++++++++++----- | ||
| 46 | 1 file changed, 10 insertions(+), 5 deletions(-) | ||
| 47 | |||
| 48 | diff --git a/rapidjson-0.2.2-1.rockspec b/rapidjson-0.2.2-1.rockspec | ||
| 49 | index 9efe7e1..6ad9188 100644 | ||
| 50 | --- a/rapidjson-0.2.2-1.rockspec | ||
| 51 | +++ b/rapidjson-0.2.2-1.rockspec | ||
| 52 | @@ -27,6 +27,13 @@ dependencies = { | ||
| 53 | "lua >= 5.1" | ||
| 54 | } | ||
| 55 | |||
| 56 | +-- windows DLL needs link with importlib. | ||
| 57 | +local link = { | ||
| 58 | + variables = { | ||
| 59 | + LUA_LIBRARIES = "$(LUA_LIBDIR)/$(LUALIB)", | ||
| 60 | + } | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | -- cmake -Bbuild -H. -DBUILD_SHARED_LIBS=ON | ||
| 64 | -- cmake --build build --target install --config Release | ||
| 65 | build = { | ||
| 66 | @@ -39,10 +46,8 @@ build = { | ||
| 67 | }, | ||
| 68 | -- Override default build options | ||
| 69 | platforms = { | ||
| 70 | - windows = { | ||
| 71 | - variables = { | ||
| 72 | - LUA_LIBRARIES = "$(LUA_LIBDIR)/$(LUALIB)", -- windows DLL needs link with importlib. | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | + windows = link, | ||
| 76 | + mingw = link, | ||
| 77 | + mxe = link, | ||
| 78 | } | ||
| 79 | } | ||
| 80 | -- | ||
| 81 | 1.7.10.4 | ||
| 82 | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | # This file is part of MXE. | ||
| 2 | # See index.html for further information. | ||
| 3 | |||
| 4 | PKG := lua-rapidjson | ||
| 5 | $(PKG)_IGNORE := | ||
| 6 | $(PKG)_VERSION := 0.2.2-1 | ||
| 7 | $(PKG)_CHECKSUM := 10783d8633df3f50b1ad33c7de89d2a94a7d9cf45e2ce5217d0d2d5e77396fd2 | ||
| 8 | $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION) | ||
| 9 | $(PKG)_FILE := $($(PKG)_SUBDIR).tar.gz | ||
| 10 | $(PKG)_URL := https://github.com/xpol/lua-rapidjson/archive/v$($(PKG)_VERSION).tar.gz | ||
| 11 | $(PKG)_DEPS := gcc luarocks | ||
| 12 | |||
| 13 | define $(PKG)_UPDATE | ||
| 14 | $(call MXE_GET_GITHUB_TAGS, xpol/lua-rapidjson) | \ | ||
| 15 | $(SED) 's,^v,,g' | ||
| 16 | endef | ||
| 17 | |||
| 18 | # shared-only because luarocks is shared-only | ||
| 19 | |||
| 20 | define $(PKG)_BUILD_SHARED | ||
| 21 | cd '$(1)' && '$(TARGET)-luarocks' make | ||
| 22 | endef | ||
| @@ -0,0 +1,83 @@ | |||
| 1 | This file is part of MXE. | ||
| 2 | See index.html for further information. | ||
| 3 | |||
| 4 | From 5cd28e7a8f0de2539322ede15616904835a4dbe3 Mon Sep 17 00:00:00 2001 | ||
| 5 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 6 | Date: Sat, 10 Oct 2015 17:45:24 +0100 | ||
| 7 | Subject: [PATCH] platform MXE | ||
| 8 | |||
| 9 | diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua | ||
| 10 | index 00fd09e..a4985e9 100644 | ||
| 11 | --- a/src/luarocks/build/builtin.lua | ||
| 12 | +++ b/src/luarocks/build/builtin.lua | ||
| 13 | @@ -165,7 +165,7 @@ function builtin.run(rockspec) | ||
| 14 | add_flags(extras, "-Wl,-rpath,%s:", libdirs) | ||
| 15 | end | ||
| 16 | add_flags(extras, "-l%s", libraries) | ||
| 17 | - if cfg.is_platform("cygwin") then | ||
| 18 | + if cfg.is_platform("cygwin") or cfg.is_platform("mxe") then | ||
| 19 | add_flags(extras, "-l%s", {"lua"}) | ||
| 20 | end | ||
| 21 | return execute(variables.LD.." "..variables.LIBFLAG, "-o", library, "-L"..variables.LUA_LIBDIR, unpack(extras)) | ||
| 22 | diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua | ||
| 23 | index 99b4077..a17fbaa 100644 | ||
| 24 | --- a/src/luarocks/cfg.lua | ||
| 25 | +++ b/src/luarocks/cfg.lua | ||
| 26 | @@ -118,6 +118,9 @@ elseif system and system:match("^Windows") then | ||
| 27 | elseif system and system:match("^MINGW") then | ||
| 28 | detected.windows = true | ||
| 29 | detected.mingw32 = true | ||
| 30 | +elseif system and system:match("^MXE") then | ||
| 31 | + detected.unix = true | ||
| 32 | + detected.mxe = true | ||
| 33 | else | ||
| 34 | detected.unix = true | ||
| 35 | -- Fall back to Unix in unknown systems. | ||
| 36 | @@ -430,6 +433,44 @@ if detected.unix then | ||
| 37 | defaults.web_browser = "xdg-open" | ||
| 38 | end | ||
| 39 | |||
| 40 | +if detected.mxe then | ||
| 41 | + local MXE_ROOT, MXE_TARGET = | ||
| 42 | + assert(site_config.LUAROCKS_PREFIX:match('^(.*)/usr/([^/]+)$')) | ||
| 43 | + defaults.lib_extension = "dll" | ||
| 44 | + defaults.external_lib_extension = "dll" | ||
| 45 | + defaults.obj_extension = "obj" | ||
| 46 | + defaults.external_deps_dirs = { site_config.LUAROCKS_PREFIX } | ||
| 47 | + defaults.arch = "mxe-" .. MXE_TARGET | ||
| 48 | + defaults.platforms = {"unix", "mxe"} | ||
| 49 | + -- LUA_INCDIR and LUA_LIBDIR are defined in site_config.lua | ||
| 50 | + defaults.variables.LUA_BINDIR = site_config.LUAROCKS_PREFIX .. "/bin" | ||
| 51 | + defaults.cmake_generator = "Unix Makefiles" | ||
| 52 | + defaults.variables.MAKE = os.getenv("MAKE") | ||
| 53 | + defaults.variables.CMAKE = MXE_ROOT .. "/usr/bin/" .. MXE_TARGET .. "-cmake" | ||
| 54 | + defaults.variables.CC = MXE_ROOT .. "/usr/bin/" .. MXE_TARGET .. "-gcc" | ||
| 55 | + defaults.variables.LD = defaults.variables.CC | ||
| 56 | + defaults.variables.CFLAGS = "-O2" | ||
| 57 | + defaults.variables.LIBFLAG = "-shared" | ||
| 58 | + defaults.variables.LUALIB = "liblua.dll.a" | ||
| 59 | + | ||
| 60 | + defaults.export_path = "SET PATH=%s" | ||
| 61 | + defaults.export_path_separator = ";" | ||
| 62 | + defaults.export_lua_path = "SET LUA_PATH=%s" | ||
| 63 | + defaults.export_lua_cpath = "SET LUA_CPATH=%s" | ||
| 64 | + defaults.wrapper_suffix = ".bat" | ||
| 65 | + | ||
| 66 | + defaults.external_deps_patterns = { | ||
| 67 | + bin = { "?.exe", "?.bat" }, | ||
| 68 | + lib = { "?.dll.a", "lib?.dll.a" }, | ||
| 69 | + include = { "?.h" } | ||
| 70 | + } | ||
| 71 | + defaults.runtime_external_deps_patterns = { | ||
| 72 | + bin = { "?.exe", "?.bat" }, | ||
| 73 | + lib = { "?.dll", "lib?.dll" }, | ||
| 74 | + include = { "?.h" } | ||
| 75 | + } | ||
| 76 | +end | ||
| 77 | + | ||
| 78 | if detected.cygwin then | ||
| 79 | defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds | ||
| 80 | defaults.arch = "cygwin-"..proc | ||
| 81 | -- | ||
| 82 | 2.1.4 | ||
| 83 | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | # This file is part of MXE. | ||
| 2 | # See index.html for further information. | ||
| 3 | |||
| 4 | PKG := luarocks | ||
| 5 | $(PKG)_IGNORE := | ||
| 6 | $(PKG)_VERSION := 2.2.2 | ||
| 7 | $(PKG)_CHECKSUM := 4f0427706873f30d898aeb1dfb6001b8a3478e46a5249d015c061fe675a1f022 | ||
| 8 | $(PKG)_SUBDIR := luarocks-$($(PKG)_VERSION) | ||
| 9 | $(PKG)_FILE := $($(PKG)_SUBDIR).tar.gz | ||
| 10 | $(PKG)_URL := https://keplerproject.github.io/luarocks/releases/$($(PKG)_FILE) | ||
| 11 | $(PKG)_DEPS := gcc lua | ||
| 12 | |||
| 13 | lua_SHORTVER := $(call SHORT_PKG_VERSION,lua) | ||
| 14 | |||
| 15 | define $(PKG)_UPDATE | ||
| 16 | $(WGET) -q -O- 'https://keplerproject.github.io/luarocks/releases/' | \ | ||
| 17 | $(SED) -n 's,.*luarocks-\([0-9][^>]*\)\.tar.*,\1,p' | \ | ||
| 18 | sort -h | tail -1 | ||
| 19 | endef | ||
| 20 | |||
| 21 | # shared-only because Lua loads modules in runtime | ||
| 22 | |||
| 23 | define $(PKG)_BUILD_SHARED | ||
| 24 | cd '$(1)' && ./configure \ | ||
| 25 | --prefix='$(PREFIX)/$(TARGET)' \ | ||
| 26 | --rocks-tree='$(PREFIX)/$(TARGET)' \ | ||
| 27 | --lua-version='$(lua_SHORTVER)' \ | ||
| 28 | --with-lua='$(PREFIX)/$(TARGET)' \ | ||
| 29 | --with-lua-bin='$(PREFIX)/bin' \ | ||
| 30 | --with-downloader='wget' \ | ||
| 31 | --with-md5-checker='openssl' | ||
| 32 | $(MAKE) -C '$(1)' build install \ | ||
| 33 | LUAROCKS_UNAME_S="MXE" \ | ||
| 34 | LUAROCKS_UNAME_M="$(TARGET)" | ||
| 35 | ln -sf '$(PREFIX)/$(TARGET)/bin/luarocks' '$(PREFIX)/bin/$(TARGET)-luarocks' | ||
| 36 | |||
| 37 | # create wine wrapper for testing | ||
| 38 | echo 'LUA_PATH="$(PREFIX)/$(TARGET)/share/lua/$(lua_SHORTVER)/?.lua;$(PREFIX)/$(TARGET)/share/lua/$(lua_SHORTVER)/?/init.lua;$$LUA_PATH"' > '$(PREFIX)/bin/$(TARGET)-lua' | ||
| 39 | echo 'LUA_CPATH="$(PREFIX)/$(TARGET)/lib/lua/$(lua_SHORTVER)/?.dll;;$$LUA_CPATH"' >> '$(PREFIX)/bin/$(TARGET)-lua' | ||
| 40 | echo 'export LUA_PATH LUA_CPATH' >> '$(PREFIX)/bin/$(TARGET)-lua' | ||
| 41 | echo 'exec wine $(PREFIX)/$(TARGET)/bin/lua.exe "$$@"' >> '$(PREFIX)/bin/$(TARGET)-lua' | ||
| 42 | chmod +x '$(PREFIX)/bin/$(TARGET)-lua' | ||
| 43 | endef | ||
| @@ -0,0 +1,65 @@ | |||
| 1 | This file is part of MXE. | ||
| 2 | See index.html for further information. | ||
| 3 | |||
| 4 | From 11c943734757cf703daa6768b3919b7a580fe8b0 Mon Sep 17 00:00:00 2001 | ||
| 5 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 6 | Date: Sat, 10 Oct 2015 22:00:31 +0100 | ||
| 7 | Subject: [PATCH 1/2] build on MXE | ||
| 8 | |||
| 9 | --- | ||
| 10 | luasocket-scm-0.rockspec | 14 ++++++++++++-- | ||
| 11 | src/usocket_dummy.lua | 1 + | ||
| 12 | 2 files changed, 13 insertions(+), 2 deletions(-) | ||
| 13 | create mode 100644 src/usocket_dummy.lua | ||
| 14 | |||
| 15 | diff --git a/luasocket-scm-0.rockspec b/luasocket-scm-0.rockspec | ||
| 16 | index f86567b..9b4da80 100644 | ||
| 17 | --- a/luasocket-scm-0.rockspec | ||
| 18 | +++ b/luasocket-scm-0.rockspec | ||
| 19 | @@ -46,7 +46,14 @@ local function make_plat(plat) | ||
| 20 | "WINVER=0x0501", | ||
| 21 | "LUASOCKET_API=__declspec(dllexport)", | ||
| 22 | "MIME_API=__declspec(dllexport)" | ||
| 23 | - } | ||
| 24 | + }, | ||
| 25 | + mxe = { | ||
| 26 | + "LUASOCKET_DEBUG", | ||
| 27 | + "LUASOCKET_INET_PTON", | ||
| 28 | + "WINVER=0x0501", | ||
| 29 | + "LUASOCKET_API=__declspec(dllexport)", | ||
| 30 | + "MIME_API=__declspec(dllexport)" | ||
| 31 | + }, | ||
| 32 | } | ||
| 33 | local modules = { | ||
| 34 | ["socket.core"] = { | ||
| 35 | @@ -85,9 +92,11 @@ local function make_plat(plat) | ||
| 36 | incdir = "/src" | ||
| 37 | } | ||
| 38 | end | ||
| 39 | - if plat == "win32" or plat == "mingw32" then | ||
| 40 | + if plat == "win32" or plat == "mingw32" or plat == "mxe" then | ||
| 41 | modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c" | ||
| 42 | modules["socket.core"].libraries = { "ws2_32" } | ||
| 43 | + modules["socket.unix"] = "src/usocket_dummy.lua" | ||
| 44 | + modules["socket.serial"] = "src/usocket_dummy.lua" | ||
| 45 | end | ||
| 46 | return { modules = modules } | ||
| 47 | end | ||
| 48 | @@ -95,6 +104,7 @@ end | ||
| 49 | build = { | ||
| 50 | type = "builtin", | ||
| 51 | platforms = { | ||
| 52 | + mxe = make_plat("mxe"), | ||
| 53 | unix = make_plat("unix"), | ||
| 54 | macosx = make_plat("macosx"), | ||
| 55 | win32 = make_plat("win32"), | ||
| 56 | diff --git a/src/usocket_dummy.lua b/src/usocket_dummy.lua | ||
| 57 | new file mode 100644 | ||
| 58 | index 0000000..3cce676 | ||
| 59 | --- /dev/null | ||
| 60 | +++ b/src/usocket_dummy.lua | ||
| 61 | @@ -0,0 +1 @@ | ||
| 62 | +return error("This file was created to suppress build of usocket.c for MXE") | ||
| 63 | -- | ||
| 64 | 2.1.4 | ||
| 65 | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | This file is part of MXE. | ||
| 2 | See index.html for further information. | ||
| 3 | |||
| 4 | From 25007fd7fed18926728b9a1249f827a27e1d03f1 Mon Sep 17 00:00:00 2001 | ||
| 5 | From: Boris Nagaev <bnagaev@gmail.com> | ||
| 6 | Date: Sat, 10 Oct 2015 23:14:31 +0100 | ||
| 7 | Subject: [PATCH 2/2] luaL_checkint -> luaL_checkinteger | ||
| 8 | |||
| 9 | --- | ||
| 10 | gem/gem.c | 2 +- | ||
| 11 | src/luasocket.c | 2 +- | ||
| 12 | src/mime.c | 2 +- | ||
| 13 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
| 14 | |||
| 15 | diff --git a/gem/gem.c b/gem/gem.c | ||
| 16 | index 976f74d..40f33b0 100644 | ||
| 17 | --- a/gem/gem.c | ||
| 18 | +++ b/gem/gem.c | ||
| 19 | @@ -24,7 +24,7 @@ static int pushchar(int c, int last, const char *marker, | ||
| 20 | } | ||
| 21 | |||
| 22 | static int eol(lua_State *L) { | ||
| 23 | - int context = luaL_checkint(L, 1); | ||
| 24 | + int context = luaL_checkinteger(L, 1); | ||
| 25 | size_t isize = 0; | ||
| 26 | const char *input = luaL_optlstring(L, 2, NULL, &isize); | ||
| 27 | const char *last = input + isize; | ||
| 28 | diff --git a/src/luasocket.c b/src/luasocket.c | ||
| 29 | index e6ee747..1bdfb13 100644 | ||
| 30 | --- a/src/luasocket.c | ||
| 31 | +++ b/src/luasocket.c | ||
| 32 | @@ -64,7 +64,7 @@ static luaL_Reg func[] = { | ||
| 33 | * Skip a few arguments | ||
| 34 | \*-------------------------------------------------------------------------*/ | ||
| 35 | static int global_skip(lua_State *L) { | ||
| 36 | - int amount = luaL_checkint(L, 1); | ||
| 37 | + int amount = luaL_checkinteger(L, 1); | ||
| 38 | int ret = lua_gettop(L) - amount - 1; | ||
| 39 | return ret >= 0 ? ret : 0; | ||
| 40 | } | ||
| 41 | diff --git a/src/mime.c b/src/mime.c | ||
| 42 | index dd37dcf..bd9a2a9 100644 | ||
| 43 | --- a/src/mime.c | ||
| 44 | +++ b/src/mime.c | ||
| 45 | @@ -661,7 +661,7 @@ static int eolprocess(int c, int last, const char *marker, | ||
| 46 | \*-------------------------------------------------------------------------*/ | ||
| 47 | static int mime_global_eol(lua_State *L) | ||
| 48 | { | ||
| 49 | - int ctx = luaL_checkint(L, 1); | ||
| 50 | + int ctx = luaL_checkinteger(L, 1); | ||
| 51 | size_t isize = 0; | ||
| 52 | const char *input = luaL_optlstring(L, 2, NULL, &isize); | ||
| 53 | const char *last = input + isize; | ||
| 54 | -- | ||
| 55 | 2.1.4 | ||
| 56 | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | # This file is part of MXE. | ||
| 2 | # See index.html for further information. | ||
| 3 | |||
| 4 | PKG := luasocket | ||
| 5 | $(PKG)_IGNORE := | ||
| 6 | $(PKG)_VERSION := 3.0-rc1 | ||
| 7 | $(PKG)_CHECKSUM := 8b67d9b5b545e1b694753dab7bd6cdbc24c290f2b21ba1e14c77b32817ea1249 | ||
| 8 | $(PKG)_SUBDIR := luasocket-$($(PKG)_VERSION) | ||
| 9 | $(PKG)_FILE := $($(PKG)_SUBDIR).tar.gz | ||
| 10 | $(PKG)_URL := https://github.com/diegonehab/luasocket/archive/v$($(PKG)_VERSION).tar.gz | ||
| 11 | $(PKG)_DEPS := gcc luarocks | ||
| 12 | |||
| 13 | define $(PKG)_UPDATE | ||
| 14 | $(call MXE_GET_GITHUB_TAGS, diegonehab/luasocket) | \ | ||
| 15 | $(SED) 's,^v,,g' | ||
| 16 | endef | ||
| 17 | |||
| 18 | # shared-only because luarocks is shared-only | ||
| 19 | |||
| 20 | define $(PKG)_BUILD_SHARED | ||
| 21 | cd '$(1)' && '$(TARGET)-luarocks' make | ||
| 22 | endef | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | local lpeg = require 'lpeg' | ||
| 2 | assert(((lpeg.R('AZ'))^1):match("TEXT") == 5) | ||
| 3 | |||
| 4 | local http = require "socket.http" | ||
| 5 | assert(http.request("http://mxe.cc"):match('MXE')) | ||
| 6 | |||
| 7 | local ll = require 'llthreads2' | ||
| 8 | local thread = ll.new("return 123") | ||
| 9 | thread:start() | ||
| 10 | local ok, result = thread:join() | ||
| 11 | assert(ok) | ||
| 12 | assert(result == 123) | ||
| 13 | |||
| 14 | local rapidjson = require 'rapidjson' | ||
| 15 | assert(rapidjson.encode(123) == '123') | ||
| 16 | assert(rapidjson.decode('["xyz"]')[1] == "xyz") | ||