Changeset 2236 for code/branches/buildsystem/src/tolua/tolua.c
- Timestamp:
- Nov 20, 2008, 8:51:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem/src/tolua/tolua.c
r2233 r2236 5 5 ** Aug 2003 6 6 ** $Id:$ 7 ** Extension by Orxonox (Reto Grieder) to support working directory 8 ** and direct usage of lua files. (2008) 7 9 */ 8 10 … … 34 36 " -H file : create include file.\n" 35 37 " -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" 37 40 " -p : parse only.\n" 38 41 " -P : parse and print structure information (for debug).\n" … … 99 102 lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION"); 100 103 104 char* working_directory = ""; 105 char* lua_source = ""; 106 101 107 if (argc==1) 102 108 { … … 126 132 case 'n': setfield(L,t,"n",argv[++i]); break; 127 133 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; 129 142 case 'S': setfield(L,t,"S",""); break; 130 143 case '1': setfield(L,t,"1",""); break; … … 146 159 lua_pop(L,1); 147 160 } 148 /* #define TOLUA_SCRIPT_RUN */ 149 #ifndef TOLUA_SCRIPT_RUN 161 150 162 { 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); 153 193 } 154 #else155 {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 #endif168 194 return 0; 169 195 }
Note: See TracChangeset
for help on using the changeset viewer.