Port scons build files for Windows users
We disable: - the tests (which require glib) although they can be reactivated with the `--tests` command line flag - shared library (lack of export symbol declarations means that although it can be built, no symbol is exported and therefore it can't be used) The `install` target installs the library and headers under the `build` folder, because it's a traditional practice to move libraries to a central location on Windows, unless you are using cygwin. In which case pass `prefix` to the command line. We adapt tools\windows\build_examples.bat to take the library that is built using scons or using tools\windows\build.bat
This commit is contained in:
parent
f31e3ba4bd
commit
69d3e70211
4 changed files with 76 additions and 21 deletions
|
|
@ -1,5 +1,6 @@
|
|||
# -*- python -*-
|
||||
import os.path
|
||||
|
||||
Import('env testruns')
|
||||
|
||||
dist_headers = [
|
||||
|
|
@ -48,7 +49,7 @@ parsers = ['parsers/%s.c'%s for s in
|
|||
'unimplemented',
|
||||
'whitespace',
|
||||
'xor',
|
||||
'value']]
|
||||
'value']]
|
||||
|
||||
backends = ['backends/%s.c' % s for s in
|
||||
['packrat', 'llk', 'regex', 'glr', 'lalr', 'lr', 'lr0']]
|
||||
|
|
@ -63,11 +64,18 @@ misc_hammer_parts = [
|
|||
'desugar.c',
|
||||
'glue.c',
|
||||
'hammer.c',
|
||||
'platform_bsdlike.c',
|
||||
'pprint.c',
|
||||
'registry.c',
|
||||
'system_allocator.c']
|
||||
|
||||
if env['PLATFORM'] == 'win32':
|
||||
misc_hammer_parts += [
|
||||
'platform_win32.c',
|
||||
'tsearch.c',
|
||||
]
|
||||
else:
|
||||
misc_hammer_parts += ['platform_bsdlike.c']
|
||||
|
||||
ctests = ['t_benchmark.c',
|
||||
't_bitreader.c',
|
||||
't_bitwriter.c',
|
||||
|
|
@ -76,24 +84,36 @@ ctests = ['t_benchmark.c',
|
|||
't_misc.c',
|
||||
't_regression.c']
|
||||
|
||||
libhammer_shared = env.SharedLibrary('hammer', parsers + backends + misc_hammer_parts)
|
||||
libhammer_static = env.StaticLibrary('hammer', parsers + backends + misc_hammer_parts)
|
||||
Default(libhammer_shared, libhammer_static)
|
||||
|
||||
env.Install("$libpath", [libhammer_static, libhammer_shared])
|
||||
static_library_name = 'hammer'
|
||||
build_shared_library=True
|
||||
if env['PLATFORM'] == 'win32':
|
||||
build_shared_library=False # symbols in hammer are not exported yet, this shared lib would be useless
|
||||
static_library_name = 'hammer_s' # prevent collision between .lib from dll and .lib for static lib
|
||||
|
||||
libhammer_shared = env.SharedLibrary('hammer', parsers + backends + misc_hammer_parts)
|
||||
libhammer_static = env.StaticLibrary(static_library_name, parsers + backends + misc_hammer_parts)
|
||||
if build_shared_library:
|
||||
Default(libhammer_shared, libhammer_static)
|
||||
env.Install("$libpath", [libhammer_static, libhammer_shared])
|
||||
else:
|
||||
Default(libhammer_static)
|
||||
env.Install("$libpath", [libhammer_static])
|
||||
|
||||
env.Install("$incpath", dist_headers)
|
||||
env.Install("$parsersincpath", parsers_headers)
|
||||
env.Install("$backendsincpath", backends_headers)
|
||||
env.Install("$pkgconfigpath", "../../../libhammer.pc")
|
||||
|
||||
testenv = env.Clone()
|
||||
testenv.ParseConfig('pkg-config --cflags --libs glib-2.0')
|
||||
testenv.Append(LIBS=['hammer'])
|
||||
testenv.Prepend(LIBPATH=['.'])
|
||||
ctestexec = testenv.Program('test_suite', ctests + ['test_suite.c'], LINKFLAGS="--coverage" if testenv.GetOption("coverage") else None)
|
||||
ctest = Alias('testc', [ctestexec], "".join(["env LD_LIBRARY_PATH=", os.path.dirname(ctestexec[0].path), " ", ctestexec[0].path]))
|
||||
AlwaysBuild(ctest)
|
||||
testruns.append(ctest)
|
||||
if GetOption("with_tests"):
|
||||
testenv = env.Clone()
|
||||
testenv.ParseConfig('pkg-config --cflags --libs glib-2.0')
|
||||
testenv.Append(LIBS=['hammer'])
|
||||
testenv.Prepend(LIBPATH=['.'])
|
||||
ctestexec = testenv.Program('test_suite', ctests + ['test_suite.c'], LINKFLAGS="--coverage" if testenv.GetOption("coverage") else None)
|
||||
ctest = Alias('testc', [ctestexec], "".join(["env LD_LIBRARY_PATH=", os.path.dirname(ctestexec[0].path), " ", ctestexec[0].path]))
|
||||
AlwaysBuild(ctest)
|
||||
testruns.append(ctest)
|
||||
|
||||
Export("libhammer_static libhammer_shared")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue