From e92c224e0797fec21b095b64fd331e8c6ae1d6bd Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Thu, 20 Dec 2018 20:50:18 -0500 Subject: [PATCH] Build fixes. --- 3rdparty/toluapp/CMakeLists.txt | 25 ++-- 3rdparty/toluapp/src/bin/tolua.c | 211 +++++++++++++++---------------- 2 files changed, 118 insertions(+), 118 deletions(-) diff --git a/3rdparty/toluapp/CMakeLists.txt b/3rdparty/toluapp/CMakeLists.txt index 8b9d9afb..ebf665d3 100644 --- a/3rdparty/toluapp/CMakeLists.txt +++ b/3rdparty/toluapp/CMakeLists.txt @@ -6,11 +6,12 @@ project ( toluapp C ) cmake_minimum_required ( VERSION 3.4 ) -include ( cmake/dist.cmake ) +# Disable dist stuff, we're not installing this as a lib +# include ( cmake/dist.cmake ) include(FindPkgConfig) -pkg_search_module(LUA REQUIRED lua>=5.3 lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52) +pkg_search_module(LUA REQUIRED lua>=5.3 lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 luajit) include_directories ( include src/lib ${LUA_INCLUDE_DIRS} ) # Build lib @@ -19,21 +20,23 @@ if ( MSVC ) set ( DEF_FILE libtoluapp.def ) endif ( ) -add_library ( toluapp_lib SHARED ${SRC_LIBTOLUAPP} ${DEF_FILE} ) +# add_library ( toluapp_lib SHARED ${SRC_LIBTOLUAPP} ${DEF_FILE} ) add_library ( toluapp_lib_static STATIC ${SRC_LIBTOLUAPP} ${DEF_FILE} ) -target_link_libraries ( toluapp_lib ${LUA_LIBRARIES} ) -set_target_properties ( toluapp_lib PROPERTIES OUTPUT_NAME toluapp CLEAN_DIRECT_OUTPUT +target_link_libraries ( toluapp_lib_static ${LUA_LIBRARIES} ) +set_target_properties ( toluapp_lib_static PROPERTIES COMPILE_FLAGS -fPIC) # -fPIC required for static linking +set_target_properties ( toluapp_lib_static PROPERTIES OUTPUT_NAME toluapp CLEAN_DIRECT_OUTPUT 1 ) # Build app include_directories ( src/bin ) set ( SRC_TOLUA src/bin/tolua.c src/bin/toluabind.c ) add_executable ( toluapp ${SRC_TOLUA} ) -target_link_libraries ( toluapp toluapp_lib ${LUA_LIBRARIES} ) +target_link_libraries ( toluapp toluapp_lib_static ${LUA_LIBRARIES} ) +# Disable installation, we don't need these at runtime for Conky # Install -install_library ( toluapp_lib ) -install_executable ( toluapp ) -install_header ( include/ ) -install_data ( README INSTALL ) -install_doc ( doc/ ) +#install_library ( toluapp_lib ) +#install_executable ( toluapp ) +#install_header ( include/ ) +#install_data ( README INSTALL ) +#install_doc ( doc/ ) diff --git a/3rdparty/toluapp/src/bin/tolua.c b/3rdparty/toluapp/src/bin/tolua.c index 65e3daf9..05758822 100644 --- a/3rdparty/toluapp/src/bin/tolua.c +++ b/3rdparty/toluapp/src/bin/tolua.c @@ -14,56 +14,58 @@ #include "tolua++.h" +#include "lauxlib.h" #include "lua.h" #include "lualib.h" -#include "lauxlib.h" #include #include #include -static void help(void) -{ - fprintf(stderr, "\n" - "usage: tolua++ [options] input_file\n" - "\n" - "Command line options are:\n" - " -v : print version information.\n" - " -o file : set output file; default is stdout.\n" - " -H file : create include file.\n" - " -n name : set package name; default is input file root name.\n" - " -p : parse only.\n" - " -P : parse and print structure information (for debug).\n" - " -S : disable support for c++ strings.\n" - " -1 : substract 1 to operator[] index (for compatibility with tolua5).\n" - " -L file : run lua file (with dofile()) before doing anything.\n" - " -D : disable automatic exporting of destructors for classes that have\n" - " constructors (for compatibility with tolua5)\n" - " -W : disable warnings for unsupported features (for compatibility\n" - " with tolua5)\n" - " -C : disable cleanup of included lua code (for easier debugging)\n" - " -E value[=value] : add extra values to the luastate\n" - " -t : export a list of types asociates with the C++ typeid name\n" - " -q : don't print warnings to the console\n" - " -h : print this message.\n" - "Should the input file be omitted, stdin is assumed;\n" - "in that case, the package name must be explicitly set.\n\n"); +static void help(void) { + fprintf( + stderr, + "\n" + "usage: tolua++ [options] input_file\n" + "\n" + "Command line options are:\n" + " -v : print version information.\n" + " -o file : set output file; default is stdout.\n" + " -H file : create include file.\n" + " -n name : set package name; default is input file root name.\n" + " -p : parse only.\n" + " -P : parse and print structure information (for debug).\n" + " -S : disable support for c++ strings.\n" + " -1 : substract 1 to operator[] index (for compatibility with " + "tolua5).\n" + " -L file : run lua file (with dofile()) before doing anything.\n" + " -D : disable automatic exporting of destructors for classes " + "that have\n" + " constructors (for compatibility with tolua5)\n" + " -W : disable warnings for unsupported features (for " + "compatibility\n" + " with tolua5)\n" + " -C : disable cleanup of included lua code (for easier " + "debugging)\n" + " -E value[=value] : add extra values to the luastate\n" + " -t : export a list of types asociates with the C++ typeid name\n" + " -q : don't print warnings to the console\n" + " -h : print this message.\n" + "Should the input file be omitted, stdin is assumed;\n" + "in that case, the package name must be explicitly set.\n\n"); } -static void version(void) -{ +static void version(void) { fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n", TOLUA_VERSION); } -static void setfield(lua_State *L, int table, const char *f, const char *v) -{ +static void setfield(lua_State *L, int table, const char *f, const char *v) { lua_pushstring(L, f); lua_pushstring(L, v); lua_settable(L, table); } -static void add_extra(lua_State *L, const char *value) -{ +static void add_extra(lua_State *L, const char *value) { int len; lua_getglobal(L, "_extra_parameters"); #if LUA_VERSION_NUM > 501 @@ -78,15 +80,13 @@ static void add_extra(lua_State *L, const char *value) static void error(char *o) __attribute__((noreturn)); -static void error(char *o) -{ +static void error(char *o) { fprintf(stderr, "tolua: unknown option '%s'\n", o); help(); exit(1); } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { #ifdef LUA_VERSION_NUM /* lua 5.1 */ lua_State *L = luaL_newstate(); luaL_openlibs(L); @@ -105,13 +105,10 @@ int main(int argc, char *argv[]) lua_pushstring(L, LUA_VERSION); lua_setglobal(L, "TOLUA_LUA_VERSION"); - if (argc == 1) - { + if (argc == 1) { help(); return 0; - } - else - { + } else { int i, t; lua_newtable(L); lua_setglobal(L, "_extra_parameters"); @@ -119,67 +116,63 @@ int main(int argc, char *argv[]) lua_pushvalue(L, -1); lua_setglobal(L, "flags"); t = lua_gettop(L); - for (i = 1; i < argc; ++i) - { - if (*argv[i] == '-') - { - switch (argv[i][1]) - { - case 'v': - version(); - return 0; - case 'h': - help(); - return 0; - case 'p': - setfield(L, t, "p", ""); - break; - case 'P': - setfield(L, t, "P", ""); - break; - case 'o': - setfield(L, t, "o", argv[++i]); - break; - case 'n': - setfield(L, t, "n", argv[++i]); - break; - case 'H': - setfield(L, t, "H", argv[++i]); - break; - case 'S': - setfield(L, t, "S", ""); - break; - case '1': - setfield(L, t, "1", ""); - break; - case 'L': - setfield(L, t, "L", argv[++i]); - break; - case 'D': - setfield(L, t, "D", ""); - break; - case 'W': - setfield(L, t, "W", ""); - break; - case 'C': - setfield(L, t, "C", ""); - break; - case 'E': - add_extra(L, argv[++i]); - break; - case 't': - setfield(L, t, "t", ""); - break; - case 'q': - setfield(L, t, "q", ""); - break; - default: - error(argv[i]); - break; + // Ignore the last arg in the arg list. + for (i = 1; i < argc - 1; ++i) { + if (*argv[i] == '-') { + switch (argv[i][1]) { + case 'v': + version(); + return 0; + case 'h': + help(); + return 0; + case 'p': + setfield(L, t, "p", ""); + break; + case 'P': + setfield(L, t, "P", ""); + break; + case 'o': + setfield(L, t, "o", argv[++i]); + break; + case 'n': + setfield(L, t, "n", argv[++i]); + break; + case 'H': + setfield(L, t, "H", argv[++i]); + break; + case 'S': + setfield(L, t, "S", ""); + break; + case '1': + setfield(L, t, "1", ""); + break; + case 'L': + setfield(L, t, "L", argv[++i]); + break; + case 'D': + setfield(L, t, "D", ""); + break; + case 'W': + setfield(L, t, "W", ""); + break; + case 'C': + setfield(L, t, "C", ""); + break; + case 'E': + add_extra(L, argv[++i]); + break; + case 't': + setfield(L, t, "t", ""); + break; + case 'q': + setfield(L, t, "q", ""); + break; + default: + error(argv[i]); + break; } - } - else - { + } else { setfield(L, t, "f", argv[i]); break; } @@ -194,15 +187,19 @@ int main(int argc, char *argv[]) } #else { - lua_pushstring(L, "/usr/share/toluapp/luapp/"); + // Take the path to the Lua sources from the last arg. + char *pkg_path = argv[argc - 1]; + char full_path[1024]; + strcpy(full_path, pkg_path); + strcat(full_path, "all.lua"); + + lua_pushstring(L, pkg_path); lua_setglobal(L, "path"); - if (luaL_loadfile(L, "/usr/share/toluapp/luapp/all.lua") != 0) - { + if (luaL_loadfile(L, full_path) != 0) { fprintf(stderr, "luaL_loadfile failed\n"); return 1; } - if (lua_pcall(L, 0, 0, 0) != 0) - { + if (lua_pcall(L, 0, 0, 0) != 0) { const char *errmsg = lua_tostring(L, -1); fprintf(stderr, "lua_pcall failed: %s\n", errmsg); lua_pop(L, 1);