- a little cleanup of building with lua and CMAKE

- added ability to force building without static libs in build script: -d=1
- added --lua-debug commandline option
This commit is contained in:
SoftCoder 2013-12-30 11:02:43 -08:00
parent 5c90b9148c
commit c7c82b56e1
5 changed files with 44 additions and 27 deletions

View File

@ -17,13 +17,19 @@ CPU_COUNT=-1
CMAKE_ONLY=0
MAKE_ONLY=0
CLANG_FORCED=0
WANT_STATIC_LIBS="-DWANT_STATIC_LIBS=ON"
while getopts "c:m:n:f:h" option; do
while getopts "c:d:m:n:f:h" option; do
case "${option}" in
c)
CPU_COUNT=${OPTARG}
# echo "${option} value: ${OPTARG}"
;;
d)
WANT_STATIC_LIBS="-DWANT_STATIC_LIBS=OFF"
# echo "${option} value: ${OPTARG}"
;;
m)
CMAKE_ONLY=${OPTARG}
# echo "${option} value: ${OPTARG}"
@ -39,9 +45,10 @@ while getopts "c:m:n:f:h" option; do
;;
h)
echo "Usage: $0 <option>"
echo " where <option> can be: -c=x, -m=1, -n=1, -f=1, -h"
echo " where <option> can be: -c=x, -d=1, -f=1, -m=1, -n=1, -h"
echo " option descriptions:"
echo " -c=x : Force the cpu / cores count to x - example: -c=4"
echo " -d=1 : Force DYNAMIC compile (do not want static libs)"
echo " -m=1 : Force running CMAKE only to create Make files (do not compile)"
echo " -n=1 : Force running MAKE only to compile (assume CMAKE already built make files)"
echo " -f=1 : Force using CLANG compiler"
@ -163,7 +170,7 @@ fi
if [ $MAKE_ONLY = 0 ]; then
echo "Calling cmake with EXTRA_CMAKE_OPTIONS = ${EXTRA_CMAKE_OPTIONS}"
cmake -DCMAKE_INSTALL_PREFIX='' -DWANT_DEV_OUTPATH=ON -DWANT_STATIC_LIBS=ON -DBUILD_MEGAGLEST_TESTS=ON -DBREAKPAD_ROOT=$BREAKPAD_ROOT $EXTRA_CMAKE_OPTIONS ..
cmake -DCMAKE_INSTALL_PREFIX='' -DWANT_DEV_OUTPATH=ON $WANT_STATIC_LIBS -DBUILD_MEGAGLEST_TESTS=ON -DBREAKPAD_ROOT=$BREAKPAD_ROOT $EXTRA_CMAKE_OPTIONS ..
if [ $? -ne 0 ]; then
echo 'ERROR: CMAKE failed.' >&2; exit 1
fi

View File

@ -20,17 +20,17 @@ ENDIF(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.hpp
PATHS /usr/include
/usr/include/lua
/usr/include/lua5.2
/usr/include/lua5.1
/usr/include/lua
/usr/include/lua5.2
/usr/include/lua5.1
IF(FreeBSD)
SET(PATHS "/usr/local/include/lua51")
ENDIF()
$ENV{LUA_HOME}
$ENV{LUA_HOME}
)
IF (LUA_STATIC AND NOT LUA_LIBRARIES)
FIND_LIBRARY(LUA_LIBRARIES NAMES liblua5.2.a liblua5.1.a liblua.a lua5.1 lua
FIND_LIBRARY(LUA_LIBRARIES NAMES liblua5.2.a liblua.a liblua5.1.a lua5.1 lua
PATHS
IF(FreeBSD)
SET(PATHS "/usr/local/lib/lua51")
@ -38,7 +38,7 @@ IF (LUA_STATIC AND NOT LUA_LIBRARIES)
$ENV{LUA_HOME})
ELSE()
FIND_LIBRARY(LUA_LIBRARIES NAMES lua5.2 lua5.1 lua
FIND_LIBRARY(LUA_LIBRARIES NAMES lua5.2 lua lua5.1
PATHS
IF(FreeBSD)
SET(PATHS "/usr/local/lib/lua51")

View File

@ -1428,6 +1428,7 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled = config.getBool("DebugUnitCommands","false");
SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled = config.getBool("DebugPathFinder","false");
SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled = config.getBool("DebugLUA","false");
LuaScript::setDebugModeEnabled(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled);
SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled = config.getBool("DebugSound","false");
SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true");
@ -3925,7 +3926,7 @@ int glestMain(int argc, char** argv) {
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERBOSE_MODE]) == true) {
SystemFlags::VERBOSE_MODE_ENABLED = true;
Thread::setEnableVerboseMode(true);
LuaScript::setDebugModeEnabled(true);
//LuaScript::setDebugModeEnabled(true);
}
// DEbug testing threads
//Thread::setEnableVerboseMode(true);
@ -4614,6 +4615,12 @@ int glestMain(int argc, char** argv) {
MeshCallbackTeamColor::noTeamColors = true;
}
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_DEBUG]) == true) {
printf("Forcing LUA debugging enabled!\n");
config.setBool("DebugLUA","true", true);
}
// Setup debug logging etc
setupLogging(config, haveSpecialOutputCommandLineOption);

View File

@ -42,6 +42,7 @@ const char *GAME_ARGS[] = {
"--opengl-info",
"--sdl-info",
"--lua-info",
"--lua-debug",
"--curl-info",
"--xerces-info",
@ -120,6 +121,7 @@ enum GAME_ARG_TYPE {
GAME_ARG_OPENGL_INFO,
GAME_ARG_SDL_INFO,
GAME_ARG_LUA_INFO,
GAME_ARG_LUA_DEBUG,
GAME_ARG_CURL_INFO,
GAME_ARG_XERCES_INFO,
@ -252,6 +254,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n%s\t\t\tdisplays your video driver's OpenGL info.",GAME_ARGS[GAME_ARG_OPENGL_INFO]);
printf("\n%s\t\t\tdisplays your SDL version information.",GAME_ARGS[GAME_ARG_SDL_INFO]);
printf("\n%s\t\t\tdisplays your LUA version information.",GAME_ARGS[GAME_ARG_LUA_INFO]);
printf("\n%s\t\t\tdisplays LUA debug information.",GAME_ARGS[GAME_ARG_LUA_DEBUG]);
printf("\n%s\t\t\tdisplays your CURL version information.",GAME_ARGS[GAME_ARG_CURL_INFO]);
printf("\n%s\t\t\tdisplays your XERCES version information.",GAME_ARGS[GAME_ARG_XERCES_INFO]);

View File

@ -212,7 +212,6 @@ void LuaScript::DumpGlobals()
void LuaScript::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
bool debugLuaDump = LuaScript::debugModeEnabled;
//try{
LuaHandle *L = luaState;
// push the first key (nil = beginning of table)
@ -237,7 +236,7 @@ void LuaScript::saveGame(XmlNode *rootNode) {
int key_type = lua_type(L, -2);
int value_type = lua_type(L, -1);
if(debugLuaDump == true) printf("LUA save key_type = %d, value_type = %d for var [%s]\n",key_type,value_type,lua_tostring(L, -2));
if(LuaScript::debugModeEnabled == true) printf("LUA save key_type = %d, value_type = %d for var [%s]\n",key_type,value_type,lua_tostring(L, -2));
// support only string keys
// globals aren't likely to have a non-string key, but just to be certain ...
@ -258,7 +257,7 @@ void LuaScript::saveGame(XmlNode *rootNode) {
// get the key as a string
string key_string = lua_tostring(L, -2); // no copy required - we already know this is a string
if(debugLuaDump == true) printf("key_string [%s]\n",key_string.c_str());
if(LuaScript::debugModeEnabled == true) printf("key_string [%s]\n",key_string.c_str());
// do not support variables that start with '_'
// lua has some predefined values like _VERSION. They all start with underscore
@ -295,14 +294,14 @@ void LuaScript::saveGame(XmlNode *rootNode) {
break;
case LUA_TTABLE:
{
if(debugLuaDump == true) printf("LUA TABLE DETECTED - START\n");
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE DETECTED - START\n");
for (lua_pushnil(L); lua_next(L, -2) ;) {
if(debugLuaDump == true) printf("LUA TABLE loop A\n");
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop A\n");
int tableKeyType = lua_type(L, -2);
int tableValueType = lua_type(L, -1);
if(debugLuaDump == true) printf("LUA TABLE loop item type [%s] key: %d value type: %d\n",lua_typename(L, tableValueType),tableKeyType,tableValueType);
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop item type [%s] key: %d value type: %d\n",lua_typename(L, tableValueType),tableKeyType,tableValueType);
switch (tableValueType) {
case LUA_TSTRING:
@ -317,11 +316,11 @@ void LuaScript::saveGame(XmlNode *rootNode) {
// Stack: value, key, table
std :: string value = "";
if(!lua_isnil(L, -1)) {
if(debugLuaDump == true) printf("LUA TABLE loop B\n");
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop B\n");
lua_pushvalue(L, -1);
if(debugLuaDump == true) printf("LUA TABLE loop C\n");
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop C\n");
if(tableValueType == LUA_TBOOLEAN ) {
value = lua_toboolean(L, -1) == 0 ? "false" : "true";
@ -330,13 +329,13 @@ void LuaScript::saveGame(XmlNode *rootNode) {
value = lua_tostring (L, -1);
}
if(debugLuaDump == true) printf("LUA TABLE loop D\n");
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop D\n");
lua_pop (L, 1);
}
lua_pop (L, 1);
if(debugLuaDump == true) printf("LUA TABLE value [%s]\n",value.c_str());
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE value [%s]\n",value.c_str());
// Stack: key, table
lua_pushvalue(L, -1);
@ -347,7 +346,7 @@ void LuaScript::saveGame(XmlNode *rootNode) {
// Stack: key, table
//std :: cout << key << "" << value << "\ n";
if(debugLuaDump == true) printf("[%s] [%s]\n",key.c_str(),value.c_str());
if(LuaScript::debugModeEnabled == true) printf("[%s] [%s]\n",key.c_str(),value.c_str());
if(value_string != "") {
value_string += "|||";
@ -359,6 +358,8 @@ void LuaScript::saveGame(XmlNode *rootNode) {
tableList.push_back(make_pair(make_pair(tableKeyType,key),make_pair(tableValueType,value)));
}
else {
if(LuaScript::debugModeEnabled == true) printf("***WARNING*** SKIPPING LUA TABLE because it has an unsupported embedded type: %d [%s]\n",tableValueType, lua_typename(L, tableValueType));
lua_pop(L, 1);
}
}
@ -372,7 +373,7 @@ void LuaScript::saveGame(XmlNode *rootNode) {
//}
if(skipTable == true) {
if(debugLuaDump == true) printf("#2 SKIPPING TABLE\n");
if(LuaScript::debugModeEnabled == true) printf("#2 SKIPPING TABLE\n");
}
else {
//vector<pair<pair<int,string>, pair<int,string>> > tableList;
@ -416,12 +417,11 @@ void LuaScript::saveGame(XmlNode *rootNode) {
}
void LuaScript::loadGame(const XmlNode *rootNode) {
bool debugLuaDump = LuaScript::debugModeEnabled;
if(debugLuaDump) printf("START [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(LuaScript::debugModeEnabled) printf("START [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
vector<XmlNode *> luaScriptNodeList = rootNode->getChildList("LuaScript");
if(debugLuaDump) printf("luaScriptNodeList.size(): %d\n",(int)luaScriptNodeList.size());
if(LuaScript::debugModeEnabled) printf("luaScriptNodeList.size(): %d\n",(int)luaScriptNodeList.size());
for(unsigned int i = 0; i < luaScriptNodeList.size(); ++i) {
XmlNode *node = luaScriptNodeList[i];
@ -429,7 +429,7 @@ void LuaScript::loadGame(const XmlNode *rootNode) {
string variable = node->getAttribute("variable")->getValue();
int value_type = node->getAttribute("value_type")->getIntValue();
if(debugLuaDump) printf("i: %d [%s] [%d]\n",i,variable.c_str(),value_type);
if(LuaScript::debugModeEnabled) printf("i: %d [%s] [%d]\n",i,variable.c_str(),value_type);
switch (value_type) {
case LUA_TSTRING:
@ -446,7 +446,7 @@ void LuaScript::loadGame(const XmlNode *rootNode) {
lua_newtable(luaState); /* We will pass a table */
vector<XmlNode *> luaScriptTableNode = node->getChildList("Table");
if(debugLuaDump) printf("luaScriptTableNode.size(): %d\n",(int)luaScriptTableNode.size());
if(LuaScript::debugModeEnabled) printf("luaScriptTableNode.size(): %d\n",(int)luaScriptTableNode.size());
for(unsigned int j = 0; j < luaScriptTableNode.size(); ++j) {
XmlNode *nodeTable = luaScriptTableNode[j];