To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 2871866b authored by Philipp Miedl's avatar Philipp Miedl

[v1.0.0] Publication MKT20c at DATE 2020

parent 62ac0024
---
BasedOnStyle: Google
IndentWidth: 2
ColumnLimit: 80
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: true
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
DerivePointerAlignment: false
PointerAlignment: Left
SortUsingDeclarations: true
---
# Compiled object files
*.slo
*.lo
*.o
*.obj
# Precompiled headers
*.qch
*.pch
# Compiled dynamic libraries
*.so
*.dylib
*.dll
# Compiled static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.out
build
# Scratch
scratch
# CMake
cmake-build*
*/cmake-build*
CMakeCache*
*/CMakeCache*
cmake_*
*/cmake_*
CMakeFiles
*/CMakeFiles
*.cbp
*/*.cbp
# IDE
compile_commands.json
*.sublime-*
# Makefiles
Makefile
*/Makefile
# Hidden files and directories
.*
*/.*
!.gitignore
!.gitmodules
[submodule "vendor/spdlog"]
path = vendor/spdlog
url = https://github.com/gabime/spdlog.git
[submodule "vendor/fmt"]
path = vendor/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "vendor/doctest"]
path = vendor/doctest
url = https://github.com/onqtam/doctest.git
[submodule "vendor/clipp"]
path = vendor/clipp
url = https://github.com/muellan/clipp.git
[submodule "vendor/json"]
path = vendor/json
url = https://github.com/nlohmann/json.git
[submodule "tools/docker"]
path = tools/docker
url = git@gitlab.ethz.ch:tec/public/exot/compilation.git
branch = master
This diff is collapsed.
Copyright (c) 2015-2020, Swiss Federal Institute of Technology (ETH Zurich)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This repository contains the application library used to build __benchmarking
tools__ and __covert channel applications__. The new library provides a core
framework making use of the *process networks* model of computation. The new
architecture defines a clearer structure for constructing covert channel
applications, and allows considerable degrees of reuse and extendability.
Additionally, the library features a breadth of utilities, which speed up the
development process, reduce code duplication, and improve the maintainability
of the codebase.
For further information and guildelines, please consult the wiki.
> __New__: The repository now contains a *tools* directory. You can find a new __containerised development environment__ there, additional information can be found in a new [README](tools/docker/README.md).
# How to use the library
This project uses [CMake](https://cmake.org/) as the build tool. It is
strongly encouraged that CMake is used for building all software based on the
library. The project's build configuration file defines a library target
called **exot**.
The library requires a number of third-party libraries:
[fmt](https://github.com/fmtlib/fmt) for string formatting,
[spdlog](https://github.com/gabime/spdlog) for logging,
[clipp](https://github.com/muellan/clipp) for command-line parsing, and
[doctest](https://github.com/onqtam/doctest) for testing. These are provided
as git submodules in the repository. To import them during cloning, run `git
clone --recursive <repo-url>`, to do that after the library has been imported,
make sure to run `git submodule update --init --recursive` to sync the
dependent repositories. To use the library at a specific tag or commit, git
submodules can also be utilised.
To use the library, include the repository in your project's path, and import
it in the project's CMakeLists.txt using `add_subdirectory`:
```cmake
cmake_minimum_required(VERSION 3.6)
project(project-that-uses-the-library VERSION 0.0.0 LANGUAGES CXX)
add_subdirectory(<path/to/library>)
# ...
target_link_libraries(<target/name> exot)
```
To successfully compile one needs:
- *CMake* ~> 3.6, preferably one that understands the C++17 standard (~> 3.8);
- a recent C++ standard library, conforming to the C++17 standard. This could be
the GNU libstdc++ from [GCC 7] and higher (libstdc++.so.6.0.23 and higher).
Please refer to the wiki for [futher guidelines];
- (optionally) *Boost* libraries, with *Boost/fiber* available,
enabled by passing -Dexot_use_fibers to the CMake command.
[GCC 7]: https://gcc.gnu.org/projects/cxx-status.html#cxx17
[futher guidelines]: https://gitlab.ethz.ch/tec/research/data_leakage_evaluation/app_lib/wikis/How-to-use-the-library%3F
The build process can be driven by *toolchain files*, which can wrap compiler,
linker, and other environment parameters and tasks necessary for building the
library and applications. If no *toolchain file* is provided, the build will
be performed with the system compiler, or the one defined with environment
variables `CC`/`CXX`. The repository contains, in
[cmake/toolchains](cmake/toolchains), a number of toolchains for dynamic and
static linkage, and for cross-compilation.
A number of build configurations are available: *Debug*, *Release*,
*RelWithDebInfo*. To configure the build with the desired configuration, run:
```bash
# Debug configuration, with symbols, static analysis, and no optimisation
cmake -DCMAKE_TOOLCHAIN_FILE=<path/to/toolchain> \
-DCMAKE_BUILD_TYPE=Debug -Bbuild/Debug -H.
# Release build, no symbols, no debug statements, high optimisation
cmake -DCMAKE_TOOLCHAIN_FILE=<path/to/toolchain> \
-DCMAKE_BUILD_TYPE=Release -Bbuild/Release -H.
```
Then, to compile specific targets, choose the build folder and run:
```bash
cmake --build build/Debug --target <target name> -- -j 0
```
To build and execute the library tests, run:
```bash
cmake --build <path/to/build> --target exot-test
./path/to/build/exot/exot-test
```
##
# @file add_fiber_dependency.cmake
# @author Bruno Klopott
# @brief Function to add a boost::fiber dependency to a cmake target.
#
# If EXOT_USE_FIBERS is set during CMake configuration step, link the
# appropriate library, provide include directories, and
# add a compile definition (equivalent to setting a preprocessor value)
# to the selected target.
function(add_fiber_dependency target)
if(${exot_use_fibers})
find_package(Boost 1.67 COMPONENTS fiber REQUIRED)
target_link_libraries(${target} PUBLIC Boost::fiber)
target_include_directories(${target} PUBLIC Boost::fiber)
target_compile_definitions(${target} PUBLIC "EXOT_USE_FIBERS")
endif(${exot_use_fibers})
endfunction()
##
# @file clone_target.cmake
# @author Bruno Klopott
# @brief Function to clone a target 'as completely as possible'.
#
# list of possible target properties, filtered for read-only and
# incompatible ones.
set(POSSIBLE_TARGET_PROPERTIES
"ALIASED_TARGET"
"ANDROID_ANT_ADDITIONAL_OPTIONS"
"ANDROID_API"
"ANDROID_API_MIN"
"ANDROID_ARCH"
"ANDROID_ASSETS_DIRECTORIES"
"ANDROID_GUI"
"ANDROID_JAR_DEPENDENCIES"
"ANDROID_JAR_DIRECTORIES"
"ANDROID_JAVA_SOURCE_DIR"
"ANDROID_NATIVE_LIB_DEPENDENCIES"
"ANDROID_NATIVE_LIB_DIRECTORIES"
"ANDROID_PROCESS_MAX"
"ANDROID_PROGUARD"
"ANDROID_PROGUARD_CONFIG_PATH"
"ANDROID_SECURE_PROPS_PATH"
"ANDROID_SKIP_ANT_STEP"
"ANDROID_STL_TYPE"
"ARCHIVE_OUTPUT_DIRECTORY_DEBUG"
"ARCHIVE_OUTPUT_DIRECTORY_RELEASE"
"ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO"
"ARCHIVE_OUTPUT_DIRECTORY"
"ARCHIVE_OUTPUT_NAME_DEBUG"
"ARCHIVE_OUTPUT_NAME_RELEASE"
"ARCHIVE_OUTPUT_NAME_RELWITHDEBINFO"
"ARCHIVE_OUTPUT_NAME"
"AUTOGEN_BUILD_DIR"
"AUTOGEN_PARALLEL"
"AUTOGEN_TARGET_DEPENDS"
"AUTOMOC_COMPILER_PREDEFINES"
"AUTOMOC_DEPEND_FILTERS"
"AUTOMOC_MACRO_NAMES"
"AUTOMOC_MOC_OPTIONS"
"AUTOMOC"
"AUTOUIC"
"AUTOUIC_OPTIONS"
"AUTOUIC_SEARCH_PATHS"
"AUTORCC"
"AUTORCC_OPTIONS"
"BINARY_DIR"
"BUILD_RPATH"
"BUILD_WITH_INSTALL_NAME_DIR"
"BUILD_WITH_INSTALL_RPATH"
"BUNDLE_EXTENSION"
"BUNDLE"
"C_EXTENSIONS"
"C_STANDARD"
"C_STANDARD_REQUIRED"
"COMMON_LANGUAGE_RUNTIME"
"COMPATIBLE_INTERFACE_BOOL"
"COMPATIBLE_INTERFACE_NUMBER_MAX"
"COMPATIBLE_INTERFACE_NUMBER_MIN"
"COMPATIBLE_INTERFACE_STRING"
"COMPILE_DEFINITIONS"
"COMPILE_FEATURES"
"COMPILE_FLAGS"
"COMPILE_OPTIONS"
"COMPILE_PDB_NAME"
"COMPILE_PDB_NAME_DEBUG"
"COMPILE_PDB_NAME_RELEASE"
"COMPILE_PDB_NAME_RELWITHDEBINFO"
"COMPILE_PDB_OUTPUT_DIRECTORY"
"COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG"
"COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE"
"COMPILE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO"
"CROSSCOMPILING_EMULATOR"
"CUDA_SEPARABLE_COMPILATION"
"CUDA_RESOLVE_DEVICE_SYMBOLS"
"CUDA_EXTENSIONS"
"CUDA_STANDARD"
"CUDA_STANDARD_REQUIRED"
"CXX_EXTENSIONS"
"CXX_STANDARD"
"CXX_STANDARD_REQUIRED"
"DEBUG_POSTFIX"
"DEFINE_SYMBOL"
"DEPLOYMENT_REMOTE_DIRECTORY"
"DOTNET_TARGET_FRAMEWORK_VERSION"
"EchoString"
"ENABLE_EXPORTS"
"ENABLED_SANITIZERS"
"EXCLUDE_FROM_ALL"
"EXCLUDE_FROM_DEFAULT_BUILD_DEBUG"
"EXCLUDE_FROM_DEFAULT_BUILD_RELEASE"
"EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO"
"EXCLUDE_FROM_DEFAULT_BUILD"
"EXPORT_NAME"
"EXPORT_PROPERTIES"
"FOLDER"
"Fortran_FORMAT"
"Fortran_MODULE_DIRECTORY"
"FRAMEWORK"
"FRAMEWORK_VERSION"
"GENERATOR_FILE_NAME"
"GNUtoMS"
"HAS_CXX"
"IMPLICIT_DEPENDS_INCLUDE_TRANSFORM"
"IMPORT_PREFIX"
"IMPORT_SUFFIX"
"INCLUDE_DIRECTORIES"
"INSTALL_NAME_DIR"
"INSTALL_RPATH"
"INSTALL_RPATH_USE_LINK_PATH"
"INTERPROCEDURAL_OPTIMIZATION_DEBUG"
"INTERPROCEDURAL_OPTIMIZATION_RELEASE"
"INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO"
"INTERPROCEDURAL_OPTIMIZATION"
"IOS_INSTALL_COMBINED"
"JOB_POOL_COMPILE"
"JOB_POOL_LINK"
"LABELS"
"C_CLANG_TIDY"
"CXX_CLANG_TIDY"
"C_COMPILER_LAUNCHER"
"CXX_COMPILER_LAUNCHER"
"C_CPPCHECK"
"CXX_CPPCHECK"
"C_CPPLINT"
"CXX_CPPLINT"
"C_INCLUDE_WHAT_YOU_USE"
"CXX_INCLUDE_WHAT_YOU_USE"
"C_VISIBILITY_PRESET"
"CXX_VISIBILITY_PRESET"
"LIBRARY_OUTPUT_DIRECTORY_DEBUG"
"LIBRARY_OUTPUT_DIRECTORY_RELEASE"
"LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO"
"LIBRARY_OUTPUT_DIRECTORY"
"LIBRARY_OUTPUT_NAME_DEBUG"
"LIBRARY_OUTPUT_NAME_RELEASE"
"LIBRARY_OUTPUT_NAME_RELWITHDEBINFO"
"LIBRARY_OUTPUT_NAME"
"LINK_DEPENDS_NO_SHARED"
"LINK_DEPENDS"
"LINKER_LANGUAGE"
"LINK_FLAGS_DEBUG"
"LINK_FLAGS_RELEASE"
"LINK_FLAGS_RELWITHDEBINFO"
"LINK_FLAGS"
"LINK_INTERFACE_LIBRARIES_DEBUG"
"LINK_INTERFACE_LIBRARIES_RELEASE"
"LINK_INTERFACE_LIBRARIES_RELWITHDEBINFO"
"LINK_INTERFACE_LIBRARIES"
"LINK_INTERFACE_MULTIPLICITY_DEBUG"
"LINK_INTERFACE_MULTIPLICITY_RELEASE"
"LINK_INTERFACE_MULTIPLICITY_RELWITHDEBINFO"
"LINK_INTERFACE_MULTIPLICITY"
"LINK_LIBRARIES"
"LINK_SEARCH_END_STATIC"
"LINK_SEARCH_START_STATIC"
"LINK_WHAT_YOU_USE"
"MACOSX_BUNDLE_INFO_PLIST"
"MACOSX_BUNDLE"
"MACOSX_FRAMEWORK_INFO_PLIST"
"MACOSX_RPATH"
"MAP_IMPORTED_CONFIG_DEBUG"
"MAP_IMPORTED_CONFIG_RELEASE"
"MAP_IMPORTED_CONFIG_RELWITHDEBINFO"
"NO_SONAME"
"NO_SYSTEM_FROM_IMPORTED"
"OSX_ARCHITECTURES_DEBUG"
"OSX_ARCHITECTURES_RELEASE"
"OSX_ARCHITECTURES_RELWITHDEBINFO"
"OSX_ARCHITECTURES"
"OUTPUT_NAME_DEBUG"
"OUTPUT_NAME_RELEASE"
"OUTPUT_NAME_RELWITHDEBINFO"
"OUTPUT_NAME"
"PDB_NAME_DEBUG"
"PDB_NAME_RELEASE"
"PDB_NAME_RELWITHDEBINFO"
"PDB_NAME"
"PDB_OUTPUT_DIRECTORY_DEBUG"
"PDB_OUTPUT_DIRECTORY_RELEASE"
"PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO"
"PDB_OUTPUT_DIRECTORY"
"POSITION_INDEPENDENT_CODE"
"PREFIX"
"PRIVATE_HEADER"
"PROJECT_LABEL"
"PUBLIC_HEADER"
"RESOURCE"
"RULE_LAUNCH_COMPILE"
"RULE_LAUNCH_CUSTOM"
"RULE_LAUNCH_LINK"
"RUNTIME_OUTPUT_DIRECTORY_DEBUG"
"RUNTIME_OUTPUT_DIRECTORY_RELEASE"
"RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO"
"RUNTIME_OUTPUT_DIRECTORY"
"RUNTIME_OUTPUT_NAME_DEBUG"
"RUNTIME_OUTPUT_NAME_RELEASE"
"RUNTIME_OUTPUT_NAME_RELWITHDEBINFO"
"RUNTIME_OUTPUT_NAME"
"SKIP_BUILD_RPATH"
"SOURCE_DIR"
"SOURCES"
"SOVERSION"
"STATIC_LIBRARY_FLAGS_DEBUG"
"STATIC_LIBRARY_FLAGS_RELEASE"
"STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"
"STATIC_LIBRARY_FLAGS"
"SUFFIX"
"VERSION")
# Creates a new target of same type and copies all possible properties
function (clone_target target new-target)
get_target_property(__type ${target} "TYPE")
if (__type STREQUAL "EXECUTABLE")
add_executable(${new-target} "")
elseif (__type STREQUAL "STATIC_LIBRARY")
add_library(${new-target} STATIC "")
elseif (__type STREQUAL "SHARED_LIBRARY")
add_library(${new-target} SHARED "")
else()
# TODO: Unsure how to dermine whether a property is only meant
# for, e.g., iterface libraries.
message(WARNING "target type ${__type} is not supported!")
return()
endif()
message(STATUS "Created a new target of type ${__type}")
message(STATUS "Copying target properties from ${target} to ${new-target}")
# Copy target properties to the newly created target
foreach(property ${POSSIBLE_TARGET_PROPERTIES})
get_target_property(__property ${target} ${property})
if(__property)
set_target_properties(${new-target} PROPERTIES "${property}" "${__property}")
message(STATUS "Set property ${property} to ${__property}")
endif()
endforeach(property)
endfunction()
##
# @file colour_message.cmake
# @author Bruno Klopott
# @brief Function to print a coloured message to the console
#
string(ASCII 27 Escape)
set(Reset "${Escape}[m")
set(Bold "${Escape}[1m")
set(Red "${Escape}[31m")
set(Green "${Escape}[32m")
set(Yellow "${Escape}[33m")
set(Blue "${Escape}[34m")
set(Magenta "${Escape}[35m")
set(Cyan "${Escape}[36m")
set(White "${Escape}[37m")
function(colour_message)
list(GET ARGV 0 message_type)
list(GET ARGV 1 colour)
list(GET ARGV 2 bold)
if (${bold} STREQUAL BOLD)
set(use_bold ON)
list(REMOVE_AT ARGV 2)
endif ()
list(REMOVE_AT ARGV 1)
list(REMOVE_AT ARGV 0)
if (${colour} STREQUAL RED)
if (${use_bold})
set(modifier "${Bold}${Red}")
else ()
set(modifier "${Red}")
endif ()
elseif (${colour} STREQUAL GREEN)
if (${use_bold})
set(modifier "${Bold}${Green}")
else ()
set(modifier "${Green}")
endif ()
elseif (${colour} STREQUAL YELLOW)
if (${use_bold})
set(modifier "${Bold}${Yellow}")
else ()
set(modifier "${Yellow}")
endif ()
elseif (${colour} STREQUAL BLUE)
if (${use_bold})
set(modifier "${Bold}${Blue}")
else ()
set(modifier "${Blue}")
endif ()
elseif (${colour} STREQUAL MAGENTA)
if (${use_bold})
set(modifier "${Bold}${Magenta}")
else ()
set(modifier "${Magenta}")
endif ()
elseif (${colour} STREQUAL CYAN)
if (${use_bold})
set(modifier "${Bold}${Cyan}")
else ()
set(modifier "${Cyan}")
endif ()
elseif (${colour} STREQUAL WHITE)
if (${use_bold})
set(modifier "${Bold}${White}")
else ()
set(modifier "${White}")
endif ()
else (${colour})
if (${use_bold})
set(modifier "${Bold}")
else ()
set(modifier "")
endif ()
endif ()
message(${message_type} "${modifier}${ARGV}${Reset}")
endfunction()
##
# @file configure_clang_format.cmake
# @author Bruno Klopott
# @brief Function that bootstraps clang-format utility.
#
function(configure_clang_format enable target)
if(${enable})
find_program(CLANG_FORMAT NAMES
"clang-format" "clang-format-6.0" "clang-format-7.0"
"/usr/local/opt/llvm/bin/clang-format")
if(CLANG_FORMAT)
message(STATUS "Found clang-format binary: " ${CLANG_FORMAT})
get_target_property(target_sources ${target} SOURCES)
get_target_property(target_name ${target} NAME)
add_custom_target(
format-${target_name}
COMMAND ${CLANG_FORMAT}
-i
-style=Google
${target_sources}
)
endif()
endif()
endfunction()
##
# @file configure_clang_tidy.cmake
# @author Bruno Klopott
# @brief Function that bootstraps the clang-tidy static analyser.
#
include(colour_message)