Menu

[r21]: / trunk / SConstruct  Maximize  Restore  History

Download this file

91 lines (74 with data), 3.7 kB

 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
##
# JsonRpc-Cpp build file.
#
# Configure compiler arguments
cflags = ['-std=c++98', '-Wall', '-W', '-pedantic', '-Wredundant-decls', '-Wshadow', '-Werror', '-O2'];
# Command line parsing
# Build with debug symbols or not
if ARGUMENTS.get('mode', 0) == 'debug':
cflags.append('-g');
# Installation directory
if ARGUMENTS.get('prefix', 0) != 0:
install_dir = ARGUMENTS.get('prefix', '');
else:
install_dir = '/usr/local';
# Create an environment
env = Environment(tools = ["default", "doxygen"], toolpath = ['.', './doc'], CXXFLAGS = cflags);
# Sources and name of the JsonRpc-Cpp library
lib_target = 'jsonrpc';
lib_sources = ['src/jsonrpc_handler.cpp', 'src/jsonrpc_server.cpp', 'src/jsonrpc_client.cpp',
'src/jsonrpc_udpserver.cpp', 'src/jsonrpc_tcpserver.cpp', 'src/jsonrpc_udpclient.cpp',
'src/jsonrpc_tcpclient.cpp', 'src/netstring.cpp'];
lib_includes = ['src/jsonrpc.h', 'src/jsonrpc_handler.h', 'src/jsonrpc_server.h', 'src/jsonrpc_client.h',
'src/jsonrpc_udpserver.h', 'src/jsonrpc_tcpserver.h', 'src/jsonrpc_udpclient.h',
'src/jsonrpc_tcpclient.h', 'src/jsonrpc_common.h', 'src/netstring.h'];
# Build libjsonrpc
libjsonrpc = env.SharedLibrary(target = lib_target, source = lib_sources, LIBS=['json']);
# Build examples
examples_sources = ['examples/test-rpc.cpp', lib_sources];
udpserver_sources = ['examples/udp-server.cpp'];
tcpserver_sources = ['examples/tcp-server.cpp'];
udpclient_sources = ['examples/udp-client.cpp'];
tcpclient_sources = ['examples/tcp-client.cpp'];
examples_common = env.Object(examples_sources);
tcpserver = env.Program(target = 'examples/tcp-server', source = [tcpserver_sources, examples_common], LIBS=['json']);
udpserver = env.Program(target = 'examples/udp-server', source = [udpserver_sources, examples_common], LIBS=['json']);
tcpclient = env.Program(target = 'examples/tcp-client', source = [tcpclient_sources, examples_common], LIBS=['json']);
udpclient = env.Program(target = 'examples/udp-client', source = [udpclient_sources, examples_common], LIBS=['json']);
# Build unit tests
test_common = env.Object(lib_sources);
unittest_sources = ['test/test-runner.cpp', 'test/test-core.cpp', 'test/test-netstring.cpp']
unittest = env.Program(target = 'test/test-runner', source = [unittest_sources, test_common], LIBS=['json', 'cppunit']);
# Run unit tests
runtest = env.Command('runtest', None, "test/test-runner $SOURCE $TARGET");
# Install script
env.Install(dir = install_dir + "/lib/", source = libjsonrpc);
env.Install(dir = install_dir + "/include/jsonrpc/", source = lib_includes);
# Doxygen
doxygen = env.Doxygen("Doxyfile");
Clean(doxygen, "doc/doxygen.pyc");
AlwaysBuild(doxygen);
env.Alias('doxygen', doxygen);
# Alias for target
env.Alias('build', [libjsonrpc]);
env.Alias('examples', ['build', tcpserver, udpserver, tcpclient, udpclient]);
env.Alias('all', ['build', 'examples', 'doc', 'test']);
env.Alias('install', [install_dir]);
env.Alias('test', ['build', unittest]);
env.Alias('runtest', ['test', runtest]);
# Help documentation
Help("""
Type: 'scons build' to build JsonRpc-Cpp library,
'scons install' to install the JsonRpc-Cpp library in the system,
'scons doc' to build documentation (doxygen),
'scons test' to build unit tests,
'scons runtest' to run unit tests,
'scons -c' to clean object files,
'scons -c install' to uninstall library and include files,
'scons -c doc' to remove documentation files,
'scons -c all' to cleanup everything.
\n
Default target when launching scons without argument is 'scons build'.
""");
# Default target when running scons without arguments
Default('build');