File: SConstruct

package info (click to toggle)
tolua++ 1.0.93-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,860 kB
  • sloc: ansic: 2,105; cpp: 326; python: 27; makefile: 16
file content (180 lines) | stat: -rw-r--r-- 4,881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import sys;
import os

tools = ['default']
if os.name == 'nt':
	tools = ['mingw']

env = Environment(tools = tools)

options_file = None
if sys.platform == 'linux2':
	options_file = "linux"

elif 'msvc' in env['TOOLS']:
	options_file = "msvc"
else:
	options_file = "posix"

opts = Variables(["config_"+options_file+".py", "custom.py", "custom_"+options_file+".py"], ARGUMENTS)
opts.Add('CC', 'The C compiler.')
opts.Add('CXX', 'The C++ compiler (for the tests)')
opts.Add('CCFLAGS', 'Flags for the compiler.', ['-O2', '-Wall'])
opts.Add('LINK', 'The linker.')
opts.Add('LINKFLAGS', 'Linker flags.', [])
opts.Add('no_cygwin', 'Use -mno-cygwin to build using the mingw compiler on cygwin', 0)
opts.Add('LIBS', 'libraries', [])
opts.Add('LIBPATH', 'library path', [])

opts.Add('tolua_bin', 'the resulting binary', 'tolua++')
opts.Add('tolua_lib', 'the resulting library', 'tolua++')
opts.Add('TOLUAPP', 'the name of the tolua++ binary (to use with built_dev=1)', 'tolua++')

opts.Add('prefix', 'The installation prefix')
opts.Add('build_dev', 'Build for development (uses tolua to rebuild toluabind.c with the embeded scripts', 0)
opts.Add('build_failsafe', "Build using 'factory default' toluabind file (in case build_dev fails)", 0)
opts.Add('ENV', 'The environment variables')
opts.Add('shared', 'Build a shared object', False)
opts.Update(env)
Help(opts.GenerateHelpText(env))

def save_config(target, source, env):
	opts.Save('custom.py', env)

cust = env.Command('custom.py', [], save_config)
env.Alias('configure', [cust])

env['TOLUAPP_BOOTSTRAP'] = env['tolua_bin']+"_bootstrap"+env['PROGSUFFIX']

env['build_dev'] = int(env['build_dev'])

## detecting the install directory on win32
if 'msvc' in env['TOOLS'] and not (env.has_key('prefix') or env['prefix']):

	if env['MSVS'].has_key('PLATFORMSDKDIR'):
		env['prefix'] = env['MSVS']['PLATFORMSDKDIR']


SConscriptChdir(0)

############ helper builders
def pkg_scan_dep(self, target, source):

	import re

	## TODO: detectar si el archivo existe antes de abrirlo asi nomas
	pkg = open(source, "rt")

	for linea in pkg:
		dep = re.search("^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea)
		if dep:
			self.Depends(target, '#' + dep.groups()[0]);

			if dep.groups()[0][-4:] == '.pkg':
				# recursividad
				self.pkg_scan_dep(target, dep.groups()[0])


def make_tolua_code(self, target, source, pkgname = None, bootstrap = False, use_own = False, use_typeid=None):

	ptarget = Dir('.').path + '/' + target
	psource = Dir('.').path + '/' + source
	header = target[:-2] + '.h'
	pheader = Dir('.').path + '/' + header

	tolua = ""
	if bootstrap:
		if os.name == 'nt':
			tolua = 'bin\\'+self['TOLUAPP_BOOTSTRAP']
		else:
			tolua = 'bin/'+self['TOLUAPP_BOOTSTRAP']
		print("********* tolua is ", tolua)
	else:
		if use_own:
			if 'msvc' in self['TOOLS']:
				tolua = 'bin\\$tolua_bin'
			else:
				tolua = 'bin/$tolua_bin'
		else:
			tolua = "$TOLUAPP"

	if pkgname:
		pkgname = ' -n '+pkgname
	else:
		pkgname = ''

	if use_typeid:
		tolua = tolua+' -t'

	comando = tolua + ' -C -H ' + pheader + ' -o ' + ptarget + pkgname + ' ' + psource
	command = self.Command(target, source, comando)

	self.SideEffect(header, target)
	self.Depends(target, source)

	self.pkg_scan_dep(target, psource)

	if bootstrap:
		self.Depends(target, "#/bin/$TOLUAPP_BOOTSTRAP")
	if use_own:
		self.Depends(target, "#/bin/$tolua_bin")
	
	return command


env.__class__.LuaBinding = make_tolua_code;
env.__class__.pkg_scan_dep = pkg_scan_dep;

def print_install_error(target, source, env):

	msg = """Error: no install prefix was specified, or detected.

you can use the 'prefix' option on command line to specify one. Examples:

	scons prefix=/usr/local install

or on Windows:

	scons "prefix=c:\\program files\\visual basic" install

Files will be installed on <prefix>/bin, <prefix>/lib and <prefix>/include
"""
	import SCons.Errors
	raise SCons.Errors.UserError(msg)

########### end of helper builders

env['CPPPATH'] = '#/include'
env['LIBPATH'] =  ['#/lib'] + env['LIBPATH']

if env['no_cygwin']:

	env['CCFLAGS'] += ['-mno-cygwin']
	env['LINKFLAGS'] += ['-mno-cygwin']

import string

Export('env')

SConscript('src/lib/SCsub')
SConscript('src/bin/SCsub')
#SConscript('src/lib/SCsub')
SConscript('src/tests/SCsub')

env.Alias('all', [env.bin_target, env.lib_target])
env.Alias('test', env.test_targets)

Default('all')

if env['prefix']:
	env.Install(env['prefix']+'/bin', env.bin_target)
	env.Install(env['prefix']+'/lib', env.lib_target)
	env.Install(env['prefix']+'/include', '#include/tolua++.h')

	env.Alias('install', [env['prefix']+'/bin', env['prefix']+'/include', env['prefix']+'/lib'])
else:
	env.Command('install', [], print_install_error)
	env.Depends('install', 'all')

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)