mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-28 20:15:24 +08:00
- fixed SCons build on Windows: only build static library (support static/dynamic at the same time requires significant changes)
- renamed SCons glob tool to globtool to avoid clash with python glob module. This prevented running the tests. - check target now works with SCons 1.x
This commit is contained in:
parent
617270bfaa
commit
64e07e54ed
19
SConstruct
19
SConstruct
@ -137,24 +137,29 @@ elif platform == 'msvc6':
|
|||||||
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
env.Tool( tool )
|
env.Tool( tool )
|
||||||
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
||||||
|
env['SHARED_LIB_ENABLED'] = False
|
||||||
elif platform == 'msvc70':
|
elif platform == 'msvc70':
|
||||||
env['MSVS_VERSION']='7.0'
|
env['MSVS_VERSION']='7.0'
|
||||||
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
env.Tool( tool )
|
env.Tool( tool )
|
||||||
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
||||||
|
env['SHARED_LIB_ENABLED'] = False
|
||||||
elif platform == 'msvc71':
|
elif platform == 'msvc71':
|
||||||
env['MSVS_VERSION']='7.1'
|
env['MSVS_VERSION']='7.1'
|
||||||
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
env.Tool( tool )
|
env.Tool( tool )
|
||||||
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
||||||
|
env['SHARED_LIB_ENABLED'] = False
|
||||||
elif platform == 'msvc80':
|
elif platform == 'msvc80':
|
||||||
env['MSVS_VERSION']='8.0'
|
env['MSVS_VERSION']='8.0'
|
||||||
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
env.Tool( tool )
|
env.Tool( tool )
|
||||||
env['CXXFLAGS']='-GR -EHsc /nologo /MT'
|
env['CXXFLAGS']='-GR -EHsc /nologo /MT'
|
||||||
|
env['SHARED_LIB_ENABLED'] = False
|
||||||
elif platform == 'mingw':
|
elif platform == 'mingw':
|
||||||
env.Tool( 'mingw' )
|
env.Tool( 'mingw' )
|
||||||
env.Append( CPPDEFINES=[ "WIN32", "NDEBUG", "_MT" ] )
|
env.Append( CPPDEFINES=[ "WIN32", "NDEBUG", "_MT" ] )
|
||||||
|
env['SHARED_LIB_ENABLED'] = False
|
||||||
elif platform.startswith('linux-gcc'):
|
elif platform.startswith('linux-gcc'):
|
||||||
env.Tool( 'default' )
|
env.Tool( 'default' )
|
||||||
env.Append( LIBS = ['pthread'], CCFLAGS = "-Wall" )
|
env.Append( LIBS = ['pthread'], CCFLAGS = "-Wall" )
|
||||||
@ -166,13 +171,16 @@ env.Tool('doxygen')
|
|||||||
env.Tool('substinfile')
|
env.Tool('substinfile')
|
||||||
env.Tool('targz')
|
env.Tool('targz')
|
||||||
env.Tool('srcdist')
|
env.Tool('srcdist')
|
||||||
env.Tool('glob')
|
env.Tool('globtool')
|
||||||
|
|
||||||
env.Append( CPPPATH = ['#include'],
|
env.Append( CPPPATH = ['#include'],
|
||||||
LIBPATH = lib_dir )
|
LIBPATH = lib_dir )
|
||||||
short_platform = platform
|
short_platform = platform
|
||||||
if short_platform.startswith('msvc'):
|
if short_platform.startswith('msvc'):
|
||||||
short_platform = short_platform[2:]
|
short_platform = short_platform[2:]
|
||||||
|
# Notes: on Windows you need to rebuild the source for each variant
|
||||||
|
# Build script does not support that yet so we only build static libraries.
|
||||||
|
env['SHARED_LIB_ENABLED'] = env.get('SHARED_LIB_ENABLED', True)
|
||||||
env['LIB_PLATFORM'] = short_platform
|
env['LIB_PLATFORM'] = short_platform
|
||||||
env['LIB_LINK_TYPE'] = 'lib' # static
|
env['LIB_LINK_TYPE'] = 'lib' # static
|
||||||
env['LIB_CRUNTIME'] = 'mt'
|
env['LIB_CRUNTIME'] = 'mt'
|
||||||
@ -210,10 +218,11 @@ def buildJSONTests( env, target_sources, target_name ):
|
|||||||
def buildLibrary( env, target_sources, target_name ):
|
def buildLibrary( env, target_sources, target_name ):
|
||||||
static_lib = env.StaticLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
|
static_lib = env.StaticLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
|
||||||
source=target_sources )
|
source=target_sources )
|
||||||
shared_lib = env.SharedLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
|
|
||||||
source=target_sources )
|
|
||||||
global lib_dir
|
global lib_dir
|
||||||
env.Install( lib_dir, static_lib )
|
env.Install( lib_dir, static_lib )
|
||||||
|
if env['SHARED_LIB_ENABLED']:
|
||||||
|
shared_lib = env.SharedLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
|
||||||
|
source=target_sources )
|
||||||
env.Install( lib_dir, shared_lib )
|
env.Install( lib_dir, shared_lib )
|
||||||
env['SRCDIST_ADD']( source=[target_sources] )
|
env['SRCDIST_ADD']( source=[target_sources] )
|
||||||
|
|
||||||
@ -232,10 +241,10 @@ def runJSONTests_action( target, source = None, env = None ):
|
|||||||
jsontest_path = Dir( '#test' ).abspath
|
jsontest_path = Dir( '#test' ).abspath
|
||||||
sys.path.insert( 0, jsontest_path )
|
sys.path.insert( 0, jsontest_path )
|
||||||
import runjsontests
|
import runjsontests
|
||||||
return runjsontests.runAllTests( os.path.abspath(source), jsontest_path )
|
return runjsontests.runAllTests( os.path.abspath(source[0].path), jsontest_path )
|
||||||
|
|
||||||
def runJSONTests_string( target, source = None, env = None ):
|
def runJSONTests_string( target, source = None, env = None ):
|
||||||
return 'RunJSONTests("%s")' % source
|
return 'RunJSONTests("%s")' % source[0]
|
||||||
|
|
||||||
import SCons.Action
|
import SCons.Action
|
||||||
ActionFactory = SCons.Action.ActionFactory
|
ActionFactory = SCons.Action.ActionFactory
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import glob
|
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
import SCons
|
import SCons
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import glob
|
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
import targz
|
import targz
|
||||||
|
|
||||||
|
@ -44,15 +44,15 @@ def valueTreeToString( fout, value, path = '.' ):
|
|||||||
assert False and "Unexpected value type"
|
assert False and "Unexpected value type"
|
||||||
|
|
||||||
def parseAndSaveValueTree( input, actual_path ):
|
def parseAndSaveValueTree( input, actual_path ):
|
||||||
root = json.read( input )
|
root = json.loads( input )
|
||||||
fout = file( actual_path, 'wt' )
|
fout = file( actual_path, 'wt' )
|
||||||
valueTreeToString( fout, root )
|
valueTreeToString( fout, root )
|
||||||
fout.close()
|
fout.close()
|
||||||
return root
|
return root
|
||||||
|
|
||||||
def rewriteValueTree( value, rewrite_path ):
|
def rewriteValueTree( value, rewrite_path ):
|
||||||
rewrite = json.write( value )
|
rewrite = json.dumps( value )
|
||||||
rewrite = rewrite[1:-1] # Somehow the string is quoted ! jsonpy bug ?
|
#rewrite = rewrite[1:-1] # Somehow the string is quoted ! jsonpy bug ?
|
||||||
file( rewrite_path, 'wt').write( rewrite + '\n' )
|
file( rewrite_path, 'wt').write( rewrite + '\n' )
|
||||||
return rewrite
|
return rewrite
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import glob
|
from glob import glob
|
||||||
|
|
||||||
|
|
||||||
def compareOutputs( expected, actual, message ):
|
def compareOutputs( expected, actual, message ):
|
||||||
@ -38,13 +38,32 @@ def safeReadFile( path ):
|
|||||||
def runAllTests( jsontest_executable_path, input_dir = None ):
|
def runAllTests( jsontest_executable_path, input_dir = None ):
|
||||||
if not input_dir:
|
if not input_dir:
|
||||||
input_dir = os.getcwd()
|
input_dir = os.getcwd()
|
||||||
tests = glob.glob( os.path.join( input_dir, '*.json' ) )
|
tests = glob( os.path.join( input_dir, '*.json' ) )
|
||||||
|
test_jsonchecker = glob( os.path.join( input_dir, 'jsonchecker', '*.json' ) )
|
||||||
failed_tests = []
|
failed_tests = []
|
||||||
for input_path in tests:
|
for input_path in tests + test_jsonchecker:
|
||||||
|
is_json_checker_test = input_path in test_jsonchecker
|
||||||
print 'TESTING:', input_path,
|
print 'TESTING:', input_path,
|
||||||
pipe = os.popen( "%s %s" % (jsontest_executable_path, input_path) )
|
options = is_json_checker_test and '--json-checker' or ''
|
||||||
|
pipe = os.popen( "%s %s %s" % (jsontest_executable_path, options,
|
||||||
|
input_path) )
|
||||||
process_output = pipe.read()
|
process_output = pipe.read()
|
||||||
status = pipe.close()
|
status = pipe.close()
|
||||||
|
if is_json_checker_test:
|
||||||
|
expect_failure = os.path.basename( input_path ).startswith( 'fail' )
|
||||||
|
if expect_failure:
|
||||||
|
if status is None:
|
||||||
|
print 'FAILED'
|
||||||
|
failed_tests.append( (input_path, 'Parsing should have failed') )
|
||||||
|
else:
|
||||||
|
print 'OK'
|
||||||
|
else:
|
||||||
|
if status is not None:
|
||||||
|
print 'FAILED'
|
||||||
|
failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) )
|
||||||
|
else:
|
||||||
|
print 'OK'
|
||||||
|
else:
|
||||||
base_path = os.path.splitext(input_path)[0]
|
base_path = os.path.splitext(input_path)[0]
|
||||||
actual_output = safeReadFile( base_path + '.actual' )
|
actual_output = safeReadFile( base_path + '.actual' )
|
||||||
actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' )
|
actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user