From 7e4b8e330c99a1db81bdf12b7aab41f5890625e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Fri, 25 Feb 2011 20:55:03 +0100 Subject: Add statically linked sluift. diff --git a/3rdParty/Lua/SConscript b/3rdParty/Lua/SConscript index cd65061..c3e2801 100644 --- a/3rdParty/Lua/SConscript +++ b/3rdParty/Lua/SConscript @@ -68,6 +68,9 @@ if env.get("LUA_BUNDLED", False) : lua_env = myenv.Clone() lua_env.MergeFlags(lua_env["LUA_FLAGS"]) + if lua_env.get("HAVE_READLINE", False) : + lua_env.Append(CPPDEFINES = ["LUA_USE_READLINE"]) + lua_env.MergeFlags(lua_env["READLINE_FLAGS"]) lua_env.Program("lua", [ "src/linit.c", "src/lua.c", diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index af2d747..0c1cf94 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -499,6 +499,13 @@ conf.Finish() # Lua env["LUA_BUNDLED"] = 1 +# Readline +conf = Configure(conf_env) +if conf.CheckCHeader(["stdio.h", "readline/readline.h"]) and conf.CheckLib("readline") : + env["HAVE_READLINE"] = True + env["READLINE_FLAGS"] = { "LIBS": ["readline"] } +conf.Finish() + # Avahi avahi_conf_env = conf_env.Clone() avahi_flags = {} diff --git a/Sluift/SConscript b/Sluift/SConscript index dbf7459..49d6de3 100644 --- a/Sluift/SConscript +++ b/Sluift/SConscript @@ -1,4 +1,4 @@ -Import("env") +Import(["env", "conf_env"]) if env["SCONS_STAGE"] == "build" : myenv = env.Clone() @@ -15,3 +15,14 @@ if env["SCONS_STAGE"] == "build" : myenv.SharedLibrary("sluift", [ "sluift.cpp", ]) + + sluift_bin_env = myenv.Clone() + sluift_bin_env.Install(".", "#/3rdParty/Lua/src/lua.c") + if sluift_bin_env.get("HAVE_READLINE", False) : + sluift_bin_env.Append(CPPDEFINES = ["LUA_USE_READLINE"]) + sluift_bin_env.MergeFlags(sluift_bin_env["READLINE_FLAGS"]) + sluift_bin_env.Program("sluift", [ + "sluift.cpp", + "lua.c", + "linit.c", + ]) diff --git a/Sluift/linit.c b/Sluift/linit.c new file mode 100644 index 0000000..4a3bd24 --- /dev/null +++ b/Sluift/linit.c @@ -0,0 +1,39 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" +#include "sluift.h" + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {"sluift", luaopen_sluift}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + -- cgit v0.10.2-6-g49f6