refactor(lua): make Lua a required (non-optional) package
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
4eadd0b7d8
commit
c8b0c10c88
16 changed files with 9 additions and 67 deletions
|
@ -121,19 +121,14 @@ if(NOT "${TCMALLOC_FOUND}" AND "${TRACK_MEMORY_USAGE}" MATCHES "ON")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
find_package(Lua)
|
||||
if ("${LUA_FOUND}" MATCHES "TRUE")
|
||||
message(STATUS "Using Lua script language")
|
||||
set(EXTRA_LIBS ${EXTRA_LIBS} ${LUA_LIBRARIES})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I ${LUA_INCLUDE_DIR} -D LEAN_USE_LUA")
|
||||
if ("${HAS_LUA_NEWSTATE}$" MATCHES "TRUE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D LEAN_USE_LUA_NEWSTATE")
|
||||
endif()
|
||||
if ("${HAS_LUA_OBJLEN}$" MATCHES "TRUE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D LEAN_USE_LUA_OBJLEN")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "FAILED to find Lua script language, it will not be available")
|
||||
find_package(Lua REQUIRED)
|
||||
set(EXTRA_LIBS ${EXTRA_LIBS} ${LUA_LIBRARIES})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I ${LUA_INCLUDE_DIR}")
|
||||
if ("${HAS_LUA_NEWSTATE}$" MATCHES "TRUE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D LEAN_USE_LUA_NEWSTATE")
|
||||
endif()
|
||||
if ("${HAS_LUA_OBJLEN}$" MATCHES "TRUE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D LEAN_USE_LUA_OBJLEN")
|
||||
endif()
|
||||
|
||||
include_directories(${LEAN_SOURCE_DIR})
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <sstream>
|
||||
#include <lua.hpp>
|
||||
#include <utility>
|
||||
|
@ -210,4 +209,3 @@ void open_expr(lua_State * L) {
|
|||
set_global_function<expr_pi>(L, "Pi");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
class expr;
|
||||
|
@ -13,4 +12,3 @@ bool is_expr(lua_State * L, int idx);
|
|||
expr & to_expr(lua_State * L, int idx);
|
||||
int push_expr(lua_State * L, expr const & o);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <sstream>
|
||||
#include <lua.hpp>
|
||||
#include <cstring>
|
||||
|
@ -133,4 +132,3 @@ void open_format(lua_State * L) {
|
|||
set_global_function<format_space>(L, "space");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
class format;
|
||||
|
@ -13,4 +12,3 @@ bool is_format(lua_State * L, int idx);
|
|||
format & to_format(lua_State * L, int idx);
|
||||
int push_format(lua_State * L, format const & o);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -8,13 +8,11 @@ Author: Leonardo de Moura
|
|||
#include <sstream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <lua.hpp>
|
||||
#include "util/debug.h"
|
||||
#include "util/exception.h"
|
||||
#include "util/memory.h"
|
||||
#include "bindings/lua/leanlua_state.h"
|
||||
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
#include "bindings/lua/name.h"
|
||||
#include "bindings/lua/numerics.h"
|
||||
#include "bindings/lua/options.h"
|
||||
|
@ -88,30 +86,7 @@ void leanlua_state::dofile(char const * fname) {
|
|||
void leanlua_state::dostring(char const * str) {
|
||||
m_ptr->dostring(str);
|
||||
}
|
||||
}
|
||||
#else
|
||||
namespace lean {
|
||||
leanlua_state::leanlua_state() {
|
||||
}
|
||||
|
||||
leanlua_state::~leanlua_state() {
|
||||
}
|
||||
|
||||
[[ noreturn ]] void throw_lua_not_supported() {
|
||||
throw exception("Lean was compiled without Lua support");
|
||||
}
|
||||
|
||||
void leanlua_state::dofile(char const * fname) {
|
||||
throw_lua_not_supported();
|
||||
}
|
||||
|
||||
void leanlua_state::dostring(char const * str) {
|
||||
throw_lua_not_supported();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace lean {
|
||||
lua_exception::lua_exception(char const * lua_error):exception("") {
|
||||
lean_assert(lua_error);
|
||||
std::string fname;
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
#include "util/debug.h"
|
||||
#include "util/name.h"
|
||||
|
@ -88,4 +87,3 @@ void open_name(lua_State * L) {
|
|||
set_global_function<mk_name>(L, "name");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
class name;
|
||||
|
@ -14,4 +13,3 @@ name & to_name(lua_State * L, int idx);
|
|||
name to_name_ext(lua_State * L, int idx);
|
||||
int push_name(lua_State * L, name const & n);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <sstream>
|
||||
#include <lua.hpp>
|
||||
#include "util/debug.h"
|
||||
|
@ -235,4 +234,3 @@ void open_mpq(lua_State * L) {
|
|||
set_global_function<mk_mpq>(L, "mpq");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
class mpz;
|
||||
|
@ -19,4 +18,3 @@ bool is_mpq(lua_State * L, int idx);
|
|||
mpq & to_mpq(lua_State * L, int idx);
|
||||
int push_mpq(lua_State * L, mpq const & val);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <sstream>
|
||||
#include <lua.hpp>
|
||||
#include "util/debug.h"
|
||||
|
@ -198,4 +197,3 @@ void open_options(lua_State * L) {
|
|||
set_global_function<mk_option>(L, "options");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
class options;
|
||||
|
@ -13,4 +12,3 @@ bool is_options(lua_State * L, int idx);
|
|||
options & to_options(lua_State * L, int idx);
|
||||
int push_options(lua_State * L, options const & o);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <sstream>
|
||||
#include <lua.hpp>
|
||||
#include "util/debug.h"
|
||||
|
@ -208,4 +207,3 @@ void open_sexpr(lua_State * L) {
|
|||
set_global_function<mk_sexpr>(L, "sexpr");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
class sexpr;
|
||||
|
@ -13,4 +12,3 @@ bool is_sexpr(lua_State * L, int idx);
|
|||
sexpr & to_sexpr(lua_State * L, int idx);
|
||||
int push_sexpr(lua_State * L, sexpr const & e);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
@ -71,4 +70,3 @@ int safe_function_wrapper(lua_State * L, lua_CFunction f){
|
|||
return luaL_error(L, error_msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#ifdef LEAN_USE_LUA
|
||||
#include <lua.hpp>
|
||||
namespace lean {
|
||||
void setfuncs(lua_State * L, luaL_Reg const * l, int nup);
|
||||
|
@ -22,4 +21,3 @@ template<lua_CFunction F> void set_global_function(lua_State * L, char const * n
|
|||
lua_setglobal(L, name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue