Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2236


Ignore:
Timestamp:
Nov 20, 2008, 8:51:44 PM (15 years ago)
Author:
rgrieder
Message:
  • Changed working directory for tolua generator to library_output_path. That resolves windows issues with dlls.
  • Removed the need to create a second tolua application. There is only one now called toluaexe_orxonox.
  • 'w' (working directory) option of tolua extends to -L, pkg-file, -o and -H if of course -w is present
  • 's' option added to tolua: Tells which file contains the bindfile generator. In our case this is src/tolua/all.lua all.lua replaces tolua-5.1.pkg. We can still choose that file from CMake (TOLUA_PARSER_SOURCE)
  • Generator dependencies are declared in src/tolua/CMakeLists.txt and used in UseTolua.cmake (PARENT_SCOPE)
  • Fixed a bug when writing the header file inclusion in package.lua
Location:
code/branches/buildsystem
Files:
3 deleted
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem/cmake/UseTolua.cmake

    r2233 r2236  
    1616#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
    1717
    18 SET(_tolua_executable_name tolua_orxonox)
     18SET(_tolua_executable_name toluaexe_orxonox)
    1919GET_TARGET_PROPERTY(TOLUA_EXECUTABLE "${_tolua_executable_name}" LOCATION)
    2020
     
    3333  SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg")
    3434  SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.cc")
    35   SET(_tolua_hfile "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.h")
     35  SET(_tolua_hfile   "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.h")
    3636  SET(${_tolua_srcfiles_varname} ${${_tolua_srcfiles_varname}} "${_tolua_cxxfile}")
    3737
     
    4444  ADD_CUSTOM_COMMAND(
    4545    OUTPUT "${_tolua_cxxfile}" "${_tolua_hfile}"
    46     COMMAND "${TOLUA_EXECUTABLE}" -n "${_tolua_package}" -w ${CMAKE_CURRENT_SOURCE_DIR} -o "${_tolua_cxxfile}" -H "${_tolua_hfile}" "${_tolua_pkgfile}"
    47     DEPENDS "${_tolua_executable_name}" ${_tolua_inputfiles}
    48     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
     46    COMMAND "${TOLUA_EXECUTABLE}" -n "${_tolua_package}"
     47                                  -w "${CMAKE_CURRENT_SOURCE_DIR}"
     48                                  -o "${_tolua_cxxfile}"
     49                                  -H "${_tolua_hfile}"
     50                                  -s "${TOLUA_PARSER_SOURCE}"
     51                                     "${_tolua_pkgfile}"
     52    DEPENDS "${_tolua_executable_name}" ${_tolua_inputfiles} ${TOLUA_PARSER_DEPENDENCIES}
     53    WORKING_DIRECTORY "${LIBRARY_OUTPUT_PATH}"
    4954  )
    5055ENDMACRO(TOLUA)
  • code/branches/buildsystem/src/tolua/CMakeLists.txt

    r2233 r2236  
    1 # TODO: only build the object files once
    2 
    3 SET (TOLUALIB_SRC_FILES
     1SET(TOLUALIB_SRC_FILES
    42  tolua_event.c
    53  tolua_is.c
     
    97)
    108
    11 ADD_LIBRARY (tolualib_orxonox SHARED ${TOLUALIB_SRC_FILES})
    12 TARGET_LINK_LIBRARIES (tolualib_orxonox ${LUA_LIBRARIES})
     9ADD_LIBRARY          (tolualib_orxonox SHARED ${TOLUALIB_SRC_FILES})
     10TARGET_LINK_LIBRARIES(tolualib_orxonox ${LUA_LIBRARIES})
    1311
    14 SET (TOLUAGEN_SRC_FILES
     12
     13SET(TOLUAGEN_SRC_FILES
    1514  tolua.c
    16   toluabind.c
    1715)
    1816
    19 ADD_EXECUTABLE (toluagen_orxonox ${TOLUAGEN_SRC_FILES} ${TOLUALIB_SRC_FILES})
    20 TARGET_LINK_LIBRARIES (toluagen_orxonox ${LUA_LIBRARIES})
     17ADD_EXECUTABLE       (toluaexe_orxonox ${TOLUAGEN_SRC_FILES})
     18TARGET_LINK_LIBRARIES(toluaexe_orxonox tolualib_orxonox ${LUA_LIBRARIES})
    2119
    22 SET (TOLUA_PACKAGE "${CMAKE_CURRENT_SOURCE_DIR}/tolua-5.1.pkg")
    23 GET_TARGET_PROPERTY(TOLUAGEN_EXE toluagen_orxonox LOCATION)
    24 ADD_CUSTOM_COMMAND(
    25   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/toluabind_orxonox.c
    26   COMMAND ${TOLUAGEN_EXE} -n tolua -w ${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/toluabind_orxonox.c -H ${CMAKE_CURRENT_BINARY_DIR}/toluabind_orxonox.h ${TOLUA_PACKAGE}
    27   DEPENDS
    28     toluagen_orxonox
    29     tolua-5.1.pkg
    30     lua/compat-5.1.lua
    31     lua/compat.lua
    32     lua/basic.lua
    33     lua/feature.lua
    34     lua/verbatim.lua
    35     lua/code.lua
    36     lua/typedef.lua
    37     lua/container.lua
    38     lua/package.lua
    39     lua/module.lua
    40     lua/namespace.lua
    41     lua/define.lua
    42     lua/enumerate.lua
    43     lua/declaration.lua
    44     lua/variable.lua
    45     lua/array.lua
    46     lua/function.lua
    47     lua/operator.lua
    48     lua/class.lua
    49     lua/clean.lua
    50     lua/doit.lua
    51     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     20SET(TOLUA_PARSER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/all.lua" PARENT_SCOPE)
     21SET(TOLUA_PARSER_DEPENDENCIES
     22  ${CMAKE_CURRENT_SOURCE_DIR}/all.lua
     23  ${CMAKE_CURRENT_SOURCE_DIR}/lua/compat-5.1.lua
     24  ${CMAKE_CURRENT_SOURCE_DIR}/lua/compat.lua
     25  ${CMAKE_CURRENT_SOURCE_DIR}/lua/basic.lua
     26  ${CMAKE_CURRENT_SOURCE_DIR}/lua/feature.lua
     27  ${CMAKE_CURRENT_SOURCE_DIR}/lua/verbatim.lua
     28  ${CMAKE_CURRENT_SOURCE_DIR}/lua/code.lua
     29  ${CMAKE_CURRENT_SOURCE_DIR}/lua/typedef.lua
     30  ${CMAKE_CURRENT_SOURCE_DIR}/lua/container.lua
     31  ${CMAKE_CURRENT_SOURCE_DIR}/lua/package.lua
     32  ${CMAKE_CURRENT_SOURCE_DIR}/lua/module.lua
     33  ${CMAKE_CURRENT_SOURCE_DIR}/lua/namespace.lua
     34  ${CMAKE_CURRENT_SOURCE_DIR}/lua/define.lua
     35  ${CMAKE_CURRENT_SOURCE_DIR}/lua/enumerate.lua
     36  ${CMAKE_CURRENT_SOURCE_DIR}/lua/declaration.lua
     37  ${CMAKE_CURRENT_SOURCE_DIR}/lua/variable.lua
     38  ${CMAKE_CURRENT_SOURCE_DIR}/lua/array.lua
     39  ${CMAKE_CURRENT_SOURCE_DIR}/lua/function.lua
     40  ${CMAKE_CURRENT_SOURCE_DIR}/lua/operator.lua
     41  ${CMAKE_CURRENT_SOURCE_DIR}/lua/class.lua
     42  ${CMAKE_CURRENT_SOURCE_DIR}/lua/clean.lua
     43  ${CMAKE_CURRENT_SOURCE_DIR}/lua/doit.lua
     44
     45  PARENT_SCOPE
    5246)
    53 
    54 SET (TOLUAEXE_SRC_FILES
    55   tolua.c
    56   toluabind_orxonox.c
    57 )
    58 
    59 ADD_EXECUTABLE (tolua_orxonox ${TOLUAEXE_SRC_FILES} ${TOLUALIB_SRC_FILES})
    60 TARGET_LINK_LIBRARIES (tolua_orxonox ${LUA_LIBRARIES})
  • code/branches/buildsystem/src/tolua/all.lua

    • Property svn:mergeinfo set to (toggle deleted branches)
      /code/branches/ceguilua/src/tolua/lua/all.lua1802-1808
      /code/branches/core3/src/tolua/lua/all.lua1572-1739
      /code/branches/gcc43/src/tolua/lua/all.lua1580
      /code/branches/gui/src/tolua/lua/all.lua1635-1723
      /code/branches/input/src/tolua/lua/all.lua1629-1636
    r2235 r2236  
    1 dofile(path.."compat-5.1.lua")
    2 dofile(path.."compat.lua")
    3 dofile(path.."basic.lua")
    4 dofile(path.."feature.lua")
    5 dofile(path.."verbatim.lua")
    6 dofile(path.."code.lua")
    7 dofile(path.."typedef.lua")
    8 dofile(path.."container.lua")
    9 dofile(path.."package.lua")
    10 dofile(path.."module.lua")
    11 dofile(path.."namespace.lua")
    12 dofile(path.."define.lua")
    13 dofile(path.."enumerate.lua")
    14 dofile(path.."declaration.lua")
    15 dofile(path.."variable.lua")
    16 dofile(path.."array.lua")
    17 dofile(path.."function.lua")
    18 dofile(path.."operator.lua")
    19 dofile(path.."class.lua")
    20 dofile(path.."clean.lua")
    21 --dofile(path.."custom.lua")
    22 dofile(path.."doit.lua")
     1dofile(path.."lua/compat-5.1.lua")
     2dofile(path.."lua/compat.lua")
     3dofile(path.."lua/basic.lua")
     4dofile(path.."lua/feature.lua")
     5dofile(path.."lua/verbatim.lua")
     6dofile(path.."lua/code.lua")
     7dofile(path.."lua/typedef.lua")
     8dofile(path.."lua/container.lua")
     9dofile(path.."lua/package.lua")
     10dofile(path.."lua/module.lua")
     11dofile(path.."lua/namespace.lua")
     12dofile(path.."lua/define.lua")
     13dofile(path.."lua/enumerate.lua")
     14dofile(path.."lua/declaration.lua")
     15dofile(path.."lua/variable.lua")
     16dofile(path.."lua/array.lua")
     17dofile(path.."lua/function.lua")
     18dofile(path.."lua/operator.lua")
     19dofile(path.."lua/class.lua")
     20dofile(path.."lua/clean.lua")
     21--dofile(path.."lua/custom.lua")
     22dofile(path.."lua/doit.lua")
    2323
    2424local err,msg = xpcall(doit, debug.traceback)
  • code/branches/buildsystem/src/tolua/lua/doit.lua

    r2229 r2236  
    3939    parse_extra()
    4040
     41    -- get potential working directory
     42    if not flags.w then
     43        flags.w = ''
     44    end
     45
    4146    -- do this after setting the package name
    42     if flags['L'] then
    43         dofile(flags['L'])
     47    if flags.L then
     48        if string.sub(flags.L, 1, 1) == '/' or string.sub(flags.L, 1, 1) == '\\' then
     49            dofile(flags.L)
     50        else
     51            dofile(flags.w..'/'..flags.L)
     52        end
    4453    end
    4554
    4655    -- add cppstring
    47     if not flags['S'] then
     56    if not flags.S then
    4857        _basic['string'] = 'cppstring'
    4958        _basic['std::string'] = 'cppstring'
     
    5261
    5362    -- proccess package
    54     local p  = Package(flags.n,flags.f)
     63        local file
     64        if flags.f then
     65        if string.sub(flags.f, 1, 1) == '/' or string.sub(flags.f, 1, 1) == '\\' then
     66            file = flags.f
     67        else
     68            file = flags.w..'/'..flags.f
     69        end
     70    else
     71        file = flags.f
     72    end
     73    local p  = Package(flags.n, file)
    5574
    5675    if flags.p then
     
    5978
    6079    if flags.o then
    61         local st,msg = writeto(flags.o)
     80            local file
     81        if string.sub(flags.o, 1, 1) == '/' or string.sub(flags.o, 1, 1) == '\\' then
     82            file = flags.o
     83        else
     84            file = flags.w..'/'..flags.o
     85        end
     86        local st,msg = writeto(file)
    6287        if not st then
    6388            error('#'..msg)
     
    84109    if not flags.P then
    85110        if flags.H then
    86             local st,msg = writeto(flags.H)
     111                local file
     112            if string.sub(flags.H, 1, 1) == '/' or string.sub(flags.H, 1, 1) == '\\' then
     113                file = flags.H
     114            else
     115                file = flags.w..'/'..flags.H
     116            end
     117            local st,msg = writeto(file)
    87118            if not st then
    88119                error('#'..msg)
  • code/branches/buildsystem/src/tolua/lua/package.lua

    r2234 r2236  
    124124    output('#endif\n')
    125125    output('#include "string.h"\n\n')
    126     output('#include "tolua/tolua++.h"\n\n')
    127 
    128     if not flags.h then
    129         --  local temp = string.reverse(flags.H)
    130         --  local start1, end1 = string.find(temp, '/')
    131         --  local start2, end2 = string.find(temp, '\\')
    132         --  local res
    133         --  if not start1 == nil then
    134         --   if not start2 == nil then
    135         --    if start1 > start2 then
    136         --     res = string.sub(temp, 1, start2)
    137         --    else
    138         --     res = string.sub(temp, 1, start1)
    139         --    end
    140         --   else
    141         --    res = string.sub(temp, 1, start1)
    142         --   end
    143         --  elseif not start2 == nil then
    144         --   res = string.sub(temp, 1, start2)
    145         --  end
    146         --  res = string.reverse(res)
    147         output('#include "tolua_bind.h"')
    148         output('\n')
     126    output('#include "tolua++.h"\n\n')
     127
     128    if flags.H then
     129        local header = gsub(flags.H, '^.-([%w_]*%.[%w_]*)$', '%1')
     130        output('#include "'..header..'"\n')
    149131    end
    150132
     
    220202    output('*/\n\n')
    221203
    222     if not flags.h then
     204    if flags.H then
    223205        output('#include "'..self.name..'Prereqs.h"\n')
    224206        output('/* Exported function */')
    225         output('_'..self.name..'Export int  tolua_'..self.name..'_open (lua_State* tolua_S);')
     207        output('_'..self.name..'Export')
     208        output('int  tolua_'..self.name..'_open (lua_State* tolua_S);')
    226209        output('\n')
    227210    end
  • code/branches/buildsystem/src/tolua/tolua.c

    r2233 r2236  
    55** Aug 2003
    66** $Id:$
     7** Extension by Orxonox (Reto Grieder) to support working directory
     8** and direct usage of lua files. (2008)
    79*/
    810
     
    3436         "  -H  file : create include file.\n"
    3537         "  -n  name : set package name; default is input file root name.\n"
    36          "  -w  folder : set working directory; efault is location of package file.\n"
     38         "  -w  directory : set working directory; default is location of package file.\n"
     39         "  -s  file : specify source lua code for the parser; all.lua is default.\n"
    3740         "  -p       : parse only.\n"
    3841         "  -P       : parse and print structure information (for debug).\n"
     
    99102 lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION");
    100103
     104 char* working_directory = "";
     105 char* lua_source = "";
     106
    101107 if (argc==1)
    102108 {
     
    126132     case 'n': setfield(L,t,"n",argv[++i]); break;
    127133     case 'H': setfield(L,t,"H",argv[++i]); break;
    128      case 'w': setfield(L,t,"w",argv[++i]); break;
     134     case 'w':
     135      working_directory = argv[++i];
     136      setfield(L,t,"w",argv[i]);
     137      break;
     138     case 's':
     139      lua_source = argv[++i];
     140      setfield(L,t,"s",argv[i]);
     141      break;
    129142     case 'S': setfield(L,t,"S",""); break;
    130143     case '1': setfield(L,t,"1",""); break;
     
    146159  lua_pop(L,1);
    147160 }
    148 /* #define TOLUA_SCRIPT_RUN */
    149 #ifndef TOLUA_SCRIPT_RUN
     161
    150162 {
    151   int tolua_tolua_open (lua_State* L);
    152   tolua_tolua_open(L);
     163  char path[BUFSIZ];
     164  char file[BUFSIZ];
     165
     166  if (lua_source[0] == '/' || lua_source[0] == '\\')
     167  {
     168   strcpy(path, lua_source);
     169   char* p = strrchr(path, '/');
     170   if (p == NULL)
     171    p = strrchr(path, '\\');
     172   p = (p == NULL) ? path : p + 1;
     173   strcpy(file, p);
     174   *p = '\0';
     175  }
     176  else
     177  {
     178   strcpy(path, working_directory);
     179   strcpy(file, "all.lua");
     180
     181   if (strlen(path) > 0)
     182   {
     183    char last = path[strlen(path) - 1];
     184    if (last != '\\' && last != '/')
     185     strcat(path, "/");
     186   }
     187  }
     188
     189  lua_pushstring(L, path);
     190  lua_setglobal(L, "path");
     191  strcat(path, file);
     192  lua_dofile(L, path);
    153193 }
    154 #else
    155  {
    156   char* p;
    157   char  path[BUFSIZ];
    158   strcpy(path,argv[0]);
    159   p = strrchr(path,'/');
    160   if (p==NULL) p = strrchr(path,'\\');
    161   p = (p==NULL) ? path : p+1;
    162   sprintf(p,"%s","../src/bin/lua/");
    163   lua_pushstring(L,path); lua_setglobal(L,"path");
    164                 strcat(path,"all.lua");
    165   lua_dofile(L,path);
    166  }
    167 #endif
    168194 return 0;
    169195}
Note: See TracChangeset for help on using the changeset viewer.