Skip to content

Commit 699c207

Browse files
authored
Inja v2 (#67)
* inja2 * header only * reduce dependencies * code cleaning * c++17 * use stdc++ * code cleaning * infrastructure * header only * add infrastructure * fix tests * use minimum clang 6 * code cleaning, polyfill for c++11 * fix some file tests * fix readme * update appveyor * fix polyfill and ci * fix polyfill * fix ci? * test msvc __cplusplus * add doxygen * activate all tests * code cleaning * add coveralls, set default to dot notation * add html test * add doxygen comments * test single_include file * change build folder in appveyor * correct make arguments in appveyor * fix appveyor arguments
1 parent d90f93f commit 699c207

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7417
-3519
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ dist
4040
.coveralls.yml
4141

4242
.vscode
43+
44+
doc/html
45+
doc/latex

.travis.yml

+21-68
Original file line numberDiff line numberDiff line change
@@ -9,103 +9,56 @@ sudo: required
99

1010
matrix:
1111
include:
12-
### Coveralls ###
13-
- os: linux
14-
compiler: gcc
15-
env: COMPILER=g++-5
16-
addons:
17-
apt:
18-
sources: ['ubuntu-toolchain-r-test']
19-
packages: g++-5
20-
before_install:
21-
- pip install --user cpp-coveralls
22-
after_success:
23-
- make clean
24-
# - coveralls --exclude lib --exclude tests --gcov-options '\-lp'
25-
26-
- os: linux
27-
compiler: gcc
28-
env: COMPILER=g++-4.9
29-
addons:
30-
apt:
31-
sources: ['ubuntu-toolchain-r-test']
32-
packages: g++-4.9
33-
34-
- os: linux
35-
compiler: gcc
36-
env: COMPILER=g++-5
37-
addons:
38-
apt:
39-
sources: ['ubuntu-toolchain-r-test']
40-
packages: g++-5
41-
42-
- os: linux
43-
compiler: gcc
44-
env: COMPILER=g++-6
45-
addons:
46-
apt:
47-
sources: ['ubuntu-toolchain-r-test']
48-
packages: g++-6
49-
5012
- os: linux
5113
compiler: gcc
5214
env: COMPILER=g++-7
5315
addons:
5416
apt:
55-
sources: ['ubuntu-toolchain-r-test']
17+
sources: ubuntu-toolchain-r-test
5618
packages: g++-7
5719

5820
- os: linux
59-
compiler: clang
60-
env: COMPILER=clang++-3.6
61-
addons:
62-
apt:
63-
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
64-
packages: clang-3.6
65-
66-
- os: linux
67-
compiler: clang
68-
env: COMPILER=clang++-3.7
21+
compiler: gcc
22+
env:
23+
- COMPILER=g++-8
6924
addons:
7025
apt:
71-
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
72-
packages: clang-3.7
26+
sources: ubuntu-toolchain-r-test
27+
packages: g++-8
7328

7429
- os: linux
75-
compiler: clang
76-
env: COMPILER=clang++-4.0
30+
compiler: gcc
31+
env:
32+
- COMPILER=g++-8
33+
- CXXFLAGS=-std=c++17
7734
addons:
7835
apt:
79-
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
80-
packages: ['g++-6', 'clang-4.0']
36+
sources: ubuntu-toolchain-r-test
37+
packages: g++-8
8138

8239
- os: linux
8340
compiler: clang
84-
env: COMPILER=clang++-5.0
41+
env: COMPILER=clang++-6.0
8542
addons:
8643
apt:
87-
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
88-
packages: ['g++-6', 'clang-5.0']
89-
90-
- os: osx
91-
osx_image: xcode7.3
44+
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0']
45+
packages: ['clang-6.0', 'libstdc++-7-dev']
9246

9347
- os: osx
94-
osx_image: xcode8
95-
96-
- os: osx
97-
osx_image: xcode8.3
48+
osx_image: xcode9
9849

9950
- os: osx
100-
osx_image: xcode9
51+
osx_image: xcode10
10152

10253

10354
script:
10455
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
10556
- uname -a
10657
- $CXX --version
10758

108-
- mkdir -p build && cd build
109-
- cmake .. && cmake --build . --config Release -- -j4
59+
- mkdir -p build
60+
- cd build
61+
- cmake ..
62+
- cmake --build . --config Release -- -j4
11063
- ctest -C Release -V
11164
- cd ..

CMakeLists.txt

+49-117
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,69 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.5)
22

33

4-
##
5-
## PROJECT
6-
##
7-
project(inja LANGUAGES CXX VERSION 1.0.1)
8-
set(INJA_VERSION ${PROJECT_VERSION})
4+
project(inja LANGUAGES CXX VERSION 2.0.0)
95

106

11-
##
12-
## OPTIONS
13-
##
14-
option(BUILD_UNIT_TESTS "Build the unit tests" ON)
15-
option(BUILD_BENCHMARK "Build the inja benchmark" OFF)
16-
option(HUNTER_ENABLED "Use hunter to manage dependencies" OFF)
7+
option(BUILD_TESTS "Build the inja unit tests" ON)
8+
option(BUILD_BENCHMARK "Build the inja benchmark" ON)
9+
option(COVERALLS "Generate coveralls data" OFF)
1710

1811

19-
##
20-
## HUNTER
21-
##
22-
if(HUNTER_ENABLED)
23-
include("cmake/HunterGate.cmake")
24-
HunterGate(
25-
URL "https://github.com/ruslo/hunter/archive/v0.19.156.tar.gz"
26-
SHA1 "8d5e4635b137365e0d1ade4d60accf4e2bb41f0d"
27-
)
28-
endif()
12+
set(CMAKE_CXX_STANDARD 17)
13+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
14+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
15+
set(CMAKE_BUILD_TYPE Debug)
16+
# set(CMAKE_BUILD_TYPE Release)
17+
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
2918

3019

31-
##
32-
## CONFIGURATION
33-
##
34-
set(CMAKE_CXX_STANDARD 11)
35-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
36-
set(INJA_INCLUDE_DIR include)
37-
set(INJA_SINGLE_INCLUDE_DIR single_include)
38-
set(INJA_HEADER_INSTALL_DIR include)
20+
add_library(inja INTERFACE)
21+
target_include_directories(inja INTERFACE include)
22+
23+
24+
execute_process(COMMAND python3 amalgamate/amalgamate.py -c amalgamate/config.json -s include WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
25+
26+
27+
if (COVERALLS)
28+
include(Coveralls)
29+
coveralls_turn_on_coverage()
3930

40-
if(WIN32 AND MSVC AND MSVC_VERSION LESS 1900)
41-
message(FATAL_ERROR "[${PROJECT_NAME}] Visual Studio versions prior to 2015 do not support the noexcept keyword, which is used in the JSON library.")
31+
file(GLOB_RECURSE COVERAGE_SRCS include/inja/*.hpp)
32+
33+
# set(COVERAGE_SRCS test/unit.cpp test/unit-renderer.cpp include/inja)
34+
35+
coveralls_setup("${COVERAGE_SRCS}" OFF) # If we should upload.
4236
endif()
4337

4438

45-
##
46-
## TESTS
47-
## create and configure the unit test target
48-
##
49-
if(BUILD_UNIT_TESTS)
39+
if(BUILD_TESTS)
5040
enable_testing()
51-
add_subdirectory(test)
52-
endif()
5341

42+
add_executable(inja_test
43+
test/unit.cpp
44+
test/unit-files.cpp
45+
test/unit-renderer.cpp
46+
)
47+
target_link_libraries(inja_test PRIVATE inja)
5448

55-
##
56-
## AMALGAMATE
57-
## amalgamate header files into single_include
58-
##
59-
execute_process(COMMAND python3 amalgamate/amalgamate.py -c amalgamate/config.json -s include
60-
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
49+
add_test(inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/inja_test)
6150

6251

63-
##
64-
## TARGETS
65-
## Build targets for the interface library
66-
##
67-
add_library(inja INTERFACE)
68-
target_include_directories(inja INTERFACE
69-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INJA_INCLUDE_DIR}>
70-
$<INSTALL_INTERFACE:${INJA_HEADER_INSTALL_DIR}>
71-
)
72-
73-
74-
add_library(inja_single INTERFACE)
75-
target_include_directories(inja_single INTERFACE
76-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INJA_SINGLE_INCLUDE_DIR}>
77-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INJA_INCLUDE_DIR}>
78-
$<INSTALL_INTERFACE:${INJA_HEADER_INSTALL_DIR}>
79-
)
80-
81-
82-
if(HUNTER_ENABLED) # Use Hunter to manage dependencies
83-
# Add JSON package
84-
hunter_add_package(nlohmann_json)
85-
find_package(nlohmann_json CONFIG REQUIRED)
86-
# Add dependencies to target
87-
target_link_libraries(inja INTERFACE nlohmann_json)
52+
add_library(single_inja INTERFACE)
53+
target_include_directories(single_inja INTERFACE single_include include)
54+
55+
add_executable(single_inja_test
56+
test/unit.cpp
57+
test/unit-files.cpp
58+
test/unit-renderer.cpp
59+
)
60+
target_link_libraries(single_inja_test PRIVATE single_inja)
61+
62+
add_test(single_inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/single_inja_test)
8863
endif()
8964

9065

91-
##
92-
## INSTALL
93-
## install header files, generate and install cmake config files for find_package()
94-
##
95-
set(include_install_dir ${INJA_HEADER_INSTALL_DIR})
96-
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
97-
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
98-
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
99-
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
100-
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
101-
set(namespace "${PROJECT_NAME}::")
102-
include(CMakePackageConfigHelpers)
103-
104-
105-
write_basic_package_version_file(
106-
"${version_config}" COMPATIBILITY SameMajorVersion
107-
)
108-
configure_package_config_file(
109-
"cmake/Config.cmake.in"
110-
"${project_config}"
111-
INSTALL_DESTINATION "${config_install_dir}"
112-
)
113-
114-
install(
115-
TARGETS inja
116-
EXPORT "${TARGETS_EXPORT_NAME}"
117-
LIBRARY DESTINATION "lib"
118-
ARCHIVE DESTINATION "lib"
119-
RUNTIME DESTINATION "bin"
120-
INCLUDES DESTINATION "${include_install_dir}"
121-
)
122-
123-
install(
124-
FILES ${INJA_INCLUDE_DIR}/inja.hpp
125-
DESTINATION "${include_install_dir}"
126-
)
127-
128-
install(
129-
FILES "${project_config}" "${version_config}"
130-
DESTINATION "${config_install_dir}"
131-
)
132-
133-
install(
134-
EXPORT "${TARGETS_EXPORT_NAME}"
135-
NAMESPACE "${namespace}"
136-
DESTINATION "${config_install_dir}"
137-
)
66+
if(BUILD_BENCHMARK)
67+
add_executable(inja_benchmark test/benchmark.cpp)
68+
target_link_libraries(inja_benchmark PRIVATE inja)
69+
endif()

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,32 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22+
23+
24+
---
25+
26+
27+
Copyright (c) 2009-2018 FIRST
28+
All rights reserved.
29+
30+
Redistribution and use in source and binary forms, with or without
31+
modification, are permitted provided that the following conditions are met:
32+
* Redistributions of source code must retain the above copyright
33+
notice, this list of conditions and the following disclaimer.
34+
* Redistributions in binary form must reproduce the above copyright
35+
notice, this list of conditions and the following disclaimer in the
36+
documentation and/or other materials provided with the distribution.
37+
* Neither the name of the FIRST nor the
38+
names of its contributors may be used to endorse or promote products
39+
derived from this software without specific prior written permission.
40+
41+
THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY
42+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43+
WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
44+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
45+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)