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