Tamar 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitmodules +3 -0
  2. data/HISTORY +22 -5
  3. data/Tamar.gemspec +114 -1
  4. data/VERSION +1 -1
  5. data/src/lua/CMakeLists.txt +176 -0
  6. data/src/lua/COPYRIGHT +34 -0
  7. data/src/lua/FindReadline.cmake +25 -0
  8. data/src/lua/HISTORY +183 -0
  9. data/src/lua/INSTALL +99 -0
  10. data/src/lua/Makefile +128 -0
  11. data/src/lua/README +46 -0
  12. data/src/lua/dist.cmake +450 -0
  13. data/src/lua/dist.info +10 -0
  14. data/src/lua/doc/amazon.gif +0 -0
  15. data/src/lua/doc/contents.html +499 -0
  16. data/src/lua/doc/cover.png +0 -0
  17. data/src/lua/doc/logo.gif +0 -0
  18. data/src/lua/doc/lua.1 +163 -0
  19. data/src/lua/doc/lua.css +41 -0
  20. data/src/lua/doc/lua.html +172 -0
  21. data/src/lua/doc/luac.1 +136 -0
  22. data/src/lua/doc/luac.html +145 -0
  23. data/src/lua/doc/manual.css +13 -0
  24. data/src/lua/doc/manual.html +8801 -0
  25. data/src/lua/doc/readme.html +40 -0
  26. data/src/lua/etc/Makefile +44 -0
  27. data/src/lua/etc/README +37 -0
  28. data/src/lua/etc/all.c +38 -0
  29. data/src/lua/etc/lua.hpp +9 -0
  30. data/src/lua/etc/lua.ico +0 -0
  31. data/src/lua/etc/lua.pc +31 -0
  32. data/src/lua/etc/luavs.bat +28 -0
  33. data/src/lua/etc/min.c +39 -0
  34. data/src/lua/etc/noparser.c +50 -0
  35. data/src/lua/etc/strict.lua +41 -0
  36. data/src/lua/src/Makefile +182 -0
  37. data/src/lua/src/lapi.c +1087 -0
  38. data/src/lua/src/lapi.h +16 -0
  39. data/src/lua/src/lauxlib.c +652 -0
  40. data/src/lua/src/lauxlib.h +174 -0
  41. data/src/lua/src/lbaselib.c +653 -0
  42. data/src/lua/src/lcode.c +831 -0
  43. data/src/lua/src/lcode.h +76 -0
  44. data/src/lua/src/ldblib.c +398 -0
  45. data/src/lua/src/ldebug.c +638 -0
  46. data/src/lua/src/ldebug.h +33 -0
  47. data/src/lua/src/ldo.c +518 -0
  48. data/src/lua/src/ldo.h +57 -0
  49. data/src/lua/src/ldump.c +164 -0
  50. data/src/lua/src/lfunc.c +174 -0
  51. data/src/lua/src/lfunc.h +34 -0
  52. data/src/lua/src/lgc.c +711 -0
  53. data/src/lua/src/lgc.h +110 -0
  54. data/src/lua/src/linit.c +38 -0
  55. data/src/lua/src/liolib.c +556 -0
  56. data/src/lua/src/llex.c +463 -0
  57. data/src/lua/src/llex.h +81 -0
  58. data/src/lua/src/llimits.h +128 -0
  59. data/src/lua/src/lmathlib.c +263 -0
  60. data/src/lua/src/lmem.c +86 -0
  61. data/src/lua/src/lmem.h +49 -0
  62. data/src/lua/src/loadlib.c +666 -0
  63. data/src/lua/src/loadlib_rel.c +719 -0
  64. data/src/lua/src/lobject.c +214 -0
  65. data/src/lua/src/lobject.h +381 -0
  66. data/src/lua/src/lopcodes.c +102 -0
  67. data/src/lua/src/lopcodes.h +268 -0
  68. data/src/lua/src/loslib.c +243 -0
  69. data/src/lua/src/lparser.c +1339 -0
  70. data/src/lua/src/lparser.h +82 -0
  71. data/src/lua/src/lstate.c +214 -0
  72. data/src/lua/src/lstate.h +169 -0
  73. data/src/lua/src/lstring.c +111 -0
  74. data/src/lua/src/lstring.h +31 -0
  75. data/src/lua/src/lstrlib.c +871 -0
  76. data/src/lua/src/ltable.c +588 -0
  77. data/src/lua/src/ltable.h +40 -0
  78. data/src/lua/src/ltablib.c +287 -0
  79. data/src/lua/src/ltm.c +75 -0
  80. data/src/lua/src/ltm.h +54 -0
  81. data/src/lua/src/lua.c +392 -0
  82. data/src/lua/src/lua.def +131 -0
  83. data/src/lua/src/lua.h +388 -0
  84. data/src/lua/src/lua.rc +28 -0
  85. data/src/lua/src/lua_dll.rc +26 -0
  86. data/src/lua/src/luac.c +200 -0
  87. data/src/lua/src/luac.rc +1 -0
  88. data/src/lua/src/luaconf.h.in +724 -0
  89. data/src/lua/src/luaconf.h.orig +763 -0
  90. data/src/lua/src/lualib.h +53 -0
  91. data/src/lua/src/lundump.c +227 -0
  92. data/src/lua/src/lundump.h +36 -0
  93. data/src/lua/src/lvm.c +766 -0
  94. data/src/lua/src/lvm.h +36 -0
  95. data/src/lua/src/lzio.c +82 -0
  96. data/src/lua/src/lzio.h +67 -0
  97. data/src/lua/src/print.c +227 -0
  98. data/src/lua/test/README +26 -0
  99. data/src/lua/test/bisect.lua +27 -0
  100. data/src/lua/test/cf.lua +16 -0
  101. data/src/lua/test/echo.lua +5 -0
  102. data/src/lua/test/env.lua +7 -0
  103. data/src/lua/test/factorial.lua +32 -0
  104. data/src/lua/test/fib.lua +40 -0
  105. data/src/lua/test/fibfor.lua +13 -0
  106. data/src/lua/test/globals.lua +13 -0
  107. data/src/lua/test/hello.lua +3 -0
  108. data/src/lua/test/life.lua +111 -0
  109. data/src/lua/test/luac.lua +7 -0
  110. data/src/lua/test/printf.lua +7 -0
  111. data/src/lua/test/readonly.lua +12 -0
  112. data/src/lua/test/sieve.lua +29 -0
  113. data/src/lua/test/sort.lua +66 -0
  114. data/src/lua/test/table.lua +12 -0
  115. data/src/lua/test/trace-calls.lua +32 -0
  116. data/src/lua/test/trace-globals.lua +38 -0
  117. data/src/lua/test/xd.lua +14 -0
  118. metadata +115 -2
@@ -0,0 +1,450 @@
1
+ # LuaDist CMake utility library.
2
+ # Provides variables and utility functions common to LuaDist CMake builds.
3
+ #
4
+ # Copyright (C) 2007-2011 LuaDist.
5
+ # by David Manura, Peter Drahos
6
+ # Redistribution and use of this file is allowed according to the terms of the MIT license.
7
+ # For details see the COPYRIGHT file distributed with LuaDist.
8
+ # Please note that the package source code is licensed under its own license.
9
+
10
+ ## INSTALL DEFAULTS (Relative to CMAKE_INSTALL_PREFIX)
11
+ # Primary paths
12
+ set ( INSTALL_BIN bin CACHE PATH "Where to install binaries to." )
13
+ set ( INSTALL_LIB lib CACHE PATH "Where to install libraries to." )
14
+ set ( INSTALL_INC include CACHE PATH "Where to install headers to." )
15
+ set ( INSTALL_ETC etc CACHE PATH "Where to store configuration files" )
16
+ set ( INSTALL_LMOD ${INSTALL_LIB}/lua CACHE PATH "Directory to install Lua modules." )
17
+ set ( INSTALL_CMOD ${INSTALL_LIB}/lua CACHE PATH "Directory to install Lua binary modules." )
18
+ set ( INSTALL_SHARE share CACHE PATH "Directory for shared data." )
19
+
20
+ # Secondary paths
21
+ set ( INSTALL_DATA ${INSTALL_SHARE}/${PROJECT_NAME} CACHE PATH "Directory the package can store documentation, tests or other data in.")
22
+ set ( INSTALL_DOC ${INSTALL_DATA}/doc CACHE PATH "Recommended directory to install documentation into.")
23
+ set ( INSTALL_EXAMPLE ${INSTALL_DATA}/example CACHE PATH "Recommended directory to install examples into.")
24
+ set ( INSTALL_TEST ${INSTALL_DATA}/test CACHE PATH "Recommended directory to install tests into.")
25
+ set ( INSTALL_FOO ${INSTALL_DATA}/etc CACHE PATH "Where to install additional files")
26
+
27
+ # Skipable content, headers, binaries and libraries are always required
28
+ option ( SKIP_TESTING "Do not add tests." OFF)
29
+ option ( SKIP_LUA_WRAPPER "Do not build and install Lua executable wrappers." OFF)
30
+ option ( SKIP_INSTALL_DATA "Skip installing all data." OFF )
31
+ if ( NOT SKIP_INSTALL_DATA )
32
+ option ( SKIP_INSTALL_DOC "Skip installation of documentation." OFF )
33
+ option ( SKIP_INSTALL_EXAMPLE "Skip installation of documentation." OFF )
34
+ option ( SKIP_INSTALL_TEST "Skip installation of tests." OFF)
35
+ option ( SKIP_INSTALL_FOO "Skip installation of optional package content." OFF)
36
+ endif ()
37
+
38
+ # TWEAKS
39
+ # Setting CMAKE to use loose block and search for find modules in source directory
40
+ set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
41
+ set ( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} )
42
+
43
+ # In MSVC, prevent warnings that can occur when using standard libraries.
44
+ if ( MSVC )
45
+ add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
46
+ endif ()
47
+
48
+ ## MACROS
49
+ # Parser macro
50
+ macro ( parse_arguments prefix arg_names option_names)
51
+ set ( DEFAULT_ARGS )
52
+ foreach ( arg_name ${arg_names} )
53
+ set ( ${prefix}_${arg_name} )
54
+ endforeach ()
55
+ foreach ( option ${option_names} )
56
+ set ( ${prefix}_${option} FALSE )
57
+ endforeach ()
58
+
59
+ set ( current_arg_name DEFAULT_ARGS )
60
+ set ( current_arg_list )
61
+ foreach ( arg ${ARGN} )
62
+ set ( larg_names ${arg_names} )
63
+ list ( FIND larg_names "${arg}" is_arg_name )
64
+ if ( is_arg_name GREATER -1 )
65
+ set ( ${prefix}_${current_arg_name} ${current_arg_list} )
66
+ set ( current_arg_name ${arg} )
67
+ set ( current_arg_list )
68
+ else ()
69
+ set ( loption_names ${option_names} )
70
+ list ( FIND loption_names "${arg}" is_option )
71
+ if ( is_option GREATER -1 )
72
+ set ( ${prefix}_${arg} TRUE )
73
+ else ()
74
+ set ( current_arg_list ${current_arg_list} ${arg} )
75
+ endif ()
76
+ endif ()
77
+ endforeach ()
78
+ set ( ${prefix}_${current_arg_name} ${current_arg_list} )
79
+ endmacro ()
80
+
81
+ # INSTALL_LUA_EXECUTABLE ( target source )
82
+ # Automatically generate a binary wrapper for lua application and install it
83
+ # The wrapper and the source of the application will be placed into /bin
84
+ # If the application source did not have .lua suffix then it will be added
85
+ # USE: lua_executable ( sputnik src/sputnik.lua )
86
+ macro ( install_lua_executable _name _source )
87
+ get_filename_component ( _source_name ${_source} NAME_WE )
88
+ if ( NOT SKIP_LUA_WRAPPER )
89
+ enable_language ( C )
90
+
91
+ find_package ( Lua51 REQUIRED )
92
+ include_directories ( ${LUA_INCLUDE_DIR} )
93
+
94
+ set ( _wrapper ${CMAKE_CURRENT_BINARY_DIR}/${_name}.c )
95
+ set ( _code
96
+ "// Not so simple executable wrapper for Lua apps
97
+ #include <stdio.h>
98
+ #include <signal.h>
99
+ #include <lua.h>
100
+ #include <lauxlib.h>
101
+ #include <lualib.h>
102
+
103
+ lua_State *L\;
104
+
105
+ static int getargs (lua_State *L, char **argv, int n) {
106
+ int narg\;
107
+ int i\;
108
+ int argc = 0\;
109
+ while (argv[argc]) argc++\;
110
+ narg = argc - (n + 1)\;
111
+ luaL_checkstack(L, narg + 3, \"too many arguments to script\")\;
112
+ for (i=n+1\; i < argc\; i++)
113
+ lua_pushstring(L, argv[i])\;
114
+ lua_createtable(L, narg, n + 1)\;
115
+ for (i=0\; i < argc\; i++) {
116
+ lua_pushstring(L, argv[i])\;
117
+ lua_rawseti(L, -2, i - n)\;
118
+ }
119
+ return narg\;
120
+ }
121
+
122
+ static void lstop (lua_State *L, lua_Debug *ar) {
123
+ (void)ar\;
124
+ lua_sethook(L, NULL, 0, 0)\;
125
+ luaL_error(L, \"interrupted!\")\;
126
+ }
127
+
128
+ static void laction (int i) {
129
+ signal(i, SIG_DFL)\;
130
+ lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1)\;
131
+ }
132
+
133
+ static void l_message (const char *pname, const char *msg) {
134
+ if (pname) fprintf(stderr, \"%s: \", pname)\;
135
+ fprintf(stderr, \"%s\\n\", msg)\;
136
+ fflush(stderr)\;
137
+ }
138
+
139
+ static int report (lua_State *L, int status) {
140
+ if (status && !lua_isnil(L, -1)) {
141
+ const char *msg = lua_tostring(L, -1)\;
142
+ if (msg == NULL) msg = \"(error object is not a string)\"\;
143
+ l_message(\"${_source_name}\", msg)\;
144
+ lua_pop(L, 1)\;
145
+ }
146
+ return status\;
147
+ }
148
+
149
+ static int traceback (lua_State *L) {
150
+ if (!lua_isstring(L, 1))
151
+ return 1\;
152
+ lua_getfield(L, LUA_GLOBALSINDEX, \"debug\")\;
153
+ if (!lua_istable(L, -1)) {
154
+ lua_pop(L, 1)\;
155
+ return 1\;
156
+ }
157
+ lua_getfield(L, -1, \"traceback\")\;
158
+ if (!lua_isfunction(L, -1)) {
159
+ lua_pop(L, 2)\;
160
+ return 1\;
161
+ }
162
+ lua_pushvalue(L, 1)\;
163
+ lua_pushinteger(L, 2)\;
164
+ lua_call(L, 2, 1)\;
165
+ return 1\;
166
+ }
167
+
168
+ static int docall (lua_State *L, int narg, int clear) {
169
+ int status\;
170
+ int base = lua_gettop(L) - narg\;
171
+ lua_pushcfunction(L, traceback)\;
172
+ lua_insert(L, base)\;
173
+ signal(SIGINT, laction)\;
174
+ status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base)\;
175
+ signal(SIGINT, SIG_DFL)\;
176
+ lua_remove(L, base)\;
177
+ if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0)\;
178
+ return status\;
179
+ }
180
+
181
+ int main (int argc, char **argv) {
182
+ L=lua_open()\;
183
+ lua_gc(L, LUA_GCSTOP, 0)\;
184
+ luaL_openlibs(L)\;
185
+ lua_gc(L, LUA_GCRESTART, 0)\;
186
+ int narg = getargs(L, argv, 0)\;
187
+ lua_setglobal(L, \"arg\")\;
188
+
189
+ // Script
190
+ char script[500] = \"./${_source_name}.lua\"\;
191
+ lua_getglobal(L, \"_PROGDIR\")\;
192
+ if (lua_isstring(L, -1)) {
193
+ sprintf( script, \"%s/${_source_name}.lua\", lua_tostring(L, -1))\;
194
+ }
195
+ lua_pop(L, 1)\;
196
+
197
+ // Run
198
+ int status = luaL_loadfile(L, script)\;
199
+ lua_insert(L, -(narg+1))\;
200
+ if (status == 0)
201
+ status = docall(L, narg, 0)\;
202
+ else
203
+ lua_pop(L, narg)\;
204
+
205
+ report(L, status)\;
206
+ lua_close(L)\;
207
+ return status\;
208
+ };
209
+ ")
210
+ file ( WRITE ${_wrapper} ${_code} )
211
+ add_executable ( ${_name} ${_wrapper} )
212
+ target_link_libraries ( ${_name} ${LUA_LIBRARY} )
213
+ install ( TARGETS ${_name} DESTINATION ${INSTALL_BIN} )
214
+ endif()
215
+ install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN} RENAME ${_source_name}.lua )
216
+ endmacro ()
217
+
218
+ # INSTALL_LIBRARY
219
+ # Installs any libraries generated using "add_library" into apropriate places.
220
+ # USE: install_library ( libexpat )
221
+ macro ( install_library )
222
+ foreach ( _file ${ARGN} )
223
+ install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB} )
224
+ endforeach()
225
+ endmacro ()
226
+
227
+ # INSTALL_EXECUTABLE
228
+ # Installs any executables generated using "add_executable".
229
+ # USE: install_executable ( lua )
230
+ macro ( install_executable )
231
+ foreach ( _file ${ARGN} )
232
+ install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} )
233
+ endforeach()
234
+ endmacro ()
235
+
236
+ # INSTALL_HEADER
237
+ # Install a directories or files into header destination.
238
+ # USE: install_header ( lua.h luaconf.h ) or install_header ( GL )
239
+ # NOTE: If headers need to be installed into subdirectories use the INSTALL command directly
240
+ macro ( install_header )
241
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
242
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
243
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
244
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} )
245
+ else ()
246
+ install ( FILES ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} )
247
+ endif ()
248
+ endforeach()
249
+ endmacro ()
250
+
251
+ # INSTALL_DATA ( files/directories )
252
+ # This installs additional data files or directories.
253
+ # USE: install_data ( extra data.dat )
254
+ macro ( install_data )
255
+ if ( NOT SKIP_INSTALL_DATA )
256
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
257
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
258
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
259
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} )
260
+ else ()
261
+ install ( FILES ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} )
262
+ endif ()
263
+ endforeach()
264
+ endif()
265
+ endmacro ()
266
+
267
+ # INSTALL_DOC ( files/directories )
268
+ # This installs documentation content
269
+ # USE: install_doc ( doc/ )
270
+ macro ( install_doc )
271
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_DOC )
272
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
273
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
274
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
275
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} )
276
+ else ()
277
+ install ( FILES ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} )
278
+ endif ()
279
+ endforeach()
280
+ endif()
281
+ endmacro ()
282
+
283
+ # INSTALL_EXAMPLE ( files/directories )
284
+ # This installs additional data
285
+ # USE: install_example ( examples/ exampleA.lua )
286
+ macro ( install_example )
287
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_EXAMPLE )
288
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
289
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
290
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
291
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} )
292
+ else ()
293
+ install ( FILES ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} )
294
+ endif ()
295
+ endforeach()
296
+ endif()
297
+ endmacro ()
298
+
299
+ # INSTALL_TEST ( files/directories )
300
+ # This installs tests
301
+ # USE: install_example ( examples/ exampleA.lua )
302
+ macro ( install_test )
303
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_TEST )
304
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
305
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
306
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
307
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} )
308
+ else ()
309
+ install ( FILES ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} )
310
+ endif ()
311
+ endforeach()
312
+ endif()
313
+ endmacro ()
314
+
315
+ # INSTALL_FOO ( files/directories )
316
+ # This installs optional content
317
+ # USE: install_foo ( examples/ exampleA.lua )
318
+ macro ( install_foo )
319
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_FOO )
320
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
321
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
322
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
323
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} )
324
+ else ()
325
+ install ( FILES ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} )
326
+ endif ()
327
+ endforeach()
328
+ endif()
329
+ endmacro ()
330
+
331
+ # INSTALL_LUA_MODULE
332
+ # This macro installs a lua source module into destination given by lua require syntax.
333
+ # Binary modules are also supported where this funcion takes sources and libraries to compile separated by LINK keyword
334
+ # USE: install_lua_module ( socket.http src/http.lua )
335
+ # USE2: install_lua_module ( mime.core src/mime.c )
336
+ # USE3: install_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} )
337
+ macro (install_lua_module _name )
338
+ string ( REPLACE "." "/" _module "${_name}" )
339
+ string ( REPLACE "." "_" _target "${_name}" )
340
+
341
+ set ( _lua_module "${_module}.lua" )
342
+ set ( _bin_module "${_module}${CMAKE_SHARED_MODULE_SUFFIX}" )
343
+
344
+ parse_arguments ( _MODULE "LINK" "" ${ARGN} )
345
+ get_filename_component ( _ext ${ARGV1} EXT )
346
+ if ( _ext STREQUAL ".lua" )
347
+ get_filename_component ( _path ${_lua_module} PATH )
348
+ get_filename_component ( _filename ${_lua_module} NAME )
349
+ install ( FILES ${ARGV1} DESTINATION ${INSTALL_LMOD}/${_path} RENAME ${_filename} )
350
+ else ()
351
+ enable_language ( C )
352
+ get_filename_component ( _module_name ${_bin_module} NAME_WE )
353
+ get_filename_component ( _module_path ${_bin_module} PATH )
354
+
355
+ find_package ( Lua51 REQUIRED )
356
+ include_directories ( ${LUA_INCLUDE_DIR} )
357
+
358
+ add_library( ${_target} MODULE ${_MODULE_DEFAULT_ARGS})
359
+ target_link_libraries ( ${_target} ${LUA_LIBRARY} ${_MODULE_LINK} )
360
+ set_target_properties ( ${_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${_module_path}" PREFIX "" OUTPUT_NAME "${_module_name}" )
361
+
362
+ install ( TARGETS ${_target} DESTINATION ${INSTALL_CMOD}/${_module_path})
363
+ endif ()
364
+ endmacro ()
365
+
366
+ # ADD_LUA_TEST
367
+ # Runs Lua script `_testfile` under CTest tester.
368
+ # Optional named argument `WORKING_DIRECTORY` is current working directory to run test under
369
+ # (defaults to ${CMAKE_CURRENT_BINARY_DIR}).
370
+ # Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}.
371
+ # Under LuaDist, set test=true in config.lua to enable testing.
372
+ # USE: add_lua_test ( test/test1.lua [args...] [WORKING_DIRECTORY dir])
373
+ macro ( add_lua_test _testfile )
374
+ if ( NOT SKIP_TESTING )
375
+ parse_arguments ( _ARG "WORKING_DIRECTORY" "" ${ARGN} )
376
+ include ( CTest )
377
+ find_program ( LUA NAMES lua lua.bat )
378
+ get_filename_component ( TESTFILEABS ${_testfile} ABSOLUTE )
379
+ get_filename_component ( TESTFILENAME ${_testfile} NAME )
380
+ get_filename_component ( TESTFILEBASE ${_testfile} NAME_WE )
381
+
382
+ # Write wrapper script.
383
+ set ( TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME} )
384
+ set ( TESTWRAPPERSOURCE
385
+ "local configuration = ...
386
+ local sodir = '${CMAKE_CURRENT_BINARY_DIR}' .. (configuration == '' and '' or '/' .. configuration)
387
+ package.path = sodir .. '/?.lua\;' .. sodir .. '/?.lua\;' .. package.path
388
+ package.cpath = sodir .. '/?.so\;' .. sodir .. '/?.dll\;' .. package.cpath
389
+ arg[0] = '${TESTFILEABS}'
390
+ table.remove(arg, 1)
391
+ return assert(loadfile '${TESTFILEABS}')(unpack(arg))
392
+ " )
393
+ if ( _ARG_WORKING_DIRECTORY )
394
+ get_filename_component ( TESTCURRENTDIRABS ${_ARG_WORKING_DIRECTORY} ABSOLUTE )
395
+ # note: CMake 2.6 (unlike 2.8) lacks WORKING_DIRECTORY parameter.
396
+ #old: set ( TESTWRAPPERSOURCE "require 'lfs'; lfs.chdir('${TESTCURRENTDIRABS}' ) ${TESTWRAPPERSOURCE}" )
397
+ set ( _pre ${CMAKE_COMMAND} -E chdir "${TESTCURRENTDIRABS}" )
398
+ endif ()
399
+ file ( WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE})
400
+ add_test ( NAME ${TESTFILEBASE} COMMAND ${_pre} ${LUA} ${TESTWRAPPER} $<CONFIGURATION> ${_ARG_DEFAULT_ARGS} )
401
+ endif ()
402
+ # see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake
403
+ endmacro ()
404
+
405
+ # Converts Lua source file `_source` to binary string embedded in C source
406
+ # file `_target`. Optionally compiles Lua source to byte code (not available
407
+ # under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua
408
+ # versions of bin2c [1] and luac [2] may be passed respectively as additional
409
+ # arguments.
410
+ #
411
+ # [1] http://lua-users.org/wiki/BinToCee
412
+ # [2] http://lua-users.org/wiki/LuaCompilerInLua
413
+ function ( add_lua_bin2c _target _source )
414
+ find_program ( LUA NAMES lua lua.bat )
415
+ execute_process ( COMMAND ${LUA} -e "string.dump(function()end)" RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET )
416
+ if ( NOT ${_LUA_DUMP_RESULT} )
417
+ SET ( HAVE_LUA_DUMP true )
418
+ endif ()
419
+ message ( "-- string.dump=${HAVE_LUA_DUMP}" )
420
+
421
+ if ( ARGV2 )
422
+ get_filename_component ( BIN2C ${ARGV2} ABSOLUTE )
423
+ set ( BIN2C ${LUA} ${BIN2C} )
424
+ else ()
425
+ find_program ( BIN2C NAMES bin2c bin2c.bat )
426
+ endif ()
427
+ if ( HAVE_LUA_DUMP )
428
+ if ( ARGV3 )
429
+ get_filename_component ( LUAC ${ARGV3} ABSOLUTE )
430
+ set ( LUAC ${LUA} ${LUAC} )
431
+ else ()
432
+ find_program ( LUAC NAMES luac luac.bat )
433
+ endif ()
434
+ endif ( HAVE_LUA_DUMP )
435
+ message ( "-- bin2c=${BIN2C}" )
436
+ message ( "-- luac=${LUAC}" )
437
+
438
+ get_filename_component ( SOURCEABS ${_source} ABSOLUTE )
439
+ if ( HAVE_LUA_DUMP )
440
+ get_filename_component ( SOURCEBASE ${_source} NAME_WE )
441
+ add_custom_command (
442
+ OUTPUT ${_target} DEPENDS ${_source}
443
+ COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ${SOURCEABS}
444
+ COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ">${_target}" )
445
+ else ()
446
+ add_custom_command (
447
+ OUTPUT ${_target} DEPENDS ${SOURCEABS}
448
+ COMMAND ${BIN2C} ${_source} ">${_target}" )
449
+ endif ()
450
+ endfunction()
data/src/lua/dist.info ADDED
@@ -0,0 +1,10 @@
1
+ --- This file is part of LuaDist project
2
+
3
+ name = "lua"
4
+ version = "5.1.4"
5
+
6
+ desc = "Lua is a powerful, fast, light-weight, embeddable scripting language."
7
+ author = "Roberto Ierusalimschy, Waldemar Celes, Luiz Henrique de Figueiredo"
8
+ license = "MIT/X11"
9
+ url = "http://www.lua.org"
10
+ maintainer = "Peter Drahoš"
Binary file