1
- """Amalgate json-cpp library sources into a single source and header file.
1
+ """Amalgamate json-cpp library sources into a single source and header file.
2
2
3
3
Works with python2.6+ and python3.4+.
4
4
5
5
Example of invocation (must be invoked from json-cpp top directory):
6
- python amalgate .py
6
+ python amalgamate .py
7
7
"""
8
8
import os
9
9
import os .path
@@ -50,20 +50,20 @@ def write_to(self, output_path):
50
50
def amalgamate_source (source_top_dir = None ,
51
51
target_source_path = None ,
52
52
header_include_path = None ):
53
- """Produces amalgated source.
53
+ """Produces amalgamated source.
54
54
Parameters:
55
55
source_top_dir: top-directory
56
56
target_source_path: output .cpp path
57
57
header_include_path: generated header path relative to target_source_path.
58
58
"""
59
- print ("Amalgating header..." )
59
+ print ("Amalgamating header..." )
60
60
header = AmalgamationFile (source_top_dir )
61
- header .add_text ("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/)." )
61
+ header .add_text ("/// Json-cpp amalgamated header (http://jsoncpp.sourceforge.net/)." )
62
62
header .add_text ('/// It is intended to be used with #include "%s"' % header_include_path )
63
63
header .add_file ("LICENSE" , wrap_in_comment = True )
64
- header .add_text ("#ifndef JSON_AMALGATED_H_INCLUDED " )
65
- header .add_text ("# define JSON_AMALGATED_H_INCLUDED " )
66
- header .add_text ("/// If defined, indicates that the source file is amalgated " )
64
+ header .add_text ("#ifndef JSON_AMALGAMATED_H_INCLUDED " )
65
+ header .add_text ("# define JSON_AMALGAMATED_H_INCLUDED " )
66
+ header .add_text ("/// If defined, indicates that the source file is amalgamated " )
67
67
header .add_text ("/// to prevent private header inclusion." )
68
68
header .add_text ("#define JSON_IS_AMALGAMATION" )
69
69
header .add_file ("include/json/version.h" )
@@ -75,37 +75,37 @@ def amalgamate_source(source_top_dir=None,
75
75
header .add_file ("include/json/reader.h" )
76
76
header .add_file ("include/json/writer.h" )
77
77
header .add_file ("include/json/assertions.h" )
78
- header .add_text ("#endif //ifndef JSON_AMALGATED_H_INCLUDED " )
78
+ header .add_text ("#endif //ifndef JSON_AMALGAMATED_H_INCLUDED " )
79
79
80
80
target_header_path = os .path .join (os .path .dirname (target_source_path ), header_include_path )
81
- print ("Writing amalgated header to %r" % target_header_path )
81
+ print ("Writing amalgamated header to %r" % target_header_path )
82
82
header .write_to (target_header_path )
83
83
84
84
base , ext = os .path .splitext (header_include_path )
85
85
forward_header_include_path = base + "-forwards" + ext
86
- print ("Amalgating forward header..." )
86
+ print ("Amalgamating forward header..." )
87
87
header = AmalgamationFile (source_top_dir )
88
- header .add_text ("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/)." )
88
+ header .add_text ("/// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/)." )
89
89
header .add_text ('/// It is intended to be used with #include "%s"' % forward_header_include_path )
90
90
header .add_text ("/// This header provides forward declaration for all JsonCpp types." )
91
91
header .add_file ("LICENSE" , wrap_in_comment = True )
92
- header .add_text ("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED " )
93
- header .add_text ("# define JSON_FORWARD_AMALGATED_H_INCLUDED " )
94
- header .add_text ("/// If defined, indicates that the source file is amalgated " )
92
+ header .add_text ("#ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED " )
93
+ header .add_text ("# define JSON_FORWARD_AMALGAMATED_H_INCLUDED " )
94
+ header .add_text ("/// If defined, indicates that the source file is amalgamated " )
95
95
header .add_text ("/// to prevent private header inclusion." )
96
96
header .add_text ("#define JSON_IS_AMALGAMATION" )
97
97
header .add_file ("include/json/config.h" )
98
98
header .add_file ("include/json/forwards.h" )
99
- header .add_text ("#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED " )
99
+ header .add_text ("#endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED " )
100
100
101
101
target_forward_header_path = os .path .join (os .path .dirname (target_source_path ),
102
102
forward_header_include_path )
103
- print ("Writing amalgated forward header to %r" % target_forward_header_path )
103
+ print ("Writing amalgamated forward header to %r" % target_forward_header_path )
104
104
header .write_to (target_forward_header_path )
105
105
106
- print ("Amalgating source..." )
106
+ print ("Amalgamating source..." )
107
107
source = AmalgamationFile (source_top_dir )
108
- source .add_text ("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/)." )
108
+ source .add_text ("/// Json-cpp amalgamated source (http://jsoncpp.sourceforge.net/)." )
109
109
source .add_text ('/// It is intended to be used with #include "%s"' % header_include_path )
110
110
source .add_file ("LICENSE" , wrap_in_comment = True )
111
111
source .add_text ("" )
@@ -123,20 +123,20 @@ def amalgamate_source(source_top_dir=None,
123
123
source .add_file (os .path .join (lib_json , "json_value.cpp" ))
124
124
source .add_file (os .path .join (lib_json , "json_writer.cpp" ))
125
125
126
- print ("Writing amalgated source to %r" % target_source_path )
126
+ print ("Writing amalgamated source to %r" % target_source_path )
127
127
source .write_to (target_source_path )
128
128
129
129
def main ():
130
130
usage = """%prog [options]
131
- Generate a single amalgated source and header file from the sources.
131
+ Generate a single amalgamated source and header file from the sources.
132
132
"""
133
133
from optparse import OptionParser
134
134
parser = OptionParser (usage = usage )
135
135
parser .allow_interspersed_args = False
136
136
parser .add_option ("-s" , "--source" , dest = "target_source_path" , action = "store" , default = "dist/jsoncpp.cpp" ,
137
137
help = """Output .cpp source path. [Default: %default]""" )
138
138
parser .add_option ("-i" , "--include" , dest = "header_include_path" , action = "store" , default = "json/json.h" ,
139
- help = """Header include path. Used to include the header from the amalgated source file. [Default: %default]""" )
139
+ help = """Header include path. Used to include the header from the amalgamated source file. [Default: %default]""" )
140
140
parser .add_option ("-t" , "--top-dir" , dest = "top_dir" , action = "store" , default = os .getcwd (),
141
141
help = """Source top-directory. [Default: %default]""" )
142
142
parser .enable_interspersed_args ()
@@ -149,7 +149,7 @@ def main():
149
149
sys .stderr .write (msg + "\n " )
150
150
sys .exit (1 )
151
151
else :
152
- print ("Source succesfully amalagated " )
152
+ print ("Source successfully amalgamated " )
153
153
154
154
if __name__ == "__main__" :
155
155
main ()
0 commit comments