[ekg2-commit] r4256 - in trunk: . scons.d: +trunk/scons.d/ +trunk/scons.d/compat +trunk/scons.d/standard trunk/SConstruct
SVN commit
svn w toxygen.net
Sob, 9 Sie 2008, 19:51:21 CEST
Author: peres
Date: 2008-08-09 19:51:21 +0200 (Sat, 09 Aug 2008)
New Revision: 4256
Added:
trunk/scons.d/
trunk/scons.d/compat
trunk/scons.d/standard
Modified:
trunk/SConstruct
Log:
Introduce modularization, move standard&compat checks onto external files.
Instead on writing defines on-the-fly, store them as dict and write after successful configure.
Modified: trunk/SConstruct
===================================================================
--- trunk/SConstruct 2008-08-09 13:01:20 UTC (rev 4255)
+++ trunk/SConstruct 2008-08-09 17:51:21 UTC (rev 4256)
@@ -23,7 +23,7 @@
print reason
sys.exit(1)
-def writedef(var, val):
+def writedef(definefile, var, val):
if val is None:
definefile.write('#undef %s\n' % (var))
if isinstance(val, str):
@@ -36,6 +36,12 @@
elif isinstance(val, int):
definefile.write(('#define %s %d\n' % (var, val)))
+def writedefines():
+ definefile = open('ekg2-config.h', 'w')
+ for k, v in defines.items():
+ writedef(definefile, k, v)
+ definefile.close()
+
def CheckStructMember(context, struct, member, headers):
context.Message('Checking for %s.%s... ' % (struct, member))
testprog = ''
@@ -47,6 +53,12 @@
context.Result(result)
return not not result
+def ExtTest(name, addexports = []):
+ exports = ['conf', 'defines']
+ exports.extend(addexports)
+ ret = SConscript('scons.d/%s' % (name), exports)
+ return ret
+
opts = Options('options.cache')
avplugins = [elem.split('/')[1] for elem in glob.glob('plugins/*/')]
@@ -63,114 +75,22 @@
opts.Save('options.cache', env)
env.Help(opts.GenerateHelpText(env))
-definefile = open('ekg2-config.h', 'w')
+defines = {}
+
for var in dirs.keys():
- writedef(var, env[var])
+ defines[var] = env[var]
for var,val in consts.items():
- writedef(var, val)
+ defines[var] = val
for var,val in mapped.items():
- writedef(val, env[var])
+ defines[val] = env[var]
conf = env.Configure(custom_tests = {'CheckStructMember': CheckStructMember})
+ekg_libs = []
-std_funcs = [
- 'inet_aton', 'inet_ntop', 'inet_pton', 'getaddrinfo',
- 'utimes', 'flock',
- 'mkstemp'
- ]
-
-std_headers = [
- 'regex.h'
- ]
-
-compat_funcs = ['strfry', 'strlcat', 'strlcpy', 'strndup', 'strnlen', 'scandir']
-
-compat_spec = {
- 'getopt_long': ['getopt', 'getopt1']
- }
-
-for func in std_funcs:
- writedef('HAVE_%s' % (func.upper()), conf.CheckFunc(func))
-for header in std_headers:
- writedef('HAVE_%s' % (header.upper().replace('.', '_')), conf.CheckHeader(header))
-
+ExtTest('standard', ['ekg_libs'])
compat = []
-for func in compat_funcs:
- have_it = conf.CheckFunc(func)
- writedef('HAVE_%s' % (func.upper()), have_it)
- if not have_it:
- compat.append('compat/%s.c' % (func))
+ExtTest('compat', ['ekg_libs', 'compat'])
-for func, files in compat_spec.items():
- have_it = conf.CheckFunc(func)
- writedef('HAVE_%s' % (func.upper()), have_it)
- if not have_it:
- for file in files:
- compat.append('compat/%s.c' % (file))
-
-ekg_libs = []
-if compat:
- ekg_libs.append('compat')
-
-platform_libs = {
- 'kvm': 'kvm_openfiles', # bsd
-
- 'nsl': 'gethostbyname', # sunos
- 'socket': 'socket',
- 'rt': 'sched_yield',
-
- 'bind': ['inet_addr', '__inet_addr'],
- 'wsock32': None
- }
-
-for lib, funcs in platform_libs.items():
- if not isinstance(funcs, list):
- funcs = [funcs]
- for func in funcs:
- if conf.CheckLib(lib, func):
- ekg_libs.append(lib)
- break
-
-
- # XXX: needs testing
-struct_members = {
- 'struct kinfo_proc': ['ki_size', 'sys/param.h', 'sys/user.h']
- }
-
-for struct, headers in struct_members.items():
- member = headers.pop(0)
- writedef('HAVE_%s_%s' % (struct.upper().replace(' ', '_'), member.upper().replace('.', '_')),
- conf.CheckStructMember(struct, member, headers))
-
-sys_types = {
- 'socklen_t': ['sys/types.h', 'sys/socket.h']
- }
-
-for type, headers in sys_types.items():
- includes = ''
- for inc in headers:
- includes += '#include <%s>\n' % (inc)
- writedef('HAVE_%s' % (type.upper()), conf.CheckType(type, includes))
-
-possibly_libbized = {
- 'dlopen': 'dl',
- 'iconv': 'iconv'
- }
-
-for func, lib in possibly_libbized.items():
- if conf.CheckFunc(func):
- ret = True
- elif conf.CheckLib(lib, func):
- ret = True
- ekg_libs.append(lib)
- else:
- ret = False
- writedef('HAVE_%s' % (func.upper()), ret)
-
-have_idn = conf.CheckLibWithHeader('idn', ['stringprep.h'], 'C', 'stringprep_check_version(NULL);')
-writedef('LIBIDN', have_idn)
-ekg_libs.append('idn')
-
plugin_def = {
'type': 'misc',
'state': 'experimental',
@@ -226,9 +146,10 @@
conf.Finish()
-definefile.close()
+writedefines()
-StaticLibrary('compat/compat', compat)
+if compat:
+ StaticLibrary('compat/compat', compat)
env.Program('ekg/ekg2', Glob('ekg/*.c'), LIBS = ekg_libs, LIBPATH = './compat')
Added: trunk/scons.d/compat
===================================================================
--- trunk/scons.d/compat (rev 0)
+++ trunk/scons.d/compat 2008-08-09 17:51:21 UTC (rev 4256)
@@ -0,0 +1,34 @@
+
+# Compatibility checks for ekg2 core, providing compat/ alternatives
+
+Import('*')
+
+compat_funcs = ['strfry', 'strlcat', 'strlcpy', 'strndup', 'strnlen', 'scandir']
+
+compat_spec = {
+ 'getopt_long': ['getopt', 'getopt1']
+ }
+
+#compat = []
+
+for func in compat_funcs:
+ have_it = conf.CheckFunc(func)
+ defines['HAVE_%s' % (func.upper())] = have_it
+ if not have_it:
+ compat.append('compat/%s.c' % (func))
+
+for func, files in compat_spec.items():
+ have_it = conf.CheckFunc(func)
+ defines['HAVE_%s' % (func.upper())] = have_it
+ if not have_it:
+ for file in files:
+ compat.append('compat/%s.c' % (file))
+
+if compat:
+ ekg_libs.append('compat')
+# StaticLibrary('compat/compat', compat)
+
+ret = True
+Return('ret')
+
+# vim:ts=4:sts=4:syntax=python
Added: trunk/scons.d/standard
===================================================================
--- trunk/scons.d/standard (rev 0)
+++ trunk/scons.d/standard 2008-08-09 17:51:21 UTC (rev 4256)
@@ -0,0 +1,83 @@
+
+# Standard checks for ekg2 core
+
+Import('*')
+
+std_funcs = [
+ 'inet_aton', 'inet_ntop', 'inet_pton', 'getaddrinfo',
+ 'utimes', 'flock',
+ 'mkstemp'
+ ]
+
+std_headers = [
+ 'regex.h'
+ ]
+
+platform_libs = {
+ 'kvm': 'kvm_openfiles', # bsd
+
+ 'nsl': 'gethostbyname', # sunos
+ 'socket': 'socket',
+ 'rt': 'sched_yield',
+
+ 'bind': ['inet_addr', '__inet_addr'], # beos
+ 'wsock32': None # win32
+ }
+
+ # XXX: needs testing
+struct_members = {
+ 'struct kinfo_proc': ['ki_size', 'sys/param.h', 'sys/user.h']
+ }
+
+sys_types = {
+ 'socklen_t': ['sys/types.h', 'sys/socket.h']
+ }
+
+possibly_libbized = {
+ 'dlopen': 'dl',
+ 'iconv': 'iconv'
+ }
+
+for func in std_funcs:
+ defines['HAVE_%s' % (func.upper())] = conf.CheckFunc(func)
+
+for header in std_headers:
+ defines['HAVE_%s' % (header.upper().replace('.', '_'))] = conf.CheckHeader(header)
+
+for lib, funcs in platform_libs.items():
+ if not isinstance(funcs, list):
+ funcs = [funcs]
+ for func in funcs:
+ if conf.CheckLib(lib, func):
+ ekg_libs.append(lib)
+ break
+
+
+for struct, headers in struct_members.items():
+ member = headers.pop(0)
+ defines['HAVE_%s_%s' % (struct.upper().replace(' ', '_'), member.upper().replace('.', '_'))] = conf.CheckStructMember(struct, member, headers)
+
+for type, headers in sys_types.items():
+ includes = ''
+ for inc in headers:
+ includes += '#include <%s>\n' % (inc)
+ defines['HAVE_%s' % (type.upper())] = conf.CheckType(type, includes)
+
+for func, lib in possibly_libbized.items():
+ if conf.CheckFunc(func):
+ ret = True
+ elif conf.CheckLib(lib, func):
+ ret = True
+ ekg_libs.append(lib)
+ else:
+ ret = False
+ defines['HAVE_%s' % (func.upper())] = ret
+
+have_idn = conf.CheckLibWithHeader('idn', ['stringprep.h'], 'C', 'stringprep_check_version(NULL);')
+defines['LIBIDN'] = have_idn
+ekg_libs.append('idn')
+
+out = True
+Return('out')
+
+# vim:ts=4:sts=4:syntax=python
Więcej informacji o liście dyskusyjnej ekg2-commit