Commit fcf3335d authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

Initial commit

parents
Pipeline #9334 passed with stage
in 46 seconds
image: debian:sid
variables:
GIT_SUBMODULE_STRATEGY: recursive
build:
stage: build
before_script:
- apt update && apt -y install cmake g++ ninja-build
script:
- mkdir build && cd build
- cmake -G Ninja ..
- ninja
- ninja install
- ctest -V
[submodule "external/ut"]
path = external/ut
url = https://github.com/boost-experimental/ut.git
[submodule "external/fmt"]
path = external/fmt
url = https://github.com/fmtlib/fmt.git
language: cpp
os:
- linux
- osx
branches:
only:
- master
- test
addons:
apt:
packages: &common_packages
- lcov
- cmake
- make
- gdb
env:
jobs:
- BOGUS_JOB=true
jobs:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
dist: xenial
env: CXX_COMPILER=g++-9 CXX_FLAGS=-std=c++2a
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *common_packages
- g++-9
- os: linux
env: CXX_COMPILER="clang++-9 -stdlib=libc++" CXX_FLAGS=-std=c++2a
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-9
packages:
- *common_packages
- clang-9
- libc++-9-dev
- os: osx
osx_image: xcode11.2
env: CXX_COMPILER=clang++ CXXSTD=c++2a
install:
- cd ..
- cd irritator
- mkdir build
- cd build
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then CXXFLAGS="$CXX_FLAGS" cmake -DCMAKE_CXX_COMPILER=$CXX_COMPILER -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COLOR_MAKEFILE=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug .. ; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then CXXFLAGS="$CXX_FLAGS" -g -O0 --coverage -fprofile-arcs -ftest-coverage" cmake -DCMAKE_CXX_COMPILER=$CXX_COMPILER -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COLOR_MAKEFILE=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None .. ; fi
script:
- make
- sudo make install
- ctest
after_success:
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then cd ${TRAVIS_BUILD_DIR} ; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then lcov --directory . --capture --output-file coverage.info ; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then lcov --remove coverage.info '/usr/*' --output-file coverage.info ; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then lcov --remove coverage.info 'external/*' --output-file coverage.info ; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then lcov --list coverage.info ; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then bash <(curl -s https://codecov.io/bash) ; fi
notifications:
email:
on_success: always
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(irritator VERSION 0.1.0 LANGUAGES CXX)
# Use the GNU standard installation directories. See
# https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html
include(GNUInstallDirs)
find_package(Threads REQUIRED)
add_library(threads INTERFACE IMPORTED)
set_property(TARGET threads PROPERTY
INTERFACE_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
add_definitions(-DFMT_HEADER_ONLY)
include_directories(${CMAKE_SOURCE_DIR}/external/fmt/include)
include_directories(${CMAKE_SOURCE_DIR}/external/ut/include)
enable_testing()
add_subdirectory(lib)
add_subdirectory(app)
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
= irritator news
== irritator v0.1.0 - 2020-xx-yy
= Irritator
Gauthier Quesnel <gauthier.quesnel@inrae.fr>
v0.1.0, 2020-xx-xx
:toc:
:homepage: https://github.com/quesnel/irritator/
[width="15%"]
|============
| https://travis-ci.org/quesnel/irritator[image:https://travis-ci.org/quesnel/irritator.png?branch=master[Build Status]] | https://ci.appveyor.com/project/quesnel/irritator?branch=master[image:https://ci.appveyor.com/api/projects/status/github/quesnel/irritator?branch=master&svg=true[Build Status]] | https://codecov.io/gh/quesnel/irritator[image:https://codecov.io/gh/quesnel/irritator/branch/irritator-0.5/graph/badge.svg[Coverage Status]]
|============
Copyright © 2020 http://www.inrae.fr/en[INRA]
The software is released under the https://www.boost.org/LICENSE_1_0.txt[Boost
license]. See the LICENSE file.
== Requirements and recommended
* `cmake` (≥ 3.11)
* $$C++$$ compiler with $$C++20$$ support:
** `gcc` ≥ 9 (https://www.gnu.org/software/gcc/projects/cxx-status.html[notes])
** `clang` ≥ 9 (https://clang.llvm.org/cxx_status.html[notes])
** `visual studio 2019 16.0` (https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes[notes])
For recent Debian GNU/Linux and Ubuntu derivatives (remove clang to
only use gcc):
[source,bash]
....
apt-get install build-essential cmake clang
....
== First installation
First, we clone Irritator git repository and the submodule.
....
git clone https://github.com/quesnel/irritator.git
cd irritator
git submodule update --init --recursive
....
== File format
Simple file
[source]
''''
4
A generator 2 0.0 100.0 0
B generator 2 0.0 100.0 0
Add adder 2 1.0 1.0 0
C counter 1 0.0 0
3
A 0 Add 0
B 0 Add 1
Add 0 C 0
''''
add_executable(app src/main.cpp)
target_link_libraries(app libirritator threads)
set_target_properties(app PROPERTIES
OUTPUT_NAME "irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
CXX_STANDARD 20)
target_compile_options(app
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
-pipe -march=native
$<$<CONFIG:Debug>:-Og -Wall -Wextra>>
$<$<CXX_COMPILER_ID:MSVC>:
/EHsc /bigobj
$<$<CONFIG:Debug>:/Od /W3 /Zi>>)
target_compile_definitions(app
PRIVATE
$<$<BOOL:${WITH_DEBUG}>:IRRITATOR_ENABLE_DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>
VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
VERSION_MINOR=${PROJECT_VERSION_MINOR}
VERSION_PATCH=${PROJECT_VERSION_PATCH}
VERSION_TWEAK=${PROJECT_VERSION_TWEAK})
install(TARGETS app
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
#include <fmt/format.h>
int
main()
{
return 0;
}
os: Visual Studio 2019
branches:
only:
- master
- test
- next
environment:
matrix:
- COMPILER: msvc
GENERATOR: Visual Studio 16 2019
PLATFORM: x64
BUILD_TYPE: Debug
- COMPILER: msvc
GENERATOR: Visual Studio 16 2019
PLATFORM: x64
BUILD_TYPE: Release
install:
- echo Installing %COMPILER% %PLATFORM% %BUILD_TYPE%
- git submodule -q update --init --recursive
- if defined BINDIR (set "PATH=%BINDIR%;%PATH%")
build_script:
- md build
- cd build
- cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%\irritator ..
- if "%COMPILER%"=="msvc" cmake --build . --config "%BUILD_TYPE%"
- if "%COMPILER%"=="msvc" cmake --build . --config "%BUILD_TYPE%" --target install
- if not "%COMPILER%"=="msvc" cmake --build .
- if not "%COMPILER%"=="msvc" cmake --build . --target install
- ctest --output-on-failure --verbose -C "%BUILD_TYPE%"
after_build:
- cmd: cd %APPVEYOR_BUILD_FOLDER%
- cmd: 7z a irritator-%COMPILER%-%PLATFORM%-%BUILD_TYPE%.zip irritator
artifacts:
- path: irritator-%COMPILER%-%PLATFORM%-%BUILD_TYPE%.zip
name: app
Subproject commit f94b7364b9409f05207c3af3fa4666730e11a854
Subproject commit 182d3520ec11608a36d5cb9565af0b370a9954f2
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(libirritator VERSION 0.1.0 LANGUAGES CXX)
option(WITH_DEBUG "enable maximium debug code. [default: ON]" ON)
set(public_irritator_header
include/irritator/core.hpp)
set(private_irritator_source
src/adder.cpp
src/counter.cpp
src/generator.cpp)
add_library(libirritator ${public_irritator_header} ${private_irritator_source})
option(BUILD_SHARED_LIBS "Build shared library" OFF)
include(GenerateExportHeader)
generate_export_header(libirritator
EXPORT_MACRO_NAME BX_EXPORT
NO_EXPORT_MACRO_NAME BX_NO_EXPORT
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/irritator/export)
target_compile_options(libirritator
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
-pipe -march=native
$<$<CONFIG:Debug>:-O0 -ggdb3 -Wall -Wextra>>
$<$<CXX_COMPILER_ID:MSVC>:
/EHsc /bigobj
$<$<CONFIG:Debug>:/std:c++latest /Od /W3 /Zi>>)
target_include_directories(libirritator PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/>)
target_link_libraries(libirritator
PRIVATE
threads)
set_target_properties(libirritator PROPERTIES
OUTPUT_NAME "irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
CXX_STANDARD 20)
target_compile_definitions(libirritator
PRIVATE
$<$<BOOL:${WITH_DEBUG}>:IRRITATOR_ENABLE_DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>
VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
VERSION_MINOR=${PROJECT_VERSION_MINOR}
VERSION_PATCH=${PROJECT_VERSION_PATCH})
install(TARGETS libirritator
EXPORT libirritator-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(IRRITATOR_DEPENDENCIES "")
configure_file(irritator.pc.in
"${CMAKE_BINARY_DIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.pc"
@ONLY)
install(FILES
${CMAKE_BINARY_DIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(DIRECTORY include/irritator
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/irritator/export
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/irritator-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}/irritator)
install(EXPORT libirritator-targets
FILE libirritator-targets.cmake
NAMESPACE libirritator::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/irritator-${VLE_ABI})
# This makes the project importable from the build directory
export(TARGETS libirritator FILE LibirritatorConfig.cmake)
function(irritator_add_test test_name)
add_executable(${test_name} ${ARGN})
set_target_properties(${test_name} PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/test\"
CXX_STANDARD 20)
target_compile_options(${test_name} BEFORE
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
-pipe -march=native
$<$<CONFIG:Debug>:-Og -Wall -Wextra>>
$<$<CXX_COMPILER_ID:MSVC>:
/EHsc /bigobj
$<$<CONFIG:Debug>:/Od /W3 /Zi>>)
target_compile_definitions(${test_name}
PRIVATE
$<$<BOOL:${WITH_DEBUG}>:IRRITATOR_ENABLE_DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>)
target_include_directories(${test_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
src
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(${test_name} libirritator threads)
add_test(${test_name} ${test_name})
endfunction()
if (NOT BUILD_SHARED_LIBS)
irritator_add_test(test-api test/public-api.cpp)
endif ()
This diff is collapsed.
prefix=@CMAKE_INSTALL_FULL_PREFIX@
exec_prefix=@CMAKE_INSTALL_FULL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: irritator
Description: A discrete event simulation tools
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
URL: http://www.vle-project.org/irritator
Requires: @IRRITATOR_DEPENDENCIES@
Cflags: -I${includedir}/irritator-@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@
Libs: -L${libdir} -lirritator-@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@
Libs.private:
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
namespace irt {} // namespace irritator
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
namespace irt {
class coupled
{
public:
};
} // namespace irt
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
namespace irt {
template<typename Time>
struct model_generator
{
output_port_id y[1];
Time sigma;
status initialize(simulation& /*sim*/)
{
sigma = 1;
return status::success;
}
status lambda(simulation& sim)
{
if (auto* port = sim.output_ports.try_to_get(y[0]); port)
port->messages.emplace_front(0.0);
return status::success;
}
};
} // namespace irt
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/core.hpp>
#include <boost/ut.hpp>
#include <fmt/format.h>
int
main()
{
using namespace boost::ut;
"model_constepxr"_test = [] {
expect(irt::is_detected_v<irt::initialize_function_t, irt::counter> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::counter> ==
false);
expect(irt::is_detected_v<irt::transition_function_t, irt::counter> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::counter> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::counter> == false);
expect(
irt::is_detected_v<irt::initialize_function_t, irt::generator> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::generator> ==
true);
expect(
irt::is_detected_v<irt::transition_function_t, irt::generator> ==
false);
expect(irt::is_detected_v<irt::has_input_port_t, irt::generator> == false);
expect(irt::is_detected_v<irt::has_output_port_t, irt::generator> == true);
expect(irt::is_detected_v<irt::initialize_function_t, irt::adder_2> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::adder_2> ==
true);
expect(irt::is_detected_v<irt::transition_function_t, irt::adder_2> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::adder_2> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::adder_2> == true);
expect(irt::is_detected_v<irt::initialize_function_t, irt::adder_3> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::adder_3> ==
true);
expect(irt::is_detected_v<irt::transition_function_t, irt::adder_3> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::adder_3> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::adder_3> == true);
expect(irt::is_detected_v<irt::initialize_function_t, irt::adder_4> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::adder_4> ==
true);
expect(irt::is_detected_v<irt::transition_function_t, irt::adder_4> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::adder_4> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::adder_4> == true);
expect(irt::is_detected_v<irt::initialize_function_t, irt::mult_2> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::mult_2> ==
true);
expect(irt::is_detected_v<irt::transition_function_t, irt::mult_2> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::mult_2> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::mult_2> == true);
expect(irt::is_detected_v<irt::initialize_function_t, irt::mult_3> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::mult_3> ==
true);
expect(irt::is_detected_v<irt::transition_function_t, irt::mult_3> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::mult_3> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::mult_3> == true);
expect(irt::is_detected_v<irt::initialize_function_t, irt::mult_4> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::mult_4> ==
true);
expect(irt::is_detected_v<irt::transition_function_t, irt::mult_4> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::mult_4> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::mult_4> == true);
expect(
irt::is_detected_v<irt::initialize_function_t, irt::integrator> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::integrator> ==
true);
expect(
irt::is_detected_v<irt::transition_function_t, irt::integrator> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::integrator> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::integrator> == true);
expect(
irt::is_detected_v<irt::initialize_function_t, irt::quantifier> ==
true);
expect(irt::is_detected_v<irt::lambda_function_t, irt::quantifier> ==
true);
expect(
irt::is_detected_v<irt::transition_function_t, irt::quantifier> ==
true);
expect(irt::is_detected_v<irt::has_input_port_t, irt::quantifier> == true);
expect(irt::is_detected_v<irt::has_output_port_t, irt::quantifier> == true);
};
"status"_test = [] {
irt::status s1 = irt::status::success;
expect(irt::is_success(s1) == true);
expect(irt::is_bad(s1) == false);
expect(irt::is_not_enough_memory(s1) == false);
irt::status s2 = irt::status::block_allocator_not_enough_memory;
expect(irt::is_success(s2) == false);
expect(irt::is_bad(s2) == true);
expect(irt::is_not_enough_memory(s2) == true);
};