help use of amalgamated header

* Include from same-directory first, so `-I DIR` is rarely needed.
* Double-check that proper header has been included.

http://stackoverflow.com/questions/28510109/linking-problems-with-jsoncpp
This commit is contained in:
Christopher Dunn 2015-02-15 10:47:49 -06:00
parent 1522e4dfb1
commit 0ee7e2426f

View File

@ -59,7 +59,7 @@ def amalgamate_source(source_top_dir=None,
print("Amalgating header...")
header = AmalgamationFile(source_top_dir)
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
header.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
header.add_text('/// It is intented to be used with #include "%s"' % header_include_path)
header.add_file("LICENSE", wrap_in_comment=True)
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
@ -85,7 +85,7 @@ def amalgamate_source(source_top_dir=None,
print("Amalgating forward header...")
header = AmalgamationFile(source_top_dir)
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
header.add_text("/// It is intented to be used with #include <%s>" % forward_header_include_path)
header.add_text('/// It is intented to be used with #include "%s"' % forward_header_include_path)
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
header.add_file("LICENSE", wrap_in_comment=True)
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
@ -105,10 +105,15 @@ def amalgamate_source(source_top_dir=None,
print("Amalgating source...")
source = AmalgamationFile(source_top_dir)
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
source.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
source.add_text('/// It is intented to be used with #include "%s"' % header_include_path)
source.add_file("LICENSE", wrap_in_comment=True)
source.add_text("")
source.add_text("#include <%s>" % header_include_path)
source.add_text('#include "%s"' % header_include_path)
source.add_text("""
#ifndef JSON_IS_AMALGAMATED
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
#endif
""")
source.add_text("")
lib_json = "src/lib_json"
source.add_file(os.path.join(lib_json, "json_tool.h"))