Skip to content

Commit 7b28698

Browse files
authored
Cleanup versioning strategy relanding (#989) (#997)
* Cleanup versioning strategy Currently, versioning is a mess. CMake and Meson have seperate build version number storage locations, with no way of knowing you need to have both. Plus, due to recent revisions the amalgamate script is broken unless you build first, and may still be broken afterwards. This PR fixes some issues with versioning, and adds comments clarifying what has to be done when doing a release. * Run clang format * Update SOVERSION....
1 parent 0d27381 commit 7b28698

12 files changed

+81
-85
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
/libs/
1111
/doc/doxyfile
1212
/dist/
13-
#/version
14-
#/include/json/version.h
1513

1614
# MSVC project files:
1715
*.sln

CMakeLists.txt

+9-6
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,18 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
6363
endif()
6464

6565
project(JSONCPP
66-
VERSION 1.9.0 # <major>[.<minor>[.<patch>[.<tweak>]]]
66+
# Note: version must be updated in three places when doing a release. This
67+
# annoying process ensures that amalgamate, CMake, and meson all report the
68+
# correct version.
69+
# 1. /meson.build
70+
# 2. /include/json/version.h
71+
# 3. /CMakeLists.txt
72+
# IMPORTANT: also update the SOVERSION!!
73+
VERSION 1.9.2 # <major>[.<minor>[.<patch>[.<tweak>]]]
6774
LANGUAGES CXX)
6875

6976
message(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
70-
set( JSONCPP_SOVERSION 21 )
77+
set( JSONCPP_SOVERSION 22 )
7178

7279
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
7380
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
@@ -89,10 +96,6 @@ set(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the libra
8996

9097
set(JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
9198

92-
# File version.h is only regenerated on CMake configure step
93-
configure_file( "${PROJECT_SOURCE_DIR}/src/lib_json/version.h.in"
94-
"${PROJECT_BINARY_DIR}/include/json/version.h"
95-
NEWLINE_STYLE UNIX )
9699
configure_file( "${PROJECT_SOURCE_DIR}/version.in"
97100
"${PROJECT_BINARY_DIR}/version"
98101
NEWLINE_STYLE UNIX )

CONTRIBUTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Then,
2626
LIB_TYPE=shared
2727
#LIB_TYPE=static
2828
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
29-
#ninja -v -C build-${LIB_TYPE} test # This stopped working on my Mac.
3029
ninja -v -C build-${LIB_TYPE}
3130
cd build-${LIB_TYPE}
3231
meson test --no-rebuild --print-errorlogs

amalgamate.py

100644100755
+21-17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python
2+
13
"""Amalgamate json-cpp library sources into a single source and header file.
24
35
Works with python2.6+ and python3.4+.
@@ -9,6 +11,9 @@
911
import os.path
1012
import sys
1113

14+
INCLUDE_PATH = "include/json"
15+
SRC_PATH = "src/lib_json"
16+
1217
class AmalgamationFile:
1318
def __init__(self, top_dir):
1419
self.top_dir = top_dir
@@ -66,15 +71,15 @@ def amalgamate_source(source_top_dir=None,
6671
header.add_text("/// If defined, indicates that the source file is amalgamated")
6772
header.add_text("/// to prevent private header inclusion.")
6873
header.add_text("#define JSON_IS_AMALGAMATION")
69-
header.add_file("include/json/version.h")
70-
header.add_file("include/json/allocator.h")
71-
header.add_file("include/json/config.h")
72-
header.add_file("include/json/forwards.h")
73-
header.add_file("include/json/features.h")
74-
header.add_file("include/json/value.h")
75-
header.add_file("include/json/reader.h")
76-
header.add_file("include/json/writer.h")
77-
header.add_file("include/json/assertions.h")
74+
header.add_file(os.path.join(INCLUDE_PATH, "version.h"))
75+
header.add_file(os.path.join(INCLUDE_PATH, "allocator.h"))
76+
header.add_file(os.path.join(INCLUDE_PATH, "config.h"))
77+
header.add_file(os.path.join(INCLUDE_PATH, "forwards.h"))
78+
header.add_file(os.path.join(INCLUDE_PATH, "features.h"))
79+
header.add_file(os.path.join(INCLUDE_PATH, "value.h"))
80+
header.add_file(os.path.join(INCLUDE_PATH, "reader.h"))
81+
header.add_file(os.path.join(INCLUDE_PATH, "writer.h"))
82+
header.add_file(os.path.join(INCLUDE_PATH, "assertions.h"))
7883
header.add_text("#endif //ifndef JSON_AMALGAMATED_H_INCLUDED")
7984

8085
target_header_path = os.path.join(os.path.dirname(target_source_path), header_include_path)
@@ -94,8 +99,8 @@ def amalgamate_source(source_top_dir=None,
9499
header.add_text("/// If defined, indicates that the source file is amalgamated")
95100
header.add_text("/// to prevent private header inclusion.")
96101
header.add_text("#define JSON_IS_AMALGAMATION")
97-
header.add_file("include/json/config.h")
98-
header.add_file("include/json/forwards.h")
102+
header.add_file(os.path.join(INCLUDE_PATH, "config.h"))
103+
header.add_file(os.path.join(INCLUDE_PATH, "forwards.h"))
99104
header.add_text("#endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED")
100105

101106
target_forward_header_path = os.path.join(os.path.dirname(target_source_path),
@@ -116,12 +121,11 @@ def amalgamate_source(source_top_dir=None,
116121
#endif
117122
""")
118123
source.add_text("")
119-
lib_json = "src/lib_json"
120-
source.add_file(os.path.join(lib_json, "json_tool.h"))
121-
source.add_file(os.path.join(lib_json, "json_reader.cpp"))
122-
source.add_file(os.path.join(lib_json, "json_valueiterator.inl"))
123-
source.add_file(os.path.join(lib_json, "json_value.cpp"))
124-
source.add_file(os.path.join(lib_json, "json_writer.cpp"))
124+
source.add_file(os.path.join(SRC_PATH, "json_tool.h"))
125+
source.add_file(os.path.join(SRC_PATH, "json_reader.cpp"))
126+
source.add_file(os.path.join(SRC_PATH, "json_valueiterator.inl"))
127+
source.add_file(os.path.join(SRC_PATH, "json_value.cpp"))
128+
source.add_file(os.path.join(SRC_PATH, "json_writer.cpp"))
125129

126130
print("Writing amalgamated source to %r" % target_source_path)
127131
source.write_to(target_source_path)

doc/jsoncpp.dox

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
\section _intro Introduction
44

55
<a HREF="http://www.json.org/">JSON (JavaScript Object Notation)</a>
6-
is a lightweight data-interchange format.
6+
is a lightweight data-interchange format.
77

88
Here is an example of JSON data:
99
\verbatim
@@ -23,14 +23,14 @@ Here is an example of JSON data:
2323
{
2424
// Default encoding for text
2525
"encoding" : "UTF-8",
26-
26+
2727
// Plug-ins loaded at start-up
2828
"plug-ins" : [
2929
"python",
3030
"c++", // trailing comment
3131
"ruby"
3232
],
33-
33+
3434
// Tab indent size
3535
// (multi-line comment)
3636
"indent" : { /*embedded comment*/ "length" : 3, "use_space": true }
@@ -67,7 +67,7 @@ const Json::Value plugins = root["plug-ins"];
6767
// Iterate over the sequence elements.
6868
for ( int index = 0; index < plugins.size(); ++index )
6969
loadPlugIn( plugins[index].asString() );
70-
70+
7171
// Try other datatypes. Some are auto-convertible to others.
7272
foo::setIndentLength( root["indent"].get("length", 3).asInt() );
7373
foo::setIndentUseSpace( root["indent"].get("use_space", true).asBool() );
@@ -124,15 +124,15 @@ reader->parse(start, stop, &value2, &errs);
124124
\endcode
125125

126126
\section _pbuild Build instructions
127-
The build instructions are located in the file
127+
The build instructions are located in the file
128128
<a HREF="https://github.com/open-source-parsers/jsoncpp/blob/master/README.md">README.md</a> in the top-directory of the project.
129129

130130
The latest version of the source is available in the project's GitHub repository:
131131
<a HREF="https://github.com/open-source-parsers/jsoncpp/">
132132
jsoncpp</a>
133133

134134
\section _news What's New?
135-
The description of latest changes can be found in
135+
The description of latest changes can be found in
136136
<a HREF="https://github.com/open-source-parsers/jsoncpp/wiki/NEWS">
137137
the NEWS wiki
138138
</a>.
@@ -152,7 +152,7 @@ The description of latest changes can be found in
152152
\section _license License
153153
See file <a href="https://github.com/open-source-parsers/jsoncpp/blob/master/LICENSE"><code>LICENSE</code></a> in the top-directory of the project.
154154

155-
Basically JsonCpp is licensed under MIT license, or public domain if desired
155+
Basically JsonCpp is licensed under MIT license, or public domain if desired
156156
and recognized in your jurisdiction.
157157

158158
\author Baptiste Lepilleur <[email protected]> (originator)

include/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
file(GLOB INCLUDE_FILES "json/*.h")
22
install(FILES
33
${INCLUDE_FILES}
4-
${PROJECT_BINARY_DIR}/include/json/version.h
54
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
65

include/json/reader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ bool JSON_API parseFromStream(CharReader::Factory const&,
378378
/** \brief Read from 'sin' into 'root'.
379379
*
380380
* Always keep comments from the input JSON.
381-
*
381+
*
382382
* This can be used to read a file into a particular sub-object.
383383
* For example:
384384
* \code

include/json/version.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef JSON_VERSION_H_INCLUDED
2+
#define JSON_VERSION_H_INCLUDED
3+
4+
// Note: version must be updated in three places when doing a release. This
5+
// annoying process ensures that amalgamate, CMake, and meson all report the
6+
// correct version.
7+
// 1. /meson.build
8+
// 2. /include/json/version.h
9+
// 3. /CMakeLists.txt
10+
// IMPORTANT: also update the SOVERSION!!
11+
12+
#define JSONCPP_VERSION_STRING "1.9.2"
13+
#define JSONCPP_VERSION_MAJOR 1
14+
#define JSONCPP_VERSION_MINOR 9
15+
#define JSONCPP_VERSION_PATCH 2
16+
#define JSONCPP_VERSION_QUALIFIER
17+
#define JSONCPP_VERSION_HEXA \
18+
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
19+
(JSONCPP_VERSION_PATCH << 8))
20+
21+
#ifdef JSONCPP_USING_SECURE_MEMORY
22+
#undef JSONCPP_USING_SECURE_MEMORY
23+
#endif
24+
#define JSONCPP_USING_SECURE_MEMORY 0
25+
// If non-zero, the library zeroes any memory that it has allocated before
26+
// it frees its memory.
27+
28+
#endif // JSON_VERSION_H_INCLUDED

meson.build

+13-24
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
project(
22
'jsoncpp',
33
'cpp',
4-
version : '1.9.0',
4+
5+
# Note: version must be updated in three places when doing a release. This
6+
# annoying process ensures that amalgamate, CMake, and meson all report the
7+
# correct version.
8+
# 1. /meson.build
9+
# 2. /include/json/version.h
10+
# 3. /CMakeLists.txt
11+
# IMPORTANT: also update the SOVERSION!!
12+
version : '1.9.2',
513
default_options : [
614
'buildtype=release',
715
'cpp_std=c++11',
816
'warning_level=1'],
917
license : 'Public Domain',
1018
meson_version : '>= 0.50.0')
1119

12-
jsoncpp_ver_arr = meson.project_version().split('.')
13-
jsoncpp_major_version = jsoncpp_ver_arr[0]
14-
jsoncpp_minor_version = jsoncpp_ver_arr[1]
15-
jsoncpp_patch_version = jsoncpp_ver_arr[2]
16-
17-
jsoncpp_cdata = configuration_data()
18-
jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version())
19-
jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version)
20-
jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version)
21-
jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version)
22-
jsoncpp_cdata.set('JSONCPP_USE_SECURE_MEMORY',0)
23-
24-
jsoncpp_gen_sources = configure_file(
25-
input : 'src/lib_json/version.h.in',
26-
output : 'version.h',
27-
configuration : jsoncpp_cdata,
28-
install : true,
29-
install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
30-
)
3120

3221
jsoncpp_headers = [
3322
'include/json/allocator.h',
@@ -39,6 +28,7 @@ jsoncpp_headers = [
3928
'include/json/json.h',
4029
'include/json/reader.h',
4130
'include/json/value.h',
31+
'include/json/version.h',
4232
'include/json/writer.h']
4333
jsoncpp_include_directories = include_directories('include')
4434

@@ -56,13 +46,12 @@ endif
5646

5747
jsoncpp_lib = library(
5848
'jsoncpp',
59-
[ jsoncpp_gen_sources,
60-
jsoncpp_headers,
49+
[ jsoncpp_headers,
6150
'src/lib_json/json_tool.h',
6251
'src/lib_json/json_reader.cpp',
6352
'src/lib_json/json_value.cpp',
6453
'src/lib_json/json_writer.cpp'],
65-
soversion : 21,
54+
soversion : 22,
6655
install : true,
6756
include_directories : jsoncpp_include_directories,
6857
cpp_args: dll_export_flag)
@@ -79,7 +68,7 @@ jsoncpp_dep = declare_dependency(
7968
include_directories : jsoncpp_include_directories,
8069
link_with : jsoncpp_lib,
8170
version : meson.project_version(),
82-
sources : jsoncpp_gen_sources)
71+
)
8372

8473
# tests
8574
python = import('python3').find_python()

src/lib_json/CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ set( PUBLIC_HEADERS
4545
${JSONCPP_INCLUDE_DIR}/json/features.h
4646
${JSONCPP_INCLUDE_DIR}/json/value.h
4747
${JSONCPP_INCLUDE_DIR}/json/reader.h
48+
${JSONCPP_INCLUDE_DIR}/json/version.h
4849
${JSONCPP_INCLUDE_DIR}/json/writer.h
4950
${JSONCPP_INCLUDE_DIR}/json/assertions.h
50-
${PROJECT_BINARY_DIR}/include/json/version.h
5151
)
5252

5353
source_group( "Public API" FILES ${PUBLIC_HEADERS} )
@@ -57,8 +57,7 @@ set(jsoncpp_sources
5757
json_reader.cpp
5858
json_valueiterator.inl
5959
json_value.cpp
60-
json_writer.cpp
61-
version.h.in)
60+
json_writer.cpp)
6261

6362
# Install instructions for this target
6463
if(JSONCPP_WITH_CMAKE_PACKAGE)

src/lib_json/version.h.in

-22
This file was deleted.

version.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)