Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luarocks #112

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
755217e
Add LuaRocks as a submodule
rpavlik Mar 14, 2012
ba2f6ae
Set up and actually go into luarocks
rpavlik Mar 14, 2012
81a0f30
Build luafilesystem
rpavlik Mar 14, 2012
b71b088
Shift things to be more correct
rpavlik Mar 14, 2012
2dab2bf
Tidy message if submodule is missing.
rpavlik Mar 14, 2012
ead5160
Make the suffix empty
rpavlik Mar 14, 2012
a31c090
make achieving luarocks a gauntlet that we skip if building lua as cpp
rpavlik Mar 14, 2012
cad2a3a
Install luasocket (using our modified rockspec)
rpavlik Mar 14, 2012
3abae51
Upgrade to luarocks post-2.0.12
rpavlik Mar 12, 2013
67c58df
Quote more things in the luarocks build.
rpavlik Mar 12, 2013
4dc5c3e
Only define LUA_BUILD_AS_DLL on Win32.
rpavlik Mar 12, 2013
7170019
Add define LUA_DL_USE_RTLD_GLOBAL to fix osgLua
rpavlik Mar 12, 2013
9c257fc
More "no need to define LUA_BUILD_AS_DLL when not Windows"
rpavlik Mar 12, 2013
783c0e7
Adjust/extend search path for Lua.
rpavlik Mar 12, 2013
80e55a4
Generate/install in root output dir.
rpavlik Mar 13, 2013
1dcba8d
Add SearchPath simple class
rpavlik Mar 13, 2013
303cec4
Cleanup
rpavlik Mar 13, 2013
8707ebe
AddToLuaPath
rpavlik Mar 13, 2013
26fdfc2
Clean up and fix
rpavlik Mar 13, 2013
cca7ed4
Remove unused methods
rpavlik Mar 13, 2013
c0bd706
add method to LuaPath to get the lua directory.
rpavlik Mar 13, 2013
1a442d8
Replace usage of the luapath object to do the dirty work of updating …
rpavlik Mar 13, 2013
2fc4162
Remove dead code we just replaced.
rpavlik Mar 13, 2013
01aeff3
Clean up and re-organize a bit.
rpavlik Mar 13, 2013
5ec86ac
Add extend as a member of the search path base.
rpavlik Mar 13, 2013
7943641
Use that member function to keep it tidy and expressive
rpavlik Mar 13, 2013
1ee97db
Remove some old duplicated code
rpavlik Mar 13, 2013
08f875f
Factor out duplicated code.
rpavlik Mar 13, 2013
9da9b1d
Put in some error checking.
rpavlik Mar 13, 2013
a9727d6
Fix/simplify root dir paths
rpavlik Mar 13, 2013
a0979fc
Add LuaPathUpdater, which handles luabind interaction and RAII
rpavlik Mar 13, 2013
24c3d9c
Use the LuaPathUpdater
rpavlik Mar 13, 2013
d696680
Add back a function to LuaPath because SPARTA uses it. Mark as deprec…
rpavlik Mar 13, 2013
a1591a6
Fix paths to C libs
rpavlik Mar 13, 2013
cd8ae8c
fix luarocks submodule (old commit hash didn't exist, resulted in fat…
Aug 14, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "doc/generation/LDoc"]
path = doc/generation/LDoc
url = https://github.com/stevedonovan/LDoc.git
[submodule "third-party/luarocks"]
path = third-party/luarocks
url = https://github.com/vancegroup/luarocks.git
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ endif()
if(NOT SHARE_OUTPUT_DIRECTORY)
set(SHARE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/share)
endif()
if(NOT ROOT_OUTPUT_DIRECTORY)
set(ROOT_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()

# Define Simple Options
option(BUILD_DOCS "Add a target to build documentation" on)
Expand Down
23 changes: 21 additions & 2 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ endif()

if(BUILD_EMBEDDED_LUA)
# Lua 5.1.5
if(BUILD_SHARED_LUA)
if(BUILD_SHARED_LUA AND WIN32)
set(LUA_DEFINITIONS "-DLUA_BUILD_AS_DLL")
set(LUA_DEFINITIONS ${LUA_DEFINITIONS} PARENT_SCOPE)
endif()
add_subdirectory(lua-5.1.5/src)
set(LUA_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lua-5.1.5/src")
set(LUA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lua-5.1.5/src")
set(LUA_INCLUDE_DIRS "${LUA_INCLUDE_DIR}")
set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIRS} PARENT_SCOPE)
set(LUA_LIBRARY lua)
set(LUA_LIBRARIES lua)
set(LUA_LIBRARIES ${LUA_LIBRARIES} PARENT_SCOPE)
set(LUA_INTERPRETER "lua-interp")
set(LUA51_FOUND YES)

add_definitions(${LUA_DEFINITIONS})
Expand All @@ -37,3 +40,19 @@ endif()
add_subdirectory(stdlib/modules)

add_subdirectory(lua_modules)

if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/luarocks/CMakeLists.txt")
message(STATUS "NOTE: Skipping LuaRocks because the submodule is missing. Try 'git submodule update --init --recursive'")

elseif(BUILD_LUA_AS_CPP)
message(STATUS "NOTE: Skipping LuaRocks because BUILD_LUA_AS_CPP is set which would confuse most compiled modules.")

else()
set(LUAROCKS_LUA_SUFFIX "")
add_subdirectory(luarocks)
include(luarocks/UseLuarocks.cmake)

luarocks_install(luarocks-luafilesystem luafilesystem "${ROOT_OUTPUT_DIRECTORY}")

luarocks_install(luarocks-luasocket "${CMAKE_CURRENT_SOURCE_DIR}/luasocket-2.0.2-5.rockspec" "${ROOT_OUTPUT_DIRECTORY}")
endif()
4 changes: 3 additions & 1 deletion third-party/lua-5.1.5/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ set(LUA_EXTRA_LIBS ${LUA_EXTRA_LIBS} CACHE INTERNAL "" FORCE)

if(BUILD_SHARED_LUA)
set(LIBTYPE SHARED)
set(LUALIB_EXTRA_DEFINES LUA_BUILD_AS_DLL)
if(WIN32)
set(LUALIB_EXTRA_DEFINES LUA_BUILD_AS_DLL)
endif()
else()
set(LIBTYPE STATIC)
set(LUALIB_EXTRA_DEFINES)
Expand Down
3 changes: 2 additions & 1 deletion third-party/lua-5.1.5/src/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ union luai_Cast { double l_d; long l_l; };
** without modifying the main part of the file.
*/


/* Required for osgLua to work properly. */
#define LUA_DL_USE_RTLD_GLOBAL

#endif

1 change: 1 addition & 0 deletions third-party/luarocks
Submodule luarocks added at d5798d
65 changes: 65 additions & 0 deletions third-party/luasocket-2.0.2-5.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- This is an unofficial modified version of the 2.0.2-5 rockspec that replaces
-- the Windows build system so that it actually works.

package = "LuaSocket"
version = "2.0.2-5"
source = {
url = "http://luaforge.net/frs/download.php/2664/luasocket-2.0.2.tar.gz",
md5 = "41445b138deb7bcfe97bff957503da8e"
}
description = {
summary = "Network support for the Lua language",
detailed = [[
LuaSocket is a Lua extension library that is composed by two parts: a C core
that provides support for the TCP and UDP transport layers, and a set of Lua
modules that add support for functionality commonly needed by applications
that deal with the Internet.
]],
homepage = "http://luaforge.net/projects/luasocket/",
license = "MIT"
}
dependencies = {
"lua >= 5.1, < 5.2"
}
build = {
type = "make",
build_variables = {
CFLAGS = "$(CFLAGS) -DLUASOCKET_DEBUG -I$(LUA_INCDIR)",
LDFLAGS = "$(LIBFLAG) -O -fpic",
LD = "$(CC)"
},
install_variables = {
INSTALL_TOP_SHARE = "$(LUADIR)",
INSTALL_TOP_LIB = "$(LIBDIR)"
},
platforms = {
macosx = {
build_variables = {
CFLAGS = "$(CFLAGS) -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN -fno-common -I$(LUA_INCDIR)"
}
},
windows={
type="builtin",
modules = {
["ltn12"] = "src/ltn12.lua",
mime = "src/mime.lua",
socket = "src/socket.lua",
["socket.ftp"] = "src/ftp.lua",
["socket.http"] = "src/http.lua",
["socket.smtp"] = "src/smtp.lua",
["socket.tp"] = "src/tp.lua",
["socket.url"] = "src/url.lua",
["mime.core"] = {
sources = {"src/mime.c"},
defines = {"MIME_EXPORTS", "MIME_API=__declspec(dllexport)"}
},
["socket.core"] = {
sources = {"src/auxiliar.c", "src/buffer.c", "src/except.c", "src/inet.c", "src/io.c", "src/luasocket.c", "src/options.c", "src/select.c", "src/tcp.c", "src/timeout.c", "src/udp.c", "src/wsocket.c"},
defines = {"LUASOCKET_EXPORTS", "LUASOCKET_API=__declspec(dllexport)"},
libraries = {"ws2_32"}
}
}
}
},
copy_directories = { "doc", "samples", "etc", "test" }
}
135 changes: 135 additions & 0 deletions vrjugglua/AddToLuaPaths.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
@file
@brief Implementation

@date 2013

@author
Ryan Pavlik
<[email protected]> and <[email protected]>
http://academic.cleardefinition.com/
Iowa State University Virtual Reality Applications Center
Human-Computer Interaction Graduate Program
*/

// Copyright Iowa State University 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

// Internal Includes
#include "AddToLuaPaths.h"

// Library/third-party includes
#include <boost/foreach.hpp>

// Standard includes
// - none

namespace vrjLua {
#define LUA_VER "5.1"

namespace {
template<typename T>
class PushBackFunctor {
public:
PushBackFunctor(T & container) : _container(container) {}
void operator()(typename T::value_type a) {
_container.push_back(a);
}
private:
T & _container;
};
} // end of namespace

namespace detail {
template<typename SearchTag>
struct GetDirsFromRoot {
static const char * dirs[];
};

template<>
const char * GetDirsFromRoot<LuaPathTags::LuaSearch>::dirs[] = {
"share/vrjugglua/lua/",
"share/lua/" LUA_VER "/",
"lib/lua/" LUA_VER "/"
};

template<>
const char * GetDirsFromRoot<LuaPathTags::LuaCSearch>::dirs[] = {
"lib/lua/" LUA_VER "/",
"lib/"
#ifdef _WIN32
,
"bin/"
#endif
};

template<typename SearchTag>
struct CallWithPatterns;

template<>
struct CallWithPatterns<LuaPathTags::LuaSearch> {
template<typename F>
static void apply(std::string const& dir, F func) {
static const char * luaPatterns[] = {
"?.lua",
"?/init.lua"
};
BOOST_FOREACH(const char * patt, luaPatterns) {
func(dir + patt);
}
}
};

template<>
struct CallWithPatterns<LuaPathTags::LuaCSearch> {
template<typename F>
static void apply(std::string const& dir, F func) {
#ifdef _WIN32
static const char luaCPattern[] = "?.dll";
#else
static const char luaCPattern[] = "?.so";
#endif
func(dir + luaCPattern);
}
};


template<typename DirectoryTag, typename SearchTag>
struct CallWithDirectory;

template<typename SearchTag>
struct CallWithDirectory<LuaPathTags::RootDirectory, SearchTag> {
template<typename F>
static void apply(std::string const& rootdir, F func) {
BOOST_FOREACH(const char * patt, GetDirsFromRoot<SearchTag>::dirs) {
CallWithPatterns<SearchTag>::apply(rootdir + patt, func);
}
}
};

template<typename SearchTag>
struct CallWithDirectory<LuaPathTags::SearchDirectory, SearchTag> {
template<typename F>
static void apply(std::string const& rootdir, F func) {
CallWithPatterns<SearchTag>::apply(rootdir, func);
}
};

template<typename DirectoryTag, typename SearchTag>
void extendLuaSearchPath(DirectoryBase<DirectoryTag> const& d, SearchPathContainerBase<SearchTag> & s) {
typedef std::vector<std::string> StringList;
StringList newpaths;
CallWithDirectory<DirectoryTag, SearchTag>::apply(d.get(), PushBackFunctor<StringList>(newpaths));
s.insert(newpaths);
}

// Explicit instantiation of function template above, so we can hide this all in the CPP file.
template void extendLuaSearchPath(DirectoryBase<LuaPathTags::RootDirectory> const&, SearchPathContainerBase<LuaPathTags::LuaSearch> &);
template void extendLuaSearchPath(DirectoryBase<LuaPathTags::SearchDirectory> const&, SearchPathContainerBase<LuaPathTags::LuaSearch> &);
template void extendLuaSearchPath(DirectoryBase<LuaPathTags::RootDirectory> const&, SearchPathContainerBase<LuaPathTags::LuaCSearch> &);
template void extendLuaSearchPath(DirectoryBase<LuaPathTags::SearchDirectory> const&, SearchPathContainerBase<LuaPathTags::LuaCSearch> &);
} // end of namespace detail

} // end of namespace vrjLua
Loading