Tamar 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,5 +1,22 @@
1
1
  RELEASE HISTORY
2
2
 
3
+ v0.7.2 / 2011-05-23
4
+
5
+ Regenerate gemspec for version 0.7.2 (David Love david@homeunix.org.uk)
6
+
7
+ Changes:
8
+
9
+ * 3 General Enhancements
10
+
11
+ * Version bump to 0.7.2
12
+ * Update HISTORY file
13
+ * Regenerate gemspec for version 0.7.1
14
+
15
+ * 1 Patch Enhancements
16
+
17
+ * Link to LuaDist sources for building Lua
18
+
19
+
3
20
  v0.7.1 / 2011-05-23
4
21
 
5
22
  Regenerate gemspec for version 0.7.1 (David Love david@homeunix.org.uk)
@@ -44,9 +61,9 @@ Changes:
44
61
 
45
62
  * 1 Patch Enhancements
46
63
 
47
- * Link to LuaDist sources for building Lua
64
+ * Include LuaDist in the gem
48
65
 
49
66
  * 1 General Enhancements
50
67
 
51
- * Regenerate gemspec for version 0.7.1
68
+ * Regenerate gemspec for version 0.7.2
52
69
 
data/Rakefile CHANGED
@@ -45,7 +45,12 @@ Jeweler::Tasks.new do |gem|
45
45
  gem.description = "See: http://rubyluabridge.rubyforge.org"
46
46
  gem.email = "david@homeunix.org.uk"
47
47
  gem.authors = ["Evan Wies, David Love"]
48
+
48
49
  # dependencies defined in Gemfile
50
+
51
+ # Include LuaDist sources
52
+ gem.files.include Dir.glob('src/**/*')
53
+
49
54
  end
50
55
  Jeweler::RubygemsDotOrgTasks.new
51
56
 
data/Tamar.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{Tamar}
8
- s.version = "0.7.2"
8
+ s.version = "0.7.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Evan Wies, David Love"]
@@ -27,7 +27,32 @@ Gem::Specification.new do |s|
27
27
  "README.rdoc",
28
28
  "Rakefile",
29
29
  "Tamar.gemspec",
30
- "VERSION"
30
+ "VERSION",
31
+ "src/luadist/CMakeLists.txt",
32
+ "src/luadist/COPYRIGHT",
33
+ "src/luadist/README",
34
+ "src/luadist/dist.cmake",
35
+ "src/luadist/dist.info",
36
+ "src/luadist/dist/config.lua.in",
37
+ "src/luadist/dist/dep.lua",
38
+ "src/luadist/dist/fetch.lua",
39
+ "src/luadist/dist/init.lua",
40
+ "src/luadist/dist/log.lua",
41
+ "src/luadist/dist/manifest.lua",
42
+ "src/luadist/dist/package.lua",
43
+ "src/luadist/dist/persist.lua",
44
+ "src/luadist/dist/sys.lua",
45
+ "src/luadist/doc/index.html",
46
+ "src/luadist/doc/luadoc.css",
47
+ "src/luadist/doc/modules/dist.dep.html",
48
+ "src/luadist/doc/modules/dist.fetch.html",
49
+ "src/luadist/doc/modules/dist.html",
50
+ "src/luadist/doc/modules/dist.log.html",
51
+ "src/luadist/doc/modules/dist.manifest.html",
52
+ "src/luadist/doc/modules/dist.package.html",
53
+ "src/luadist/doc/modules/dist.persist.html",
54
+ "src/luadist/doc/modules/dist.sys.html",
55
+ "src/luadist/luadist"
31
56
  ]
32
57
  s.homepage = %q{http://rubyluabridge.rubyforge.org}
33
58
  s.licenses = ["BSD"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.7.3
@@ -0,0 +1,42 @@
1
+ # Copyright (C) 2007-2011 LuaDist.
2
+ # Created by Peter Drahoš
3
+ # Redistribution and use of this file is allowed according to the terms of the MIT license.
4
+ # For details see the COPYRIGHT file distributed with LuaDist.
5
+ # Please note that the package source code is licensed under its own license.
6
+
7
+ project ( luadist NONE )
8
+ cmake_minimum_required ( VERSION 2.6 )
9
+ include ( dist.cmake )
10
+
11
+ ## LuaDist settings
12
+ # Host specific setup
13
+ set ( DETECTED_TYPE ${CMAKE_SYSTEM_PROCESSOR} )
14
+ set ( DETECTED_ARCH ${CMAKE_SYSTEM_NAME} )
15
+
16
+ if ( CYGWIN )
17
+ # Make sure Cygwin uses correct arch and type.
18
+ set ( DETECTED_TYPE x86 )
19
+ set ( DETECTED_ARCH Cygwin )
20
+ elseif ( MSVC )
21
+ set ( DETECTED_TYPE MSVC32 )
22
+ endif ()
23
+
24
+ set ( DIST_VERSION 1.2 )
25
+ set ( DIST_TYPE ${DETECTED_TYPE} CACHE STRING "Host system type. PLEASE CHECK!" FORCE )
26
+ set ( DIST_ARCH ${DETECTED_ARCH} CACHE STRING "Host system architecture. PLEASE CHECK!" FORCE )
27
+
28
+ configure_file ( dist/config.lua.in ${CMAKE_CURRENT_BINARY_DIR}/dist/config.lua @ONLY )
29
+
30
+ install_lua_executable ( luadist luadist )
31
+ install_lua_module ( dist.init dist/init.lua )
32
+ install_lua_module ( dist.dep dist/dep.lua )
33
+ install_lua_module ( dist.fetch dist/fetch.lua )
34
+ install_lua_module ( dist.log dist/log.lua )
35
+ install_lua_module ( dist.manifest dist/manifest.lua )
36
+ install_lua_module ( dist.package dist/package.lua )
37
+ install_lua_module ( dist.persist dist/persist.lua )
38
+ install_lua_module ( dist.sys dist/sys.lua )
39
+ install_lua_module ( dist.config ${CMAKE_CURRENT_BINARY_DIR}/dist/config.lua )
40
+
41
+ install_data ( COPYRIGHT README )
42
+ install_doc ( doc/ )
@@ -0,0 +1,34 @@
1
+ LuaDist License
2
+ ---------------
3
+
4
+ LuaDist is licensed under the terms of the MIT license reproduced below.
5
+ This means that LuaDist is free software and can be used for both academic
6
+ and commercial purposes at absolutely no cost.
7
+
8
+ Modules and Lua bindings contained in "dist" packages have their
9
+ individual copyright.
10
+
11
+ ===============================================================================
12
+
13
+ Copyright (C) 2007-2010 LuaDist.
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in
23
+ all copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31
+ THE SOFTWARE.
32
+
33
+ ===============================================================================
34
+
@@ -0,0 +1,95 @@
1
+ * About LuaDist
2
+ -------------
3
+ LuaDist is a CMake-based multi-platform standalone Lua distribution
4
+ providing a build environment and module management. For more information
5
+ please visit http://www.luadist.org.
6
+
7
+ * Availability
8
+ ------------
9
+ LuaDist is freely available for both academic and commercial purposes under
10
+ MIT license. See COPYRIGHT for details. Please see individual packages for
11
+ their license.
12
+
13
+ * Installation
14
+ ------------
15
+ LuaDist relies on CMake (www.cmake.org) for building. The build process
16
+ consists of two stages. First stage in the CMake based bootstrap that will
17
+ build and install all needed components. Second stage uses the bootstrap
18
+ environment to build and install the final release. This process is needed to
19
+ ensure LuaDist remains self update-able and endorses its correct deployment
20
+ structure.
21
+
22
+ To build LuaDist on Unix (including Linux, OS X and Cygwin) systems simply
23
+ use the provided build bash script.
24
+
25
+ > ./build [optional CMake arguments]
26
+
27
+ LuaDist can be built natively on Windows using MinGW and MSVC compilers
28
+ (possibly others). For this purpose we provide respective build.bat and
29
+ build_msvc.bat scripts which you can use.
30
+
31
+ * Running
32
+ -------
33
+ LuaDist installs to a standalone directory and should be able to execute on
34
+ most systems supported systems without the need to set up any environment.
35
+
36
+ To invoke the luadist CLI simply use:
37
+ $ cd luadist/bin
38
+ $ ./lua luadist
39
+
40
+ Any other binaries distributed using LuaDist can also be invoked directly
41
+ $ cd luadist/bin
42
+ $ ./luac
43
+
44
+ If you experience problems with dynamic libraries or missing Lua modules you
45
+ can ensure LuaDist finds them by providing following environment variables:
46
+ $ export DIST_ROOT=/full/path/to/luadist
47
+ $ export LD_LIBRARY_PATH=$DIST_ROOT/lib
48
+ $ cd $DIST_ROOT/bin
49
+ $ ./lua luadist
50
+
51
+ * Compatibility
52
+ -------------
53
+ LuaDist was designed to support Unix/Linux, Mac and Windows
54
+ installs.
55
+
56
+ We are testing on the following operating systems:
57
+ Ubuntu 10.10, amd64 and x86
58
+ OS X 10.6, intel i386 and x86_64
59
+ Windows 7 with MinGW compiler, 32bit
60
+ Windows 7 with MSVC compilers, 32bit
61
+ Cygwin on Windows 7, 32bit
62
+
63
+ * Authors
64
+ -------
65
+ LuaDist is developed and maintained by:
66
+ Peter Drahoš
67
+ Peter Kapec
68
+ David Manura
69
+
70
+ Contributors:
71
+ Jozef Lang
72
+ Matej Lipták
73
+
74
+ NOTE: LuaDist installable components "dists" contain their copyright and
75
+ legal information. Authors of the contents of these components are not
76
+ related to the LuaDist project.
77
+
78
+ * Thanks
79
+ ------
80
+ We would like to thank the following people who directly or indirectly
81
+ contributed to the project.
82
+
83
+ Roberto Ierusalimschy (Lua)
84
+ Waldemar Celes (Lua)
85
+ Luiz Henrique de Figueiredo (Lua)
86
+ Mike Pall (LuaJIT)
87
+ Hisham Muhamad (LuaRocks)
88
+ Karl M. Syrings (UnxUtils)
89
+ David Manura (luausers wiki)
90
+ André Carregal (luafilesystem)
91
+ Tomás Guisasola (luafilesystem)
92
+ Diego Nehab (luasocket)
93
+ All "dist" authors and maintainers.
94
+
95
+ Thank You.
@@ -0,0 +1,436 @@
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
+ get_filename_component ( _source_name ${_source} NAME_WE )
95
+ set ( _wrapper ${CMAKE_CURRENT_BINARY_DIR}/${_name}.c )
96
+ set ( _code
97
+ "// Not so simple executable wrapper for Lua apps
98
+ #include <stdio.h>
99
+ #include <signal.h>
100
+ #include <lua.h>
101
+ #include <lauxlib.h>
102
+ #include <lualib.h>
103
+
104
+ lua_State *L\;
105
+
106
+ static int getargs (lua_State *L, char **argv, int n) {
107
+ int narg\;
108
+ int i\;
109
+ int argc = 0\;
110
+ while (argv[argc]) argc++\;
111
+ narg = argc - (n + 1)\;
112
+ luaL_checkstack(L, narg + 3, \"too many arguments to script\")\;
113
+ for (i=n+1\; i < argc\; i++)
114
+ lua_pushstring(L, argv[i])\;
115
+ lua_createtable(L, narg, n + 1)\;
116
+ for (i=0\; i < argc\; i++) {
117
+ lua_pushstring(L, argv[i])\;
118
+ lua_rawseti(L, -2, i - n)\;
119
+ }
120
+ return narg\;
121
+ }
122
+
123
+ static void lstop (lua_State *L, lua_Debug *ar) {
124
+ (void)ar\;
125
+ lua_sethook(L, NULL, 0, 0)\;
126
+ luaL_error(L, \"interrupted!\")\;
127
+ }
128
+
129
+ static void laction (int i) {
130
+ signal(i, SIG_DFL)\;
131
+ lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1)\;
132
+ }
133
+
134
+ static void l_message (const char *pname, const char *msg) {
135
+ if (pname) fprintf(stderr, \"%s: \", pname)\;
136
+ fprintf(stderr, \"%s\\n\", msg)\;
137
+ fflush(stderr)\;
138
+ }
139
+
140
+ static int report (lua_State *L, int status) {
141
+ if (status && !lua_isnil(L, -1)) {
142
+ const char *msg = lua_tostring(L, -1)\;
143
+ if (msg == NULL) msg = \"(error object is not a string)\"\;
144
+ l_message(\"${_name}\", msg)\;
145
+ lua_pop(L, 1)\;
146
+ }
147
+ return status\;
148
+ }
149
+
150
+ static int traceback (lua_State *L) {
151
+ if (!lua_isstring(L, 1))
152
+ return 1\;
153
+ lua_getfield(L, LUA_GLOBALSINDEX, \"debug\")\;
154
+ if (!lua_istable(L, -1)) {
155
+ lua_pop(L, 1)\;
156
+ return 1\;
157
+ }
158
+ lua_getfield(L, -1, \"traceback\")\;
159
+ if (!lua_isfunction(L, -1)) {
160
+ lua_pop(L, 2)\;
161
+ return 1\;
162
+ }
163
+ lua_pushvalue(L, 1)\;
164
+ lua_pushinteger(L, 2)\;
165
+ lua_call(L, 2, 1)\;
166
+ return 1\;
167
+ }
168
+
169
+ static int docall (lua_State *L, int narg, int clear) {
170
+ int status\;
171
+ int base = lua_gettop(L) - narg\;
172
+ lua_pushcfunction(L, traceback)\;
173
+ lua_insert(L, base)\;
174
+ signal(SIGINT, laction)\;
175
+ status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base)\;
176
+ signal(SIGINT, SIG_DFL)\;
177
+ lua_remove(L, base)\;
178
+ if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0)\;
179
+ return status\;
180
+ }
181
+
182
+ int main (int argc, char **argv) {
183
+ L=lua_open()\;
184
+ lua_gc(L, LUA_GCSTOP, 0)\;
185
+ luaL_openlibs(L)\;
186
+ lua_gc(L, LUA_GCRESTART, 0)\;
187
+ getargs(L, argv, 0)\;
188
+ lua_setglobal(L, \"arg\")\;
189
+ // _PROGDIR global is only available when loadlib_rel.c is used in Lua
190
+ int status = luaL_dostring(L, \"return dofile ( (_PROGDIR or '.') .. '/${_source_name}.lua')\")\;
191
+ report(L, status)\;
192
+ lua_close(L)\;
193
+ return status\;
194
+ };
195
+ ")
196
+ file ( WRITE ${_wrapper} ${_code} )
197
+ add_executable ( ${_name} ${_wrapper} )
198
+ target_link_libraries ( ${_name} ${LUA_LIBRARY} )
199
+ install ( TARGETS ${_name} DESTINATION ${INSTALL_BIN} )
200
+ endif()
201
+ install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN} RENAME ${_source_name}.lua )
202
+ endmacro ()
203
+
204
+ # INSTALL_LIBRARY
205
+ # Installs any libraries generated using "add_library" into apropriate places.
206
+ # USE: install_library ( libexpat )
207
+ macro ( install_library )
208
+ foreach ( _file ${ARGN} )
209
+ install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB} )
210
+ endforeach()
211
+ endmacro ()
212
+
213
+ # INSTALL_EXECUTABLE
214
+ # Installs any executables generated using "add_executable".
215
+ # USE: install_executable ( lua )
216
+ macro ( install_executable )
217
+ foreach ( _file ${ARGN} )
218
+ install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} )
219
+ endforeach()
220
+ endmacro ()
221
+
222
+ # INSTALL_HEADER
223
+ # Install a directories or files into header destination.
224
+ # USE: install_header ( lua.h luaconf.h ) or install_header ( GL )
225
+ # NOTE: If headers need to be installed into subdirectories use the INSTALL command directly
226
+ macro ( install_header )
227
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
228
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
229
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
230
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} )
231
+ else ()
232
+ install ( FILES ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} )
233
+ endif ()
234
+ endforeach()
235
+ endmacro ()
236
+
237
+ # INSTALL_DATA ( files/directories )
238
+ # This installs additional data files or directories.
239
+ # USE: install_data ( extra data.dat )
240
+ macro ( install_data )
241
+ if ( NOT SKIP_INSTALL_DATA )
242
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
243
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
244
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
245
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} )
246
+ else ()
247
+ install ( FILES ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} )
248
+ endif ()
249
+ endforeach()
250
+ endif()
251
+ endmacro ()
252
+
253
+ # INSTALL_DOC ( files/directories )
254
+ # This installs documentation content
255
+ # USE: install_doc ( doc/ )
256
+ macro ( install_doc )
257
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_DOC )
258
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
259
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
260
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
261
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} )
262
+ else ()
263
+ install ( FILES ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} )
264
+ endif ()
265
+ endforeach()
266
+ endif()
267
+ endmacro ()
268
+
269
+ # INSTALL_EXAMPLE ( files/directories )
270
+ # This installs additional data
271
+ # USE: install_example ( examples/ exampleA.lua )
272
+ macro ( install_example )
273
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_EXAMPLE )
274
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
275
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
276
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
277
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} )
278
+ else ()
279
+ install ( FILES ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} )
280
+ endif ()
281
+ endforeach()
282
+ endif()
283
+ endmacro ()
284
+
285
+ # INSTALL_TEST ( files/directories )
286
+ # This installs tests
287
+ # USE: install_example ( examples/ exampleA.lua )
288
+ macro ( install_test )
289
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_TEST )
290
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
291
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
292
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
293
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} )
294
+ else ()
295
+ install ( FILES ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} )
296
+ endif ()
297
+ endforeach()
298
+ endif()
299
+ endmacro ()
300
+
301
+ # INSTALL_FOO ( files/directories )
302
+ # This installs optional content
303
+ # USE: install_foo ( examples/ exampleA.lua )
304
+ macro ( install_foo )
305
+ if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_FOO )
306
+ parse_arguments ( _ARG "INTO" "" ${ARGN} )
307
+ foreach ( _file ${_ARG_DEFAULT_ARGS} )
308
+ if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" )
309
+ install ( DIRECTORY ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} )
310
+ else ()
311
+ install ( FILES ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} )
312
+ endif ()
313
+ endforeach()
314
+ endif()
315
+ endmacro ()
316
+
317
+ # INSTALL_LUA_MODULE
318
+ # This macro installs a lua source module into destination given by lua require syntax.
319
+ # Binary modules are also supported where this funcion takes sources and libraries to compile separated by LINK keyword
320
+ # USE: install_lua_module ( socket.http src/http.lua )
321
+ # USE2: install_lua_module ( mime.core src/mime.c )
322
+ # USE3: install_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} )
323
+ macro (install_lua_module _name )
324
+ string ( REPLACE "." "/" _module "${_name}" )
325
+ string ( REPLACE "." "_" _target "${_name}" )
326
+
327
+ set ( _lua_module "${_module}.lua" )
328
+ set ( _bin_module "${_module}${CMAKE_SHARED_MODULE_SUFFIX}" )
329
+
330
+ parse_arguments ( _MODULE "LINK" "" ${ARGN} )
331
+ get_filename_component ( _ext ${ARGV1} EXT )
332
+ if ( _ext STREQUAL ".lua" )
333
+ get_filename_component ( _path ${_lua_module} PATH )
334
+ get_filename_component ( _filename ${_lua_module} NAME )
335
+ install ( FILES ${ARGV1} DESTINATION ${INSTALL_LMOD}/${_path} RENAME ${_filename} )
336
+ else ()
337
+ enable_language ( C )
338
+ get_filename_component ( _module_name ${_bin_module} NAME_WE )
339
+ get_filename_component ( _module_path ${_bin_module} PATH )
340
+
341
+ find_package ( Lua51 REQUIRED )
342
+ include_directories ( ${LUA_INCLUDE_DIR} )
343
+
344
+ add_library( ${_target} MODULE ${_MODULE_DEFAULT_ARGS})
345
+ target_link_libraries ( ${_target} ${LUA_LIBRARY} ${_MODULE_LINK} )
346
+ set_target_properties ( ${_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${_module_path}" PREFIX "" OUTPUT_NAME "${_module_name}" )
347
+
348
+ install ( TARGETS ${_target} DESTINATION ${INSTALL_CMOD}/${_module_path})
349
+ endif ()
350
+ endmacro ()
351
+
352
+ # ADD_LUA_TEST
353
+ # Runs Lua script `_testfile` under CTest tester.
354
+ # Optional argument `_testcurrentdir` is current working directory to run test under
355
+ # (defaults to ${CMAKE_CURRENT_BINARY_DIR}).
356
+ # Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}.
357
+ # Under LuaDist, set test=true in config.lua to enable testing.
358
+ # USE: add_lua_test ( test/test1.lua )
359
+ macro ( add_lua_test _testfile )
360
+ if ( SKIP_TESTING )
361
+ include ( CTest )
362
+ find_program ( LUA NAMES lua lua.bat )
363
+ get_filename_component ( TESTFILEABS ${_testfile} ABSOLUTE )
364
+ get_filename_component ( TESTFILENAME ${_testfile} NAME )
365
+ get_filename_component ( TESTFILEBASE ${_testfile} NAME_WE )
366
+
367
+ # Write wrapper script.
368
+ set ( TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME} )
369
+ set ( TESTWRAPPERSOURCE
370
+ "local configuration = ...
371
+ local sodir = '${CMAKE_CURRENT_BINARY_DIR}' .. (configuration == '' and '' or '/' .. configuration)
372
+ package.path = sodir .. '/?.lua\;' .. sodir .. '/?.lua\;' .. package.path
373
+ package.cpath = sodir .. '/?.so\;' .. sodir .. '/?.dll\;' .. package.cpath
374
+ arg[0] = '${TESTFILEABS}'
375
+ return dofile '${TESTFILEABS}'
376
+ " )
377
+ if ( ${ARGC} GREATER 1 )
378
+ set ( _testcurrentdir ${ARGV1} )
379
+ get_filename_component ( TESTCURRENTDIRABS ${_testcurrentdir} ABSOLUTE )
380
+ set ( TESTWRAPPERSOURCE
381
+ "require 'lfs'
382
+ lfs.chdir('${TESTCURRENTDIRABS}' )
383
+ ${TESTWRAPPERSOURCE}" )
384
+ endif ()
385
+ file ( WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE})
386
+ add_test ( NAME ${TESTFILEBASE} COMMAND ${LUA} ${TESTWRAPPER} $<CONFIGURATION> )
387
+ endif ()
388
+ # see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake
389
+ endmacro ()
390
+
391
+ # Converts Lua source file `_source` to binary string embedded in C source
392
+ # file `_target`. Optionally compiles Lua source to byte code (not available
393
+ # under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua
394
+ # versions of bin2c [1] and luac [2] may be passed respectively as additional
395
+ # arguments.
396
+ #
397
+ # [1] http://lua-users.org/wiki/BinToCee
398
+ # [2] http://lua-users.org/wiki/LuaCompilerInLua
399
+ function ( add_lua_bin2c _target _source )
400
+ find_program ( LUA NAMES lua lua.bat )
401
+ execute_process ( COMMAND ${LUA} -e "string.dump(function()end)" RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET )
402
+ if ( NOT ${_LUA_DUMP_RESULT} )
403
+ SET ( HAVE_LUA_DUMP true )
404
+ endif ()
405
+ message ( "-- string.dump=${HAVE_LUA_DUMP}" )
406
+
407
+ if ( ARGV2 )
408
+ get_filename_component ( BIN2C ${ARGV2} ABSOLUTE )
409
+ set ( BIN2C ${LUA} ${BIN2C} )
410
+ else ()
411
+ find_program ( BIN2C NAMES bin2c bin2c.bat )
412
+ endif ()
413
+ if ( HAVE_LUA_DUMP )
414
+ if ( ARGV3 )
415
+ get_filename_component ( LUAC ${ARGV3} ABSOLUTE )
416
+ set ( LUAC ${LUA} ${LUAC} )
417
+ else ()
418
+ find_program ( LUAC NAMES luac luac.bat )
419
+ endif ()
420
+ endif ( HAVE_LUA_DUMP )
421
+ message ( "-- bin2c=${BIN2C}" )
422
+ message ( "-- luac=${LUAC}" )
423
+
424
+ get_filename_component ( SOURCEABS ${_source} ABSOLUTE )
425
+ if ( HAVE_LUA_DUMP )
426
+ get_filename_component ( SOURCEBASE ${_source} NAME_WE )
427
+ add_custom_command (
428
+ OUTPUT ${_target} DEPENDS ${_source}
429
+ COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ${SOURCEABS}
430
+ COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ">${_target}" )
431
+ else ()
432
+ add_custom_command (
433
+ OUTPUT ${_target} DEPENDS ${SOURCEABS}
434
+ COMMAND ${BIN2C} ${_source} ">${_target}" )
435
+ endif ()
436
+ endfunction()