Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using more CMake #765

Merged
merged 25 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c87b080
:construction_worker: new cmake file for test cases
nlohmann Aug 25, 2017
05b97c4
:construction_worker: added flags for Valgrind and Clang sanitizer
nlohmann Aug 25, 2017
3dcd360
:construction_worker: adding status messages
nlohmann Aug 25, 2017
839681f
:construction_worker: using Ninja
nlohmann Aug 25, 2017
268f5a3
:construction_worker: added option to switch off exceptions
nlohmann Aug 25, 2017
5e7acbf
:construction_worker: adjusted flags for Clang sanitizer
nlohmann Aug 25, 2017
8608f42
:construction_worker: trying to use libstdc++
nlohmann Aug 25, 2017
4f5c345
:construction_worker: run sanitizer another time to check if it works
nlohmann Aug 26, 2017
0e94ba8
:construction_worker: using the same compilers
nlohmann Aug 26, 2017
15e757c
:hammer: trying to fix memory issue with valarray
nlohmann Aug 27, 2017
b41b130
:construction_worker: removed unneccessary test
nlohmann Aug 27, 2017
31ce7e1
Merge branch 'develop' into feature/issue698
nlohmann Sep 9, 2017
c1d6478
Merge branch 'develop' into feature/issue698
nlohmann Sep 9, 2017
41994ba
Merge branch 'develop' into feature/issue698
nlohmann Sep 9, 2017
295d65a
Merge branch 'develop' into feature/issue698
nlohmann Sep 9, 2017
cafc2d0
Merge branch 'develop' into feature/issue698
nlohmann Sep 10, 2017
248db1e
Merge branch 'develop' into feature/issue698
nlohmann Sep 10, 2017
82c9368
Merge branch 'develop' into feature/issue698
nlohmann Sep 10, 2017
e75adc2
Merge branch 'develop' into feature/issue698
nlohmann Sep 13, 2017
f89f8b2
Merge branch 'develop' into feature/issue698
nlohmann Oct 2, 2017
4912231
Merge branch 'develop' into feature/issue698
nlohmann Oct 2, 2017
54bd1b5
Merge branch 'develop' into feature/issue698
nlohmann Oct 3, 2017
3457e7b
:checkered_flag: try to get MSVC 2017 running again
nlohmann Oct 3, 2017
a85bc35
:checkered_flag: another try
nlohmann Oct 3, 2017
e2045ea
:checkered_flag: and another try
nlohmann Oct 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 25 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,28 @@ matrix:
include:

# Valgrind

- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=valgrind
- CMAKE_OPTIONS=-DJSON_Valgrind=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: [g++-4.9, valgrind]
after_success:
- make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""
packages: ['g++-4.9', 'valgrind', 'ninja-build']

# clang sanitizer
- os: linux
compiler: clang
env:
- COMPILER=clang++-5.0
- SPECIAL=sanitizer
- CMAKE_OPTIONS=-DJSON_Sanitizer=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0']
after_success:
- make clang_sanitize -j4
packages: ['g++-6', 'clang-5.0', 'ninja-build']

# cppcheck

- os: linux
compiler: gcc
env:
Expand All @@ -65,24 +59,20 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: [g++-4.9, cppcheck]
packages: ['g++-4.9', 'cppcheck', 'ninja-build']
after_success:
- make cppcheck

# no exceptions

- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=no_exceptions
- CMAKE_OPTIONS=-DJSON_NoExceptions=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: [g++-4.9, cppcheck]
after_success:
- make clean
- CPPFLAGS="-DJSON_NOEXCEPTION" make check TEST_PATTERN="-e \"*\""
packages: ['g++-4.9', 'ninja-build']

# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)

Expand All @@ -91,7 +81,7 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ruby']
packages: ['g++-4.9', 'ruby', 'ninja-build']
before_script:
- wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
- tar xf lcov_1.11.orig.tar.gz
Expand Down Expand Up @@ -119,7 +109,7 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']
coverity_scan:
project:
name: "nlohmann/json"
Expand Down Expand Up @@ -163,31 +153,31 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-4.9
packages: ['g++-4.9', 'ninja-build']

- os: linux
compiler: gcc
env: COMPILER=g++-5
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-5
packages: ['g++-5', 'ninja-build']

- os: linux
compiler: gcc
env: COMPILER=g++-6
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-6
packages: ['g++-6', 'ninja-build']

- os: linux
compiler: gcc
env: COMPILER=g++-7
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-7
packages: ['g++-7', 'ninja-build']

- os: linux
compiler: gcc
Expand All @@ -197,7 +187,7 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-7
packages: ['g++-7', 'ninja-build']

# Linux / Clang

Expand All @@ -207,55 +197,55 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
packages: ['g++-6', 'clang-3.5']
packages: ['g++-6', 'clang-3.5', 'ninja-build']

- os: linux
compiler: clang
env: COMPILER=clang++-3.6
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']

- os: linux
compiler: clang
env: COMPILER=clang++-3.7
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
packages: ['g++-6', 'clang-3.7']
packages: ['g++-6', 'clang-3.7', 'ninja-build']

- os: linux
compiler: clang
env: COMPILER=clang++-3.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'clang-3.8']
packages: ['g++-6', 'clang-3.8', 'ninja-build']

- os: linux
compiler: clang
env: COMPILER=clang++-3.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'clang-3.9']
packages: ['g++-6', 'clang-3.9', 'ninja-build']

- os: linux
compiler: clang
env: COMPILER=clang++-4.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
packages: ['g++-6', 'clang-4.0']
packages: ['g++-6', 'clang-4.0', 'ninja-build']

- os: linux
compiler: clang
env: COMPILER=clang++-5.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0']
packages: ['g++-6', 'clang-5.0', 'ninja-build']

- os: linux
compiler: clang
Expand All @@ -265,7 +255,7 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0']
packages: ['g++-6', 'clang-5.0', 'ninja-build']

################
# build script #
Expand All @@ -274,9 +264,9 @@ matrix:
script:
# get CMake (only for systems with brew - macOS)
- |
if [[ !(-x $(which cmake)) && (-x $(which brew)) ]]; then
if [[ (-x $(which brew)) ]]; then
brew update
brew install cmake
brew install cmake ninja
cmake --version
fi

Expand All @@ -289,7 +279,7 @@ script:

# compile and execute unit tests
- mkdir -p build && cd build
- cmake .. && cmake --build . --config Release -- -j4
- cmake .. ${CMAKE_OPTIONS} -GNinja && cmake --build . --config Release
- ctest -C Release -V
- cd ..

Expand Down
10 changes: 3 additions & 7 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,10 @@ struct external_constructor<value_t::array>
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
static void construct(BasicJsonType& j, const std::valarray<T>& arr)
{
using std::begin;
using std::end;
j.m_type = value_t::array;
j.m_value = value_t::array;
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
j.m_value.array->resize(arr.size());
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
j.assert_invariant();
}
};
Expand Down Expand Up @@ -1190,10 +1189,7 @@ void from_json(const BasicJsonType& j, std::valarray<T>& l)
JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
}
l.resize(j.size());
for (size_t i = 0; i < j.size(); ++i)
{
l[i] = j[i];
}
std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l));
}

template<typename BasicJsonType, typename CompatibleArrayType>
Expand Down
Loading