[Luarocks-developers] [patch] msvc compilation under cygwin
David Manura
dm.lua at math2.org
Sat Aug 30 22:50:33 GMT+2 2008
The attached patch allows LuaRocks to install from source under Cygwin
via configure and then compile modules natively with MSVC++. LuaRocks
can also use the command-line utilities that come with Cygwin rather
than the native the UnxUtils previously bundled.
There is a new "--target" switch in configure that enables this
behavior. Typical example:
./configure --prefix=/usr/local/luavc --with-lua=/usr/local/luavc
--target=windows
Without the --target=windows switch, LuaRocks would compile Cygwin
binaries under gcc. A future extension to this would be to support an
additional value like "--target=windows-mingw" to enable LuaRocks to
compile modules with MinGW (i.e. "gcc -mno-cygwin"). This switch
might be further generalized to support cross-compilation under other
platforms.
To support, MSVC++ builds, a new LUA_LIB variable has been defined
under Windows. This is set automatically to $LUA_LIBDIR/lua5.1.lib or
$LUA_LIBDIR/lua51.lib depending on which is auto-detected (since Lua
and Lua Binaries name this file differently), though it can also be
explicitly specified with the (possibly not ideally named)
--with-lua-lib-lib. Hard-coded values should be removed from some of
the .rockspec files, such as
$ diff -u md5-1.1.2-1.rockspec~ md5-1.1.2-1.rockspec
--- md5-1.1.2-1.rockspec~ 2008-08-30 19:38:27.968750000 -0400
+++ md5-1.1.2-1.rockspec 2008-08-30 14:31:48.140625000 -0400
@@ -24,16 +24,10 @@
build_variables = {
LIB_OPTION = "$(LIBFLAG)",
CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)",
+ LUA_LIB = "$(LUA_LIB)"
},
install_variables = {
LUA_LIBDIR = "$(LIBDIR)",
LUA_DIR = "$(LUADIR)"
- },
- platforms = {
- win32 = {
- build_variables = {
- LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib"
- }
- }
}
Another change is that the Makefile installs the luarocks and
luarocks-admin shell scripts differently under Cygwin/MSVC++. For
instance, for luarocks, it installs luarocks.bat (DOS batch) and
luarocks (Cygwin shell script), both of which invokve luarocks.lua.
You may invoke either depending on which is most convenient (e.g.
whether you are in or outside the Cygwin shell). The change to the
shell script was also necessary since UNIX-style program paths cannot
be sent to a native Windows version of lua.exe via the shell script
shebang line. (BTW, the behavior of the Makefile overwriting source
files causes some confusion/complications, and some of that was
removed in making this change.)
The two fixes made to fs/win32.lua handle "find" under Cygwin, which
can return paths prefixed by "./" and implement a native Windows
current_dir to ensures Windows style paths.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: luarocks-patch
Type: application/octet-stream
Size: 10565 bytes
Desc: not available
Url : http://lists.luaforge.net/pipermail/luarocks-developers/attachments/20080830/cec14db3/luarocks-patch.obj
More information about the Luarocks-developers
mailing list