Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit f53e9c7

Browse files
committed
Import to git
0 parents  commit f53e9c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+30464
-0
lines changed

CMakeLists.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (C) 2007-2009 LuaDist.
2+
# Created by Peter Kapec
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 (toluapp C)
8+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
9+
INCLUDE(dist.cmake)
10+
11+
# Find Lua
12+
find_package(Lua51 REQUIRED)
13+
include_directories(${LUA_INCLUDE_DIR})
14+
15+
# Build lib
16+
INCLUDE_DIRECTORIES(include src/lib)
17+
FILE(GLOB SRC_LIBTOLUAPP src/lib/*.c )
18+
IF(MSVC)
19+
SET(DEF_FILE libtoluapp.def)
20+
ENDIF()
21+
22+
ADD_LIBRARY (toluapp_lib SHARED ${SRC_LIBTOLUAPP} ${DEF_FILE})
23+
TARGET_LINK_LIBRARIES (toluapp_lib ${LUA_LIBRARIES})
24+
SET_TARGET_PROPERTIES (toluapp_lib PROPERTIES OUTPUT_NAME toluapp CLEAN_DIRECT_OUTPUT 1 )
25+
26+
# Build app
27+
INCLUDE_DIRECTORIES(src/bin)
28+
SET(SRC_TOLUA src/bin/tolua.c src/bin/toluabind.c)
29+
ADD_EXECUTABLE (toluapp ${SRC_TOLUA})
30+
TARGET_LINK_LIBRARIES (toluapp toluapp_lib ${LUA_LIBRARIES})
31+
32+
# Install
33+
INSTALL(TARGETS toluapp DESTINATION ${INSTALL_BIN})
34+
INSTALL(TARGETS toluapp_lib DESTINATION ${INSTALL_LIB})
35+
INSTALL(DIRECTORY include/ DESTINATION ${INSTALL_INC})
36+
INSTALL(FILES README INSTALL DESTINATION ${INSTALL_DATA})
37+
INSTALL(DIRECTORY doc/ DESTINATION ${INSTALL_DOC})

COPYRIGHT

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
tolua++ License
2+
---------------
3+
4+
tolua++ is based on toLua (www.tecgraf.puc-rio.br/~celes/tolua), and
5+
it's licensed under the terms of the MIT license reproduced below.
6+
This means that Lua is free software and can be used for both academic
7+
and commercial purposes at absolutely no cost.
8+
9+
===============================================================================
10+
11+
Copyright (C) 2009 Ariel Manzur.
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a copy
14+
of this software and associated documentation files (the "Software"), to deal
15+
in the Software without restriction, including without limitation the rights
16+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
copies of the Software, and to permit persons to whom the Software is
18+
furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in
21+
all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29+
THE SOFTWARE.
30+
31+
===============================================================================
32+
33+
(end of COPYRIGHT)

INSTALL

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
This version of tolua++ uses SCons to compile (http://www.scons.org). SCons uses
2+
pythin. If you don't want to install python, check "Installation without scons"
3+
below.
4+
5+
* Installation
6+
7+
1. Edit the "config" file for your platform to suit your environment,
8+
if at all necessary (for cygwin, mingw, BSD and mac OSX use
9+
'config_posix')
10+
2. Then, type "scons".
11+
12+
You can use 'scons -h' to see a list of available command line options.
13+
14+
* What you get
15+
16+
If "scons" succeeds, you get:
17+
* an executable to generate binding code in ./bin;
18+
* the C library to be linked in your application in ./lib;
19+
* the include file needed to compile your application in ./include.
20+
These are the only directories you need for development, besides Lua.
21+
22+
You can use 'scons install' to install the files, see the 'prefix' option.
23+
24+
* Installation without scons
25+
26+
The instructions for building tolua++ without scons depend on the particular
27+
compiler you are using.
28+
The simplest way is to create a folder with all .c and .h files except
29+
'toluabind_default.c', and then create a project for the executable and the
30+
library, as follows:
31+
32+
tolua.exe: all *.c *.h in src/bin (except toluabind_default.c)
33+
tolua.lib: all *.c *.h in src/lib.
34+
35+
* Installation with Microsoft Visual Studio
36+
37+
The directory 'win32' contains project files for Microsoft Visual Studio 7
38+
(contributed by Makoto Hamanaka). The project has 4 different build options:
39+
withLua50_Release, withLua51_Release, withLua50_Debug and withLua51_Debug.
40+
They all expect the lua library names used by the LuaBinaries packages
41+
(http://luabinaries.luaforge.net/). The resulting files are built on /lib and
42+
/bin (for the library and tolua++.exe).

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# makefile for tolua hierarchy
2+
3+
all:
4+
@echo "Makefile is deprecated ;)"
5+
@echo "see INSTALL for details on how to build tolua++"

README

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
This is tolua++-1.0
2+
3+
* What is tolua++?
4+
tolua++ is an extension of toLua, a tool to integrate C/C++ code with
5+
Lua. tolua++ includes new features oriented to c++, such as class
6+
templates.
7+
8+
tolua is a tool that greatly simplifies the integration of C/C++ code
9+
with Lua. Based on a "cleaned" header file, tolua automatically generates
10+
the binding code to access C/C++ features from Lua. Using Lua-5.0 API and
11+
metamethod facilities, the current version automatically maps C/C++
12+
constants, external variables, functions, namespace, classes, and methods
13+
to Lua. It also provides facilities to create Lua modules.
14+
15+
* Availability
16+
17+
tolua++ is freely available for both academic and commercial purposes.
18+
See COPYRIGHT for details.
19+
20+
tolua++ can be downloaded from the sites below:
21+
http://www.codenix.com/~tolua/
22+
23+
* Installation
24+
See INSTALL.
25+
26+
* Contacting the author
27+
tolua has been designed and implemented by Waldemar Celes.
28+
tolua++ is maintained by Ariel Manzur.
29+
Send your comments, bug reports and anything else to
30+

README-5.1

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Compiling for lua 5.1
2+
---------------------
3+
4+
Starting from version 1.0.8pre1, tolua++ can be compiled with both lua 5.0 and
5+
5.1. Both versions will output the same code, and the C API (tolua++.h) is the
6+
same.
7+
8+
The build system is not yet ready to detect/decide when to compile for 5.1,
9+
the easiest way right now is to add a file called 'custom.py' on the root of
10+
the package, with the following:
11+
12+
## BEGIN custom.py
13+
14+
CCFLAGS = ['-I/usr/local/include/lua5.1', '-O2', '-ansi']
15+
LIBPATH = ['/usr/local/lib']
16+
LIBS = ['lua5.1', 'dl', 'm']
17+
tolua_bin = 'tolua++5.1'
18+
tolua_lib = 'tolua++5.1'
19+
TOLUAPP = 'tolua++5.1'
20+
21+
## END custom.py
22+
23+
This will build the binary as 'tolua++5.1' and the library as 'libtolua++5.1.a'
24+
(taken from tolua_bin and tolua_lib), and take the lua headers and libraries
25+
from /usr/local/include/lua5.1 and /usr/local/lib. It will also link with
26+
'-llua5.1'. Modify the parameters acording to your system.
27+
28+
Compatibility
29+
-------------
30+
31+
There are a couple of things to keep in mind when running code inside tolua
32+
using the -L option:
33+
34+
* `...' and arg: you can still use 'arg' on 5.1, this is done automatically by
35+
adding the 'arg' declaration to functions on files loaded with dofile.
36+
37+
For example, the line:
38+
39+
function foo( ... )
40+
41+
becomes
42+
43+
function foo( ... ) local arg = {n=select('#', ...), ...};
44+
45+
This lets you use the same code on both versions without having to make any
46+
modifications.
47+
48+
* keep in mind that there are slight differences on the way string.gsub works,
49+
and the original version of the function is always kept, so it will behave
50+
diffently depending on which version of lua you're using.

SConstruct

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
import sys;
2+
import os
3+
4+
tools = ['default']
5+
if os.name == 'nt':
6+
tools = ['mingw']
7+
8+
env = Environment(tools = tools)
9+
10+
options_file = None
11+
if sys.platform == 'linux2':
12+
options_file = "linux"
13+
14+
elif 'msvc' in env['TOOLS']:
15+
options_file = "msvc"
16+
else:
17+
options_file = "posix"
18+
19+
opts = Options(["config_"+options_file+".py", "custom.py", "custom_"+options_file+".py"], ARGUMENTS)
20+
opts.Add('CC', 'The C compiler.')
21+
opts.Add('CXX', 'The C++ compiler (for the tests)')
22+
opts.Add('CCFLAGS', 'Flags for the compiler.', ['-O2', '-Wall'])
23+
opts.Add('LINK', 'The linker.')
24+
opts.Add('LINKFLAGS', 'Linker flags.', [])
25+
opts.Add('no_cygwin', 'Use -mno-cygwin to build using the mingw compiler on cygwin', 0)
26+
opts.Add('LIBS', 'libraries', [])
27+
opts.Add('LIBPATH', 'library path', [])
28+
29+
opts.Add('tolua_bin', 'the resulting binary', 'tolua++')
30+
opts.Add('tolua_lib', 'the resulting library', 'tolua++')
31+
opts.Add('TOLUAPP', 'the name of the tolua++ binary (to use with built_dev=1)', 'tolua++')
32+
33+
opts.Add('prefix', 'The installation prefix')
34+
opts.Add('build_dev', 'Build for development (uses tolua to rebuild toluabind.c with the embeded scripts', 0)
35+
opts.Add('build_failsafe', "Build using 'factory default' toluabind file (in case build_dev fails)", 0)
36+
opts.Add('ENV', 'The environment variables')
37+
opts.Add('shared', 'Build a shared object', False)
38+
opts.Update(env)
39+
Help(opts.GenerateHelpText(env))
40+
41+
def save_config(target, source, env):
42+
opts.Save('custom.py', env)
43+
44+
cust = env.Command('custom.py', [], save_config)
45+
env.Alias('configure', [cust])
46+
47+
env['TOLUAPP_BOOTSTRAP'] = env['tolua_bin']+"_bootstrap"+env['PROGSUFFIX']
48+
49+
env['build_dev'] = int(env['build_dev'])
50+
51+
## detecting the install directory on win32
52+
if 'msvc' in env['TOOLS'] and not (env.has_key('prefix') or env['prefix']):
53+
54+
if env['MSVS'].has_key('PLATFORMSDKDIR'):
55+
env['prefix'] = env['MSVS']['PLATFORMSDKDIR']
56+
57+
58+
SConscriptChdir(0)
59+
60+
############ helper builders
61+
def pkg_scan_dep(self, target, source):
62+
63+
import re
64+
65+
## TODO: detectar si el archivo existe antes de abrirlo asi nomas
66+
pkg = open(source, "rt")
67+
68+
for linea in pkg.xreadlines():
69+
dep = re.search("^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea)
70+
if dep:
71+
self.Depends(target, '#' + dep.groups()[0]);
72+
73+
if dep.groups()[0][-4:] == '.pkg':
74+
# recursividad
75+
self.pkg_scan_dep(target, dep.groups()[0])
76+
77+
78+
def make_tolua_code(self, target, source, pkgname = None, bootstrap = False, use_own = False, use_typeid=None):
79+
80+
ptarget = Dir('.').path + '/' + target
81+
psource = Dir('.').path + '/' + source
82+
header = target[:-2] + '.h'
83+
pheader = Dir('.').path + '/' + header
84+
85+
tolua = ""
86+
if bootstrap:
87+
if os.name == 'nt':
88+
tolua = 'bin\\'+self['TOLUAPP_BOOTSTRAP']
89+
else:
90+
tolua = 'bin/'+self['TOLUAPP_BOOTSTRAP']
91+
print("********* tolua is ", tolua)
92+
else:
93+
if use_own:
94+
if 'msvc' in self['TOOLS']:
95+
tolua = 'bin\\$tolua_bin'
96+
else:
97+
tolua = 'bin/$tolua_bin'
98+
else:
99+
tolua = "$TOLUAPP"
100+
101+
if pkgname:
102+
pkgname = ' -n '+pkgname
103+
else:
104+
pkgname = ''
105+
106+
if use_typeid:
107+
tolua = tolua+' -t'
108+
109+
comando = tolua + ' -C -H ' + pheader + ' -o ' + ptarget + pkgname + ' ' + psource
110+
command = self.Command(target, source, comando)
111+
112+
self.SideEffect(header, target)
113+
self.Depends(target, source)
114+
115+
self.pkg_scan_dep(target, psource)
116+
117+
if bootstrap:
118+
self.Depends(target, "#/bin/$TOLUAPP_BOOTSTRAP")
119+
if use_own:
120+
self.Depends(target, "#/bin/$tolua_bin")
121+
122+
return command
123+
124+
125+
env.__class__.LuaBinding = make_tolua_code;
126+
env.__class__.pkg_scan_dep = pkg_scan_dep;
127+
128+
def print_install_error(target, source, env):
129+
130+
msg = """Error: no install prefix was specified, or detected.
131+
132+
you can use the 'prefix' option on command line to specify one. Examples:
133+
134+
scons prefix=/usr/local install
135+
136+
or on Windows:
137+
138+
scons "prefix=c:\\program files\\visual basic" install
139+
140+
Files will be installed on <prefix>/bin, <prefix>/lib and <prefix>/include
141+
"""
142+
import SCons.Errors
143+
raise SCons.Errors.UserError(msg)
144+
145+
########### end of helper builders
146+
147+
env['CPPPATH'] = '#/include'
148+
env['LIBPATH'] = ['#/lib'] + env['LIBPATH']
149+
150+
if env['no_cygwin']:
151+
152+
env['CCFLAGS'] += ['-mno-cygwin']
153+
env['LINKFLAGS'] += ['-mno-cygwin']
154+
155+
import string
156+
157+
Export('env')
158+
159+
SConscript('src/lib/SCsub')
160+
SConscript('src/bin/SCsub')
161+
#SConscript('src/lib/SCsub')
162+
SConscript('src/tests/SCsub')
163+
164+
env.Alias('all', [env.bin_target, env.lib_target])
165+
env.Alias('test', env.test_targets)
166+
167+
Default('all')
168+
169+
if env['prefix']:
170+
env.Install(env['prefix']+'/bin', env.bin_target)
171+
env.Install(env['prefix']+'/lib', env.lib_target)
172+
env.Install(env['prefix']+'/include', '#include/tolua++.h')
173+
174+
env.Alias('install', [env['prefix']+'/bin', env['prefix']+'/include', env['prefix']+'/lib'])
175+
else:
176+
env.Command('install', [], print_install_error)
177+
env.Depends('install', 'all')
178+
179+
env.Command('deb', [], 'dpkg-buildpackage -I.svn -Icustom.py -Itoluabind_dev.c -Itoluabind_dev.h -Itoluabind_default.o -Icustom.lua -I.sconsign', ENV=os.environ)
180+

0 commit comments

Comments
 (0)