Skip to content

Commit

Permalink
Add jsoncpp library. Needed for the ForTheRecord pvr addon
Browse files Browse the repository at this point in the history
  • Loading branch information
margro committed Sep 4, 2012
1 parent a818c5c commit 6c846f1
Show file tree
Hide file tree
Showing 26 changed files with 6,999 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -50,4 +50,6 @@ project/BuildDependencies/downloads
project/BuildDependencies/lib
project/BuildDependencies/include
addons/*/project/VS2010Express/Debug
addons/*/project/VS2010Express/Release
addons/*/project/VS2010Express/Release
lib/jsoncpp/project/VS2010Express/Debug
lib/jsoncpp/project/VS2010Express/Release
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -124,6 +124,7 @@ AC_SUBST(DATADIR)

AC_OUTPUT([Makefile
lib/Makefile
lib/jsoncpp/Makefile
lib/libhts/Makefile
lib/tinyxml/Makefile
addons/Makefile
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.am
@@ -1,4 +1,4 @@
SUBDIRS = libhts tinyxml
SUBDIRS = libhts tinyxml jsoncpp

zip:

Expand Down
1 change: 1 addition & 0 deletions lib/jsoncpp/AUTHORS
@@ -0,0 +1 @@
Baptiste Lepilleur <blep@users.sourceforge.net>
12 changes: 12 additions & 0 deletions lib/jsoncpp/Makefile.am
@@ -0,0 +1,12 @@
noinst_LTLIBRARIES = libjsoncpp.la

libjsoncpp_la_SOURCES = src/lib_json/json_reader.cpp \
src/lib_json/json_value.cpp \
src/lib_json/json_writer.cpp

INCLUDES=-Iinclude/

$(LIB): libjsoncpp.la
cp -f .libs/libjsoncpp.a .
cp -f .libs/libjsoncpp.la $(LIB)

53 changes: 53 additions & 0 deletions lib/jsoncpp/README.txt
@@ -0,0 +1,53 @@
* Introduction:

JSON (JavaScript Object Notation) is a lightweight data-interchange format.
It can represent integer, real number, string, an ordered sequence of
value, and a collection of name/value pairs.

JsonCpp is a simple API to manipulate JSON value, and handle serialization
and unserialization to string.

It can also preserve existing comment in unserialization/serialization steps,
making it a convenient format to store user input files.

Unserialization parsing is user friendly and provides precise error reports.

* Building/Testing:

JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires
python to be installed (http://www.python.org).

You download scons-local distribution from the following url:
http://sourceforge.net/project/showfiles.php?group_id=30337&package_id=67375

Unzip it in the directory where you found this README file. scons.py Should be
at the same level as README.

python scons.py platform=PLTFRM [TARGET]
where PLTFRM may be one of:
suncc Sun C++ (Solaris)
vacpp Visual Age C++ (AIX)
mingw
msvc6 Microsoft Visual Studio 6 service pack 5-6
msvc70 Microsoft Visual Studio 2002
msvc71 Microsoft Visual Studio 2003
msvc80 Microsoft Visual Studio 2005
linux-gcc Gnu C++ (linux, also reported to work for Mac OS X)

adding platform is fairly simple. You need to change the Sconstruct file
to do so.

and TARGET may be:
check: build library and run unit tests.
doc: build documentation
doc-dist: build documentation tarball

To run the test manually:
cd test
# This will run the Reader/Writer tests
python runjsontests.py "path to jsontest.exe"
# This will run the unit tests (mostly Value)
python rununittests.py "path to test_lib_json.exe"

You can run the tests using valgrind using:
python rununittests.py --valgrind "path to test_lib_json.exe"
300 changes: 300 additions & 0 deletions lib/jsoncpp/SConstruct
@@ -0,0 +1,300 @@
"""
Build system can be clean-up by sticking to a few core production factory, with automatic dependencies resolution.
4 basic project productions:
- library
- binary
- documentation
- tests
* Library:
Input:
- dependencies (other libraries)
- headers: include path & files
- sources
- generated sources
- resources
- generated resources
Production:
- Static library
- Dynamic library
- Naming rule
Life-cycle:
- Library compilation
- Compilation as a dependencies
- Run-time
- Packaging
Identity:
- Name
- Version
* Binary:
Input:
- dependencies (other libraries)
- headers: include path & files (usually empty)
- sources
- generated sources
- resources
- generated resources
- supported variant (optimized/debug, dll/static...)
Production:
- Binary executable
- Manifest [on some platforms]
- Debug symbol [on some platforms]
Life-cycle:
- Compilation
- Run-time
- Packaging
Identity:
- Name
- Version
* Documentation:
Input:
- dependencies (libraries, binaries)
- additional sources
- generated sources
- resources
- generated resources
- supported variant (public/internal)
Production:
- HTML documentation
- PDF documentation
- CHM documentation
Life-cycle:
- Documentation
- Packaging
- Test
Identity:
- Name
- Version
"""



import os
import os.path
import sys

JSONCPP_VERSION = '0.2'
DIST_DIR = '#dist'

options = Variables()
options.Add( EnumVariable('platform',
'Platform (compiler/stl) used to build the project',
'msvc71',
allowed_values='suncc vacpp mingw msvc6 msvc7 msvc71 msvc80 linux-gcc'.split(),
ignorecase=2) )

try:
platform = ARGUMENTS['platform']
if platform == 'linux-gcc':
CXX = 'g++' # not quite right, but env is not yet available.
import commands
version = commands.getoutput('%s -dumpversion' %CXX)
platform = 'linux-gcc-%s' %version
print "Using platform '%s'" %platform
LD_LIBRARY_PATH = os.environ.get('LD_LIBRARY_PATH', '')
LD_LIBRARY_PATH = "%s:libs/%s" %(LD_LIBRARY_PATH, platform)
os.environ['LD_LIBRARY_PATH'] = LD_LIBRARY_PATH
print "LD_LIBRARY_PATH =", LD_LIBRARY_PATH
except KeyError:
print 'You must specify a "platform"'
sys.exit(2)

print "Building using PLATFORM =", platform

rootbuild_dir = Dir('#buildscons')
build_dir = os.path.join( '#buildscons', platform )
bin_dir = os.path.join( '#bin', platform )
lib_dir = os.path.join( '#libs', platform )
sconsign_dir_path = Dir(build_dir).abspath
sconsign_path = os.path.join( sconsign_dir_path, '.sconsign.dbm' )

# Ensure build directory exist (SConsignFile fail otherwise!)
if not os.path.exists( sconsign_dir_path ):
os.makedirs( sconsign_dir_path )

# Store all dependencies signature in a database
SConsignFile( sconsign_path )

def make_environ_vars():
"""Returns a dictionnary with environment variable to use when compiling."""
# PATH is required to find the compiler
# TEMP is required for at least mingw
vars = {}
for name in ('PATH', 'TEMP', 'TMP'):
if name in os.environ:
vars[name] = os.environ[name]
return vars


env = Environment( ENV = make_environ_vars(),
toolpath = ['scons-tools'],
tools=[] ) #, tools=['default'] )

if platform == 'suncc':
env.Tool( 'sunc++' )
env.Tool( 'sunlink' )
env.Tool( 'sunar' )
env.Append( CCFLAGS = ['-mt'] )
elif platform == 'vacpp':
env.Tool( 'default' )
env.Tool( 'aixcc' )
env['CXX'] = 'xlC_r' #scons does not pick-up the correct one !
# using xlC_r ensure multi-threading is enabled:
# http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.vacpp7a.doc/compiler/ref/cuselect.htm
env.Append( CCFLAGS = '-qrtti=all',
LINKFLAGS='-bh:5' ) # -bh:5 remove duplicate symbol warning
elif platform == 'msvc6':
env['MSVS_VERSION']='6.0'
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
env.Tool( tool )
env['CXXFLAGS']='-GR -GX /nologo /MT'
elif platform == 'msvc70':
env['MSVS_VERSION']='7.0'
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
env.Tool( tool )
env['CXXFLAGS']='-GR -GX /nologo /MT'
elif platform == 'msvc71':
env['MSVS_VERSION']='7.1'
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
env.Tool( tool )
env['CXXFLAGS']='-GR -GX /nologo /MT'
elif platform == 'msvc80':
env['MSVS_VERSION']='8.0'
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
env.Tool( tool )
env['CXXFLAGS']='-GR -EHsc /nologo /MT'
elif platform == 'mingw':
env.Tool( 'mingw' )
env.Append( CPPDEFINES=[ "WIN32", "NDEBUG", "_MT" ] )
elif platform.startswith('linux-gcc'):
env.Tool( 'default' )
env.Append( LIBS = ['pthread'], CCFLAGS = "-Wall" )
env['SHARED_LIB_ENABLED'] = True
else:
print "UNSUPPORTED PLATFORM."
env.Exit(1)

env.Tool('doxygen')
env.Tool('substinfile')
env.Tool('targz')
env.Tool('srcdist')
env.Tool('globtool')

env.Append( CPPPATH = ['#include'],
LIBPATH = lib_dir )
short_platform = platform
if short_platform.startswith('msvc'):
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.
# This also fails on AIX because both dynamic and static library ends with
# extension .a.
env['SHARED_LIB_ENABLED'] = env.get('SHARED_LIB_ENABLED', False)
env['LIB_PLATFORM'] = short_platform
env['LIB_LINK_TYPE'] = 'lib' # static
env['LIB_CRUNTIME'] = 'mt'
env['LIB_NAME_SUFFIX'] = '${LIB_PLATFORM}_${LIB_LINK_TYPE}${LIB_CRUNTIME}' # must match autolink naming convention
env['JSONCPP_VERSION'] = JSONCPP_VERSION
env['BUILD_DIR'] = env.Dir(build_dir)
env['ROOTBUILD_DIR'] = env.Dir(rootbuild_dir)
env['DIST_DIR'] = DIST_DIR
if 'TarGz' in env['BUILDERS']:
class SrcDistAdder:
def __init__( self, env ):
self.env = env
def __call__( self, *args, **kw ):
apply( self.env.SrcDist, (self.env['SRCDIST_TARGET'],) + args, kw )
env['SRCDIST_BUILDER'] = env.TarGz
else: # If tarfile module is missing
class SrcDistAdder:
def __init__( self, env ):
pass
def __call__( self, *args, **kw ):
pass
env['SRCDIST_ADD'] = SrcDistAdder( env )
env['SRCDIST_TARGET'] = os.path.join( DIST_DIR, 'jsoncpp-src-%s.tar.gz' % env['JSONCPP_VERSION'] )

env_testing = env.Clone( )
env_testing.Append( LIBS = ['json_${LIB_NAME_SUFFIX}'] )

def buildJSONExample( env, target_sources, target_name ):
env = env.Clone()
env.Append( CPPPATH = ['#'] )
exe = env.Program( target=target_name,
source=target_sources )
env['SRCDIST_ADD']( source=[target_sources] )
global bin_dir
return env.Install( bin_dir, exe )

def buildJSONTests( env, target_sources, target_name ):
jsontests_node = buildJSONExample( env, target_sources, target_name )
check_alias_target = env.Alias( 'check', jsontests_node, RunJSONTests( jsontests_node, jsontests_node ) )
env.AlwaysBuild( check_alias_target )

def buildUnitTests( env, target_sources, target_name ):
jsontests_node = buildJSONExample( env, target_sources, target_name )
check_alias_target = env.Alias( 'check', jsontests_node,
RunUnitTests( jsontests_node, jsontests_node ) )
env.AlwaysBuild( check_alias_target )

def buildLibrary( env, target_sources, target_name ):
static_lib = env.StaticLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
source=target_sources )
global lib_dir
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['SRCDIST_ADD']( source=[target_sources] )

Export( 'env env_testing buildJSONExample buildLibrary buildJSONTests buildUnitTests' )

def buildProjectInDirectory( target_directory ):
global build_dir
target_build_dir = os.path.join( build_dir, target_directory )
target = os.path.join( target_directory, 'sconscript' )
SConscript( target, build_dir=target_build_dir, duplicate=0 )
env['SRCDIST_ADD']( source=[target] )


def runJSONTests_action( target, source = None, env = None ):
# Add test scripts to python path
jsontest_path = Dir( '#test' ).abspath
sys.path.insert( 0, jsontest_path )
data_path = os.path.join( jsontest_path, 'data' )
import runjsontests
return runjsontests.runAllTests( os.path.abspath(source[0].path), data_path )

def runJSONTests_string( target, source = None, env = None ):
return 'RunJSONTests("%s")' % source[0]

import SCons.Action
ActionFactory = SCons.Action.ActionFactory
RunJSONTests = ActionFactory(runJSONTests_action, runJSONTests_string )

def runUnitTests_action( target, source = None, env = None ):
# Add test scripts to python path
jsontest_path = Dir( '#test' ).abspath
sys.path.insert( 0, jsontest_path )
import rununittests
return rununittests.runAllTests( os.path.abspath(source[0].path) )

def runUnitTests_string( target, source = None, env = None ):
return 'RunUnitTests("%s")' % source[0]

RunUnitTests = ActionFactory(runUnitTests_action, runUnitTests_string )

env.Alias( 'check' )

srcdist_cmd = env['SRCDIST_ADD']( source = """
AUTHORS README.txt SConstruct
""".split() )
env.Alias( 'src-dist', srcdist_cmd )

buildProjectInDirectory( 'src/jsontestrunner' )
buildProjectInDirectory( 'src/lib_json' )
buildProjectInDirectory( 'src/test_lib_json' )
buildProjectInDirectory( 'doc' )
#print env.Dump()

0 comments on commit 6c846f1

Please sign in to comment.