mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-02-25 07:41:07 +01:00
Merge pull request #625 from SoapGentoo/mesonise
Add initial Meson build file
This commit is contained in:
commit
c21b4bbfdb
24
.travis.yml
24
.travis.yml
@ -7,14 +7,24 @@
|
||||
# to allow C++11, though we are not yet building with -std=c++11
|
||||
|
||||
install:
|
||||
- if [[ $TRAVIS_OS_NAME == osx ]]; then
|
||||
brew update;
|
||||
brew install python3 ninja;
|
||||
python3 -m venv venv;
|
||||
source venv/bin/activate;
|
||||
elif [[ $TRAVIS_OS_NAME == linux ]]; then
|
||||
wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip;
|
||||
unzip -q ninja-linux.zip -d build;
|
||||
fi
|
||||
- pip3 install meson
|
||||
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
|
||||
- if [[ $CXX = g++ ]]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
|
||||
# /usr/bin/clang has a conflict with gcc, so use clang-X.Y.
|
||||
- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
|
||||
- if [[ $CXX = clang++ ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
|
||||
- echo ${PATH}
|
||||
- ls /usr/local
|
||||
- ls /usr/local/bin
|
||||
- export PATH=/usr/local/bin:/usr/bin:${PATH}
|
||||
- export PATH="${PWD}"/build:/usr/local/bin:/usr/bin:${PATH}
|
||||
- echo ${CXX}
|
||||
- ${CXX} --version
|
||||
- which valgrind
|
||||
@ -23,10 +33,7 @@ addons:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
- george-edison55-precise-backports # cmake 3.2.3
|
||||
packages:
|
||||
- cmake
|
||||
- cmake-data
|
||||
- gcc-4.9
|
||||
- g++-4.9
|
||||
- clang-3.5
|
||||
@ -40,8 +47,9 @@ compiler:
|
||||
script: ./travis.sh
|
||||
env:
|
||||
matrix:
|
||||
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
|
||||
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
|
||||
- LIB_TYPE=static BUILD_TYPE=release
|
||||
- LIB_TYPE=shared BUILD_TYPE=debug
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
sudo: false
|
||||
|
102
meson.build
Normal file
102
meson.build
Normal file
@ -0,0 +1,102 @@
|
||||
project(
|
||||
'jsoncpp',
|
||||
'cpp',
|
||||
version : '1.8.0',
|
||||
default_options : [
|
||||
'buildtype=release',
|
||||
'warning_level=1'],
|
||||
license : 'Public Domain',
|
||||
meson_version : '>= 0.41.1')
|
||||
|
||||
jsoncpp_ver_arr = meson.project_version().split('.')
|
||||
jsoncpp_major_version = jsoncpp_ver_arr[0]
|
||||
jsoncpp_minor_version = jsoncpp_ver_arr[1]
|
||||
jsoncpp_patch_version = jsoncpp_ver_arr[2]
|
||||
|
||||
jsoncpp_cdata = configuration_data()
|
||||
jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version())
|
||||
jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version)
|
||||
jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version)
|
||||
jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version)
|
||||
|
||||
jsoncpp_gen_sources = configure_file(
|
||||
input : 'src/lib_json/version.h.in',
|
||||
output : 'version.h',
|
||||
configuration : jsoncpp_cdata,
|
||||
install : true,
|
||||
install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
|
||||
)
|
||||
|
||||
jsoncpp_headers = [
|
||||
'include/json/allocator.h',
|
||||
'include/json/assertions.h',
|
||||
'include/json/autolink.h',
|
||||
'include/json/config.h',
|
||||
'include/json/features.h',
|
||||
'include/json/forwards.h',
|
||||
'include/json/json.h',
|
||||
'include/json/reader.h',
|
||||
'include/json/value.h',
|
||||
'include/json/writer.h']
|
||||
jsoncpp_include_directories = include_directories('include')
|
||||
|
||||
install_headers(
|
||||
jsoncpp_headers,
|
||||
subdir : 'json')
|
||||
|
||||
jsoncpp_lib = library(
|
||||
'jsoncpp',
|
||||
[ jsoncpp_gen_sources,
|
||||
jsoncpp_headers,
|
||||
'src/lib_json/json_tool.h',
|
||||
'src/lib_json/json_reader.cpp',
|
||||
'src/lib_json/json_value.cpp',
|
||||
'src/lib_json/json_writer.cpp'],
|
||||
soversion : 18,
|
||||
install : true,
|
||||
include_directories : jsoncpp_include_directories)
|
||||
|
||||
import('pkgconfig').generate(
|
||||
libraries : jsoncpp_lib,
|
||||
version : meson.project_version(),
|
||||
name : 'jsoncpp',
|
||||
filebase : 'jsoncpp',
|
||||
description : 'A C++ library for interacting with JSON')
|
||||
|
||||
# for libraries bundling jsoncpp
|
||||
declare_dependency(
|
||||
include_directories : jsoncpp_include_directories,
|
||||
link_with : jsoncpp_lib,
|
||||
version : meson.project_version(),
|
||||
sources : jsoncpp_gen_sources)
|
||||
|
||||
# tests
|
||||
python = import('python3').find_python()
|
||||
|
||||
jsoncpp_test = executable(
|
||||
'jsoncpp_test',
|
||||
[ 'src/test_lib_json/jsontest.cpp',
|
||||
'src/test_lib_json/jsontest.h',
|
||||
'src/test_lib_json/main.cpp'],
|
||||
include_directories : jsoncpp_include_directories,
|
||||
link_with : jsoncpp_lib,
|
||||
install : false)
|
||||
test(
|
||||
'unittest_jsoncpp_test',
|
||||
jsoncpp_test)
|
||||
|
||||
jsontestrunner = executable(
|
||||
'jsontestrunner',
|
||||
'src/jsontestrunner/main.cpp',
|
||||
include_directories : jsoncpp_include_directories,
|
||||
link_with : jsoncpp_lib,
|
||||
install : false)
|
||||
test(
|
||||
'unittest_jsontestrunner',
|
||||
python,
|
||||
args : [
|
||||
'-B',
|
||||
join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
|
||||
jsontestrunner,
|
||||
join_paths(meson.current_source_dir(), 'test/data')]
|
||||
)
|
16
travis.sh
16
travis.sh
@ -17,15 +17,7 @@ set -vex
|
||||
|
||||
env | sort
|
||||
|
||||
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE .
|
||||
make
|
||||
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 .
|
||||
make
|
||||
|
||||
# Python is not available in Travis for osx.
|
||||
# https://github.com/travis-ci/travis-ci/issues/2320
|
||||
if [ "$TRAVIS_OS_NAME" != "osx" ]
|
||||
then
|
||||
make jsoncpp_check
|
||||
valgrind --error-exitcode=42 --leak-check=full ./src/test_lib_json/jsoncpp_test
|
||||
fi
|
||||
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
|
||||
ninja -v -C build-${LIB_TYPE}
|
||||
ninja -v -C build-${LIB_TYPE} test
|
||||
rm -r build-${LIB_TYPE}
|
||||
|
Loading…
x
Reference in New Issue
Block a user