Skip to content

Commit c21b4bb

Browse files
authored
Merge pull request #625 from SoapGentoo/mesonise
Add initial Meson build file
2 parents 154652e + d14d8c3 commit c21b4bb

File tree

3 files changed

+122
-20
lines changed

3 files changed

+122
-20
lines changed

.travis.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77
# to allow C++11, though we are not yet building with -std=c++11
88

99
install:
10+
- if [[ $TRAVIS_OS_NAME == osx ]]; then
11+
brew update;
12+
brew install python3 ninja;
13+
python3 -m venv venv;
14+
source venv/bin/activate;
15+
elif [[ $TRAVIS_OS_NAME == linux ]]; then
16+
wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip;
17+
unzip -q ninja-linux.zip -d build;
18+
fi
19+
- pip3 install meson
1020
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
11-
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
21+
- if [[ $CXX = g++ ]]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
1222
# /usr/bin/clang has a conflict with gcc, so use clang-X.Y.
13-
- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
23+
- if [[ $CXX = clang++ ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
1424
- echo ${PATH}
1525
- ls /usr/local
1626
- ls /usr/local/bin
17-
- export PATH=/usr/local/bin:/usr/bin:${PATH}
27+
- export PATH="${PWD}"/build:/usr/local/bin:/usr/bin:${PATH}
1828
- echo ${CXX}
1929
- ${CXX} --version
2030
- which valgrind
@@ -23,10 +33,7 @@ addons:
2333
sources:
2434
- ubuntu-toolchain-r-test
2535
- llvm-toolchain-precise-3.5
26-
- george-edison55-precise-backports # cmake 3.2.3
2736
packages:
28-
- cmake
29-
- cmake-data
3037
- gcc-4.9
3138
- g++-4.9
3239
- clang-3.5
@@ -40,8 +47,9 @@ compiler:
4047
script: ./travis.sh
4148
env:
4249
matrix:
43-
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
44-
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
50+
- LIB_TYPE=static BUILD_TYPE=release
51+
- LIB_TYPE=shared BUILD_TYPE=debug
4552
notifications:
4653
email: false
54+
dist: trusty
4755
sudo: false

meson.build

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
project(
2+
'jsoncpp',
3+
'cpp',
4+
version : '1.8.0',
5+
default_options : [
6+
'buildtype=release',
7+
'warning_level=1'],
8+
license : 'Public Domain',
9+
meson_version : '>= 0.41.1')
10+
11+
jsoncpp_ver_arr = meson.project_version().split('.')
12+
jsoncpp_major_version = jsoncpp_ver_arr[0]
13+
jsoncpp_minor_version = jsoncpp_ver_arr[1]
14+
jsoncpp_patch_version = jsoncpp_ver_arr[2]
15+
16+
jsoncpp_cdata = configuration_data()
17+
jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version())
18+
jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version)
19+
jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version)
20+
jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version)
21+
22+
jsoncpp_gen_sources = configure_file(
23+
input : 'src/lib_json/version.h.in',
24+
output : 'version.h',
25+
configuration : jsoncpp_cdata,
26+
install : true,
27+
install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
28+
)
29+
30+
jsoncpp_headers = [
31+
'include/json/allocator.h',
32+
'include/json/assertions.h',
33+
'include/json/autolink.h',
34+
'include/json/config.h',
35+
'include/json/features.h',
36+
'include/json/forwards.h',
37+
'include/json/json.h',
38+
'include/json/reader.h',
39+
'include/json/value.h',
40+
'include/json/writer.h']
41+
jsoncpp_include_directories = include_directories('include')
42+
43+
install_headers(
44+
jsoncpp_headers,
45+
subdir : 'json')
46+
47+
jsoncpp_lib = library(
48+
'jsoncpp',
49+
[ jsoncpp_gen_sources,
50+
jsoncpp_headers,
51+
'src/lib_json/json_tool.h',
52+
'src/lib_json/json_reader.cpp',
53+
'src/lib_json/json_value.cpp',
54+
'src/lib_json/json_writer.cpp'],
55+
soversion : 18,
56+
install : true,
57+
include_directories : jsoncpp_include_directories)
58+
59+
import('pkgconfig').generate(
60+
libraries : jsoncpp_lib,
61+
version : meson.project_version(),
62+
name : 'jsoncpp',
63+
filebase : 'jsoncpp',
64+
description : 'A C++ library for interacting with JSON')
65+
66+
# for libraries bundling jsoncpp
67+
declare_dependency(
68+
include_directories : jsoncpp_include_directories,
69+
link_with : jsoncpp_lib,
70+
version : meson.project_version(),
71+
sources : jsoncpp_gen_sources)
72+
73+
# tests
74+
python = import('python3').find_python()
75+
76+
jsoncpp_test = executable(
77+
'jsoncpp_test',
78+
[ 'src/test_lib_json/jsontest.cpp',
79+
'src/test_lib_json/jsontest.h',
80+
'src/test_lib_json/main.cpp'],
81+
include_directories : jsoncpp_include_directories,
82+
link_with : jsoncpp_lib,
83+
install : false)
84+
test(
85+
'unittest_jsoncpp_test',
86+
jsoncpp_test)
87+
88+
jsontestrunner = executable(
89+
'jsontestrunner',
90+
'src/jsontestrunner/main.cpp',
91+
include_directories : jsoncpp_include_directories,
92+
link_with : jsoncpp_lib,
93+
install : false)
94+
test(
95+
'unittest_jsontestrunner',
96+
python,
97+
args : [
98+
'-B',
99+
join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
100+
jsontestrunner,
101+
join_paths(meson.current_source_dir(), 'test/data')]
102+
)

travis.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ set -vex
1717

1818
env | sort
1919

20-
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE .
21-
make
22-
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE -DJSONCPP_USE_SECURE_MEMORY=1 .
23-
make
24-
25-
# Python is not available in Travis for osx.
26-
# https://github.com/travis-ci/travis-ci/issues/2320
27-
if [ "$TRAVIS_OS_NAME" != "osx" ]
28-
then
29-
make jsoncpp_check
30-
valgrind --error-exitcode=42 --leak-check=full ./src/test_lib_json/jsoncpp_test
31-
fi
20+
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
21+
ninja -v -C build-${LIB_TYPE}
22+
ninja -v -C build-${LIB_TYPE} test
23+
rm -r build-${LIB_TYPE}

0 commit comments

Comments
 (0)