Skip to content

Commit

Permalink
tooling: Make cloe a super-build of all packages
Browse files Browse the repository at this point in the history
New:
- Add `cloe-meta` package to replace previous role of `cloe`.

- Add `cloe-plugins-core` package recipe (but do not build).

- Add editable builds to GitHub workflow `build-cloe` matrix.

Changed:
- Package `cloe` provides all Cloe packages compiled in one go.
  This is a boon to development, as we make `cloe` editable and
  only have to work with a single package.
  It also massively speeds up compilation:
  - Conan and CMake configuration is only performed once.
  - All cores can now be utilized much more effectively during the build
    process.

- Do not aggressively lint everything
  The developer can do this themselves by setting a cmake define:
  https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CLANG_TIDY.html

- Move all individual tests into single project tests
  Still support multiple profiles, but this makes it easier
  to support the cloe super-build and should also make it
  easier to develop and maintain tests.

- Renamed top-level Make targets:
  - `status` is now `status-all`
  - `export` is now `export-all`
  - `deploy` is now `deploy-all`
  - `clean` is now `clean-all`
  - `purge` is now `purge-all`

- The following top-level Make targets just refer to `cloe` super-build package:
  - `package`
  - `smoketest`
  - `smoketest-deps`
  - `status`
  - `export`

Fixed:
- Plugin Conan configurations do not export correct library path.

Removed:
- Work-In-Progress Lua files.
cassava committed Dec 4, 2023
1 parent 7e95d49 commit bb50a5e
Showing 133 changed files with 990 additions and 1,191 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/build-cloe.yaml
Original file line number Diff line number Diff line change
@@ -28,9 +28,20 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
build_type: [RelWithDebInfo]
package_target: [package]
os:
- "ubuntu-20.04"
- "ubuntu-22.04"
conan_profile:
- "cloe-normal"
package_target:
# 1. Build each test configuration in Conan cache and run all tests
- "export-all smoketest-deps smoketest"

# 2. Build cloe super-package in editable mode and run tests
- "editable all smoketest TEST_CONANFILES=tests/conanfile_all.py"

# 3. Build individual packages in editable mode and run tests
- "editable-select build-all smoketest TEST_CONANFILES=tests/conanfile_split.py"
env:
CONAN_NON_INTERACTIVE: "yes"
DEBIAN_FRONTEND: noninteractive
@@ -59,12 +70,9 @@ jobs:
- name: Configure Conan
run: |
make setup-conan
- name: Build cloe w/ package
conan config set general.default_profile=${{ matrix.conan_profile }}
conan config set general.default_build_profile=${{ matrix.conan_profile }}
make export-cli
- name: Build cloe
run: |
make ${{ matrix.package_target }}
- name: Build smoketest dependencies
run: |
make smoketest-deps
- name: Run smoketests
run: |
make smoketest
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This CMakeLists.txt configures a super-build containing everything
# from this repo.
#
# It is currently experimental.
#

cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe LANGUAGES CXX)

set(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/runtime/cmake")

# Since a super-build does not export packages individually via Conan,
# we cannot depend on Conan-generated CMake config files, instead we
# use the CMake targets directly as if they were already found.
set(CLOE_FIND_PACKAGES OFF CACHE BOOL "Call find_package() for cloe packages" FORCE)

# Ensure output goes to one place so cloe-launch can find the plugins
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)

# Ensure we can test from this level.
include(CTest)

add_subdirectory(fable)
add_subdirectory(runtime)
add_subdirectory(models)
add_subdirectory(oak)
add_subdirectory(engine)
add_subdirectory(plugins)
118 changes: 75 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -3,6 +3,11 @@
# This file contains Makefile targets for the cloe project.
#

# Make configuration:
SHELL := /bin/bash
GNUMAKEFLAGS := --no-print-directory
SUBMAKEFLAGS :=

CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch

@@ -20,78 +25,96 @@ AG := $(or \

# Build configuration:
BUILD_DIR := build
LOCKFILE_SOURCE := conanfile.py
BUILD_LOCKFILE := ${BUILD_DIR}/conan.lock
LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${BUILD_LOCKFILE}"
INSTALL_DIR := /usr/local
CONAN_OPTIONS :=

# Lockfile for cloe-meta:
META_LOCKFILE_SOURCE := meta/conanfile.py
META_BUILD_LOCKFILE := meta/build/conan.lock
META_LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${META_BUILD_LOCKFILE}"

.DEFAULT_GOAL := help
.PHONY: help
.SILENT: help
help::
$(call print_help_usage)
echo
$(call print_help_section, "Default target")
$(call print_help_target, help, "show this help on available targets")
echo

# Setup targets ---------------------------------------------------------------
include Makefile.setup

${META_BUILD_LOCKFILE}:
${MAKE} -C meta LOCKFILE_SOURCE=conanfile.py lockfile

.PHONY: lockfile
lockfile: ${META_BUILD_LOCKFILE}

# Workspace targets -----------------------------------------------------------
help::
$(call print_help_section, "Available workspace targets")
$(call print_help_target, status, "show status of each of the Conan packages")
$(call print_help_target, smoketest-deps, "build system test pre-requisites")
$(call print_help_target, smoketest, "run system tests")
$(call print_help_target, docs, "generate documentation")
$(call print_help_target, deploy, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]")
$(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}")
$(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe")
$(call print_help_target, docs, "generate Doxygen and Sphinx documentation")
echo

${BUILD_LOCKFILE}:
${MAKE} -f Makefile.package SOURCE_CONANFILE=/dev/null LOCKFILE_SOURCE=${LOCKFILE_SOURCE} ${BUILD_LOCKFILE}

.PHONY: lockfile
lockfile: ${BUILD_LOCKFILE}
.PHONY: docs
docs:
$(call print_header, "Generating Doxygen documentation...")
${MAKE} -C docs doxygen
$(call print_header, "Generating Sphinx documentation...")
${MAKE} -C docs html

.PHONY: status
status: ${BUILD_LOCKFILE}
@for pkg in ${ALL_PKGS}; do \
[ -d $${pkg} ] || continue; \
${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${LOCKFILE_OPTION} -C $${pkg} status || true; \
done
help::
$(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe")
$(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}")
echo

.PHONY: deploy
deploy:
$(call print_header, "Deploying binaries to ${INSTALL_DIR}...")
conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy .
mkdir -p ${INSTALL_DIR}
cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/
.PHONY: export-cli
export-cli:
${MAKE} -C cli export

.PHONY: deploy-cli
deploy-cli:
$(call print_header, "Deploying cloe-launch binary with pip...")
${MAKE} -C cli install

.PHONY: export-cli
export-cli:
${MAKE} -C cli export
help::
$(call print_help_target, lockfile, "create a lockfile for cloe-meta package")
$(call print_help_target, status-all, "show status of each of the Conan packages")
$(call print_help_target, export-all, "export all package sources to Conan cache")
$(call print_help_target, build-all, "build individual packages locally in-source")
$(call print_help_target, deploy-all, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]")
$(call print_help_target, clean-all, "clean entire repository of temporary files")
$(call print_help_target, purge-all, "remove all cloe packages (in any version) from Conan cache")
echo

export: export-cli
package: export-cli
.PHONY: build-all
build-all: lockfile
${MAKE} all-select UNSELECT_PKGS="meta" CONAN_OPTIONS="${CONAN_OPTIONS} ${META_LOCKFILE_OPTION}"

.PHONY: docs
docs:
$(call print_header, "Generating Doxygen documentation...")
${MAKE} -C docs doxygen
$(call print_header, "Generating Sphinx documentation...")
${MAKE} -C docs html
.PHONY: status-all
status-all: ${META_BUILD_LOCKFILE}
@for pkg in ${ALL_PKGS}; do \
[ -d $${pkg} ] || continue; \
${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${META_LOCKFILE_OPTION} -C $${pkg} status || true; \
done

.PHONY: smoketest-deps
smoketest-deps: export-cli smoketest-deps-select
.PHONY: export-all
export-all:
$(call print_header, "Exporting all cloe Conan packages...")
${MAKE} export-select export-cli export

.PHONY: smoketest
smoketest: smoketest-select
.PHONY: deploy-all
deploy-all:
$(call print_header, "Deploying binaries to ${INSTALL_DIR}...")
conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy .
mkdir -p ${INSTALL_DIR}
cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/

.PHONY: clean-all
clean-all:
${MAKE} clean clean-select

.PHONY: purge-all
purge-all:
@@ -122,6 +145,8 @@ todos:
${AG} FIXME
${AG} XXX

# Hidden development targets --------------------------------------------------

.PHONY: grep-uuids
grep-uuids:
${AG} "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b"
@@ -134,5 +159,12 @@ find-missing-eol:
sanitize-files:
git grep --cached -Ilz '' | while IFS= read -rd '' f; do tail -c1 < "$$f" | read -r _ || echo >> "$$f"; done

# Build targets ---------------------------------------------------------------
# Micro-packages build targets ------------------------------------------------
include Makefile.all

# Mono-package build targets --------------------------------------------------
DISABLE_HELP_PREAMBLE := true
help::
@printf "Available $(_yel)cloe$(_rst) package targets:\n"

include Makefile.package
66 changes: 20 additions & 46 deletions Makefile.all
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ SHELL := /bin/bash
GNUMAKEFLAGS := --no-print-directory
SUBMAKEFLAGS :=

META_PKG := cloe
PLUGIN_PKGS := $(wildcard plugins/*)
META_PKG := meta
PLUGIN_PKGS := plugins/basic plugins/gndtruth_extractor plugins/minimator plugins/mocks plugins/noisy_sensor plugins/speedometer plugins/virtue
ALL_PKGS := fable runtime models oak engine ${PLUGIN_PKGS} ${META_PKG}
WITHOUT_PKGS :=
UNSELECT_PKGS := ${WITHOUT_PKGS}
@@ -62,6 +62,7 @@ models: runtime
oak: runtime
engine: models oak
${PLUGIN_PKGS}: runtime models
${META_PKG}: fable runtime models oak engine ${PLUGIN_PKGS}

## BUILD_POLICY
## Usage: make BUILD_POLICY="missing"
@@ -106,22 +107,13 @@ ${1}-each: ${4}
endef

REGEX_TARGET := 's/(-vendor|-select)?-each//'
$(filter-out ${META_PKG}, ${ALL_PKGS} ${ALL_VENDOR}):
${ALL_PKGS} ${ALL_VENDOR}:
${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET})

# Re-define ${META_PKG} target to use Makefile.package, and only run for targets
# where it makes sense, since "${META_PKG}" is a Conan meta-package.
${META_PKG}:
for case in export package package-outdated list purge clean smoketest smoketest-deps; do \
if [ "$$(echo '${MAKECMDGOALS}' | sed -re ${REGEX_TARGET})" == "$${case}" ]; then \
${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS}" $${case} || exit 1; \
fi \
done

# Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY)
# define make_vendor_target
# $(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR}))
# endef
define make_vendor_target
$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR}))
endef

# Usage: $(call make_every_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY)
define make_every_target
@@ -139,19 +131,16 @@ endef
.PHONY: help
.SILENT: help
help::
$(call print_help_section, "Available build targets")

# $(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]")
# $(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]")
# $(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]")
$(call print_help_section, "Available multi-package targets")

ifneq "${ALL_VENDOR}" ""
help::
echo

$(call make_every_target, export, "export all package recipes", "[conan-cache]")
$(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]")
$(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]")
$(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]")
help::
$(call print_help_target, package, "create ${META_PKG} package and plugins", "[conan-cache]")
echo
endif

$(call make_select_target, export-select, "export selected packages", "[conan-cache]")
$(call make_select_target, package-select, "create selected packages with policy", "[conan-cache]")
@@ -179,34 +168,19 @@ $(call make_select_target, clean-select, "remove build artifacts", "[in-source]"
help::
echo
$(call print_help_subsection, "Options")
# $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}")
ifneq "${ALL_VENDOR}" ""
$(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}")
endif
$(call print_help_option, WITH_PKGS, "", "include optional packages from ${_grn}UNSELECT_PKGS${_rst}")
$(call print_help_option, LOCKFILE_SOURCE, "", "use specified conanfile as lockfile source for build")
echo
$(call print_help_subsection, "Defines")
$(call print_help_option, BUILD_POLICY, ${BUILD_POLICY})
$(call print_help_define, CONAN_OPTIONS, ${CONAN_OPTIONS})
# $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR})
# $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR})
ifneq "${ALL_VENDOR}" ""
$(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR})
$(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR})
endif
$(call print_help_define_lines, UNSELECT_PKGS, ${UNSELECT_PKGS})
$(call print_help_define_lines, SELECT_PKGS, ${SELECT_PKGS})
echo

.PHONY: package
package: export-select
# Build cloe with all targets and options together.
#
# This is different from the package target in that it always builds the
# packages from this workspace, the ones in SELECT_PKGS.
# This is different from the package-select target in that it builds them
# all together and thereby uses the correct dependency resolution with
# overrides and options.
TARGETS=$$( \
for pkg in ${SELECT_PKGS}; do \
if [ ! -d $${pkg} ]; then \
continue; \
fi; \
echo -n "--build=$$(make --no-print-directory -C $${pkg} info-name) "; \
done; \
) && \
${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS} $$TARGETS" package
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -84,14 +84,15 @@ See the Conan [documentation][6] for more information on how to do this.
To build all packages, you should run the following:
make package
make export-all
make -C meta package
This will export all Conan recipes from this repository and create the cloe
package. Conan will download and build all necessary dependencies. Should
any errors occur during the build, you may have to force Conan to build
all packages instead of re-using packages it finds:
```
make package CONAN_OPTIONS="--build"
make -C meta package CONAN_OPTIONS="--build"
```
Run `make help` to get an overview of the available targets we expect you to
use. For more details on how this is done, have a look at the Makefiles in the
@@ -166,7 +167,7 @@ Note that the above examples show the verbose output of the `cloe-launch` tool.
Integration and system tests can be run to ensure that all the packages built
are working together as expected:
make smoketest-deps
make export-all smoketest-deps
make smoketest
This will build packages in the required configurations as defined by the
203 changes: 164 additions & 39 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path
from semver import SemVer

from conan import ConanFile
from conan.tools import cmake, files, scm
@@ -16,22 +18,56 @@ class Cloe(ConanFile):
description = "Closed-loop automated driving simulation environment"
topics = ["simulation"]
settings = "os", "compiler", "build_type", "arch"
provides = (
"fable",
"cloe-runtime",
"cloe-models",
"cloe-oak",
"cloe-engine",
"cloe-plugins-core",
"cloe-plugin-basic",
"cloe-plugin-gndtruth-extractor",
"cloe-plugin-minimator",
"cloe-plugin-mocks",
"cloe-plugin-noisy-sensor",
"cloe-plugin-speedometer",
"cloe-plugin-virtue",
)
options = {
"with_vtd": [True, False],
"with_engine": [True, False],

# Doesn't affect package ID:
"pedantic": [True, False],
"shared": [True, False],
"fPIC": [True, False],
"fable_allow_comments": [True, False],
"engine_server": [True, False],
"engine_lrdb": [True, False]
}
default_options = {
"with_vtd": False,
"with_engine": True,

"pedantic": True,

"cloe-engine:server": True,
"shared": True,
"fPIC": True,
"fable_allow_comments": True,
"engine_server": True,
"engine_lrdb": True,
}
generators = "CMakeDeps", "VirtualRunEnv"
no_copy_source = True
exports_sources = [
"*/cmake/*",
"*/src/*",
"*/include/*",
"*/CMakeLists.txt",

"fable/examples/*",

"engine/lua/*",
"engine/webui/*",
"engine/vendor/*",

"plugins/*/src/*",
"plugins/*/include/*",
"plugins/*/ui/*",
"plugins/*/CMakeLists.txt",

"CMakelists.txt"
]

def set_version(self):
version_file = Path(self.recipe_folder) / "VERSION"
@@ -42,31 +78,120 @@ def set_version(self):
self.version = git.run("describe --dirty=-dirty")[1:]

def requirements(self):
def cloe_requires(dep):
self.requires(f"{dep}/{self.version}@cloe/develop")

cloe_requires("cloe-runtime")
cloe_requires("cloe-models")
cloe_requires("cloe-plugin-basic")
cloe_requires("cloe-plugin-gndtruth-extractor")
cloe_requires("cloe-plugin-minimator")
cloe_requires("cloe-plugin-mocks")
cloe_requires("cloe-plugin-noisy-sensor")
cloe_requires("cloe-plugin-speedometer")
cloe_requires("cloe-plugin-virtue")
if self.options.with_vtd:
cloe_requires("cloe-plugin-vtd")

boost_version = "[>=1.65.0]"
if self.options.with_engine:
cloe_requires("cloe-engine")

# Overrides:
self.requires("fmt/9.1.0", override=True)
self.requires("inja/3.4.0", override=True)
self.requires("nlohmann_json/3.11.2", override=True)
self.requires("incbin/cci.20211107", override=True),
self.requires(f"boost/{boost_version}", override=True)

def package_id(self):
del self.info.options.pedantic
self.requires("fmt/9.1.0")
self.requires("inja/3.4.0")
self.requires("nlohmann_json/3.11.2")
self.requires("incbin/cci.20211107"),
self.requires("spdlog/1.11.0")
self.requires("eigen/3.4.0")
self.requires("cli11/2.3.2", private=True)
self.requires("sol2/3.3.1")
self.requires("boost/[>=1.65.1]")
if self.options.engine_server:
self.requires("oatpp/1.3.0")

def build_requirements(self):
self.test_requires("gtest/1.13.0")

def layout(self):
cmake.cmake_layout(self)
self.cpp.build.bindirs = ["bin"]
self.cpp.source.includedirs.append(os.path.join(self.folders.build, "include"))

def generate(self):
# The version as a single 32-bit number takes the format:
#
# (EPOCH << 24) | (MAJOR_VERSION << 16) | (MINOR_VERSION << 8) | PATCH_VERSION
#
# Each version consists of at most 8 bits, so 256 potential values, including 0.
# The epoch starts with 0, and is bumped after each version naming scheme.
semver = SemVer(self.version, True)
version_u32 = (0<<24) | (semver.major << 16) | (semver.minor << 8) | semver.patch

tc = cmake.CMakeToolchain(self)
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
tc.cache_variables["CMAKE_MODULE_PATH"] = self.source_folder + "/runtime/cmake"
tc.cache_variables["FABLE_VERSION"] = self.version
tc.cache_variables["FABLE_VERSION_U32"] = version_u32
tc.cache_variables["FABLE_ALLOW_COMMENTS"] = self.options.fable_allow_comments
tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version
tc.cache_variables["CLOE_VERSION"] = self.version
tc.cache_variables["CLOE_VERSION_U32"] = version_u32
tc.cache_variables["CLOE_ENGINE_WITH_SERVER"] = self.options.engine_server
tc.cache_variables["CLOE_ENGINE_WITH_LRDB"] = self.options.engine_lrdb
tc.generate()

def build(self):
cm = cmake.CMake(self)
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
if self.should_install:
cm = cmake.CMake(self)
cm.install()

# Package license files for compliance
for meta, dep in self.dependencies.items():
if dep.package_folder is None:
continue
ref = str(meta.ref)
name = ref[: str(ref).index("/")]
files.copy(
self,
"*",
src=os.path.join(dep.package_folder, "licenses"),
dst=os.path.join(self.package_folder, "licenses", name),
)

def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "cloe")
self.cpp_info.set_property("pkg_config_name", "cloe")

self.cpp_info.components["fable"].libs = ["fable"]
self.cpp_info.components["fable"].set_property("cmake_file_name", "fable")
self.cpp_info.components["fable"].set_property("cmake_target_name", "fable::fable")
self.cpp_info.components["fable"].set_property("pkg_config_name", "fable")

self.cpp_info.components["runtime"].libs = ["cloe-runtime"]
self.cpp_info.components["runtime"].requires = ["fable"]
self.cpp_info.components["runtime"].set_property("cmake_file_name", "cloe-runtime")
self.cpp_info.components["runtime"].set_property("cmake_target_name", "cloe::runtime")
self.cpp_info.components["runtime"].set_property("pkg_config_name", "cloe-runtime")

if self.settings.os == "Linux":
self.cpp_info.system_libs.append("pthread")
self.cpp_info.system_libs.append("dl")

# Linking to libstdc++fs is required on GCC < 9.
# (GCC compilers with version < 7 have no std::filesystem support.)
# No consideration has been made yet for other compilers,
# please add them here as necessary.
if self.settings.get_safe("compiler") == "gcc" and self.settings.get_safe("compiler.version") in ["7", "8"]:
self.cpp_info.system_libs = ["stdc++fs"]

self.cpp_info.libs = files.collect_libs(self)
if not self.in_local_cache: # editable build
self.cpp_info.builddirs.append(os.path.join(self.source_folder, "cmake"))
self.cpp_info.includedirs.append(os.path.join(self.build_folder, "include"))
bindir = os.path.join(self.build_folder, "bin")
luadir = os.path.join(self.source_folder, "engine/lua")
libdir = os.path.join(self.build_folder, "lib");
else:
self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "cloe"))
bindir = os.path.join(self.package_folder, "bin")
luadir = os.path.join(self.package_folder, "lib/cloe/lua")
libdir = None

self.output.info(f"Appending PATH environment variable: {bindir}")
self.runenv_info.prepend_path("PATH", bindir)
self.output.info(f"Appending CLOE_LUA_PATH environment variable: {luadir}")
self.runenv_info.prepend_path("CLOE_LUA_PATH", luadir)
if libdir is not None:
self.output.info(f"Appending LD_LIBRARY_PATH environment variable: {libdir}")
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
148 changes: 139 additions & 9 deletions docs/develop/building-cloe.rst
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ directory of every Cloe package (e.g. in ``plugins/basic/``):
.. comment:
The path below is relative to the project docs folder, not this file.
.. runcmd:: make -C ../models help
.. runcmd:: bash -c "make -C ../models help | sed -e 's/\x1b\[[0-9;]*m//g'"
:replace: "PACKAGE_DIR:.*\\//PACKAGE_DIR: <SOME_PATH>\\/"

``conanfile.py``
@@ -61,22 +61,56 @@ Verify that the cloe-plugin-basic package is currently in editable mode::
make status

.. note::
Positive-Example:
Positive-Example::

.. code-block::
editable : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop

editable : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop
Negative-Example::

Negative-Example:

.. code-block::
ok : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop
ok : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop

Now, you can build the package binaries in your local working directory::

make clean all

The next time when Conan needs the package ``cloe-plugin-basic`` in
this version, it will resolve the include and library directories
to this local build. It is important to understand that you as a
developer are now responsible for ABI compatibility!!

.. note::
Conan can build packages with any constellation of dependencies that
you may require. This means that it is necessary to build an individual
package in a way that is compatible with the final composition.

For example, it may be that the entire set of packages as defined by
the ``cloe-meta`` package require ``boost/1.65.1``. When building
the ``basic`` plugin as in this example, it has no way of knowing
that this version of Boost will be used when building ``cloe-engine``.
Therefore Conan will use the latest version of the ``boost`` package
it can find, such as ``boost/1.78.0``.

In normal non-editable builds, Conan tracks these potential
incompatibilities and prevents you from incorrect combinations.
In editable mode however, you are responsible. Combining code
linked to two different versions of Boost is undefined behavior
and will lead to segfaults or worse!

The solution to this dilemma is to let Conan know when making
a local build to use the final composition configuration for
resolving dependency configurations. This can be done by
generating a lockfile first of the final composition, and
using this lockfile when building a part locally.

This is common enough that there is a simple mechanism baked
into the Makefiles to use a Conan recipe for automatically
generating and using a lockfile::

make clean all LOCKFILE_SOURCE=${CLOE_ROOT}/conanfile-meta.py

where ``${CLOE_ROOT}`` is the path to the repository root; for
the ``basic`` plugin, this is ``../..``.

Since the package is in editable mode, the binaries will be created in the
``./build/`` directory in your package sub-directory.

@@ -91,6 +125,102 @@ Verify the package status::
If you execute the latter command from the top-level directory, you will see the
status of all Cloe packages.

Practical Example
"""""""""""""""""

Let's apply the above to a very practical example involving ``cloe-engine``.
Assume the following situation: I checkout a develop branch, such as
``develop``, with the intention of modifying the ``cloe-engine`` package.

First, because I am going to make changes, I disable the use of ``git describe``
for versioning by explicitely setting a version::

echo "0.99.0-develop" > VERSION

Then I make sure the entire project is exported::

make export-all

.. note::
This is roughtly equivalent to::

( cd fable && conan export conanfile.py fable/0.99.0-develop@cloe/develop)
( cd runtime && conan export conanfile.py cloe-runtime/0.99.0-develop@cloe/develop)
...

If there are any changes in other packages, I want to pick up those as well.
I let Conan know that I want to use ``cloe-engine`` in editable mode::

cd engine
make editable

.. note::
This is equivalent to::

cd engine
conan editable add conanfile cloe-engine/0.99.0-develop@cloe/develop

Now, I need to choose a configuration that I want to use for testing the
entire set of packages. I can use ``cloe-meta`` or I can use a configuration
in the ``tests/`` directory, such as ``tests/conanfile_split.py``.
I use this when building ``cloe-engine`` as the source for creating a lockfile::

cd engine
make clean all LOCKFILE_SOURCE=../tests/conanfile_split.py

This will automatically build any missing dependencies that are necessary for
building ``cloe-engine``, after which it will build ``cloe-engine`` locally.

Before running any tests, I may need to make sure any additional dependencies
not required by ``cloe-engine`` but required for the test execution are
built::

cloe-launch prepare tests/conanfile_split.py

.. note::
This is *approximately* equivalent to::

conan install ../tests/conanfile_split.py --build=outdated --build=cascade

Once this is complete, we can launch into a correctly configured shell,
with ``PATH`` and ``LD_LIBRARY_PATH`` set so that the shell can find
``cloe-engine`` and it can find required libraries and plugins.

.. code-block::
cloe-launch shell -c tests/conanfile_split.py
And at this point we are done and can run tests, make modifications
to the editable ``cloe-engine`` package, rebuild, and run tests again::

bats tests
$EDITOR engine/src/main.cpp
make -C engine all
bats tests


Superbuild
----------

The practical example of in-source builds above was one of the easiest
configurations we could choose. It becomes more arduous when we want to
edit packages that other packages in turn depend on, because then we need
to compile multiple packages by hand in the correct order.

To side-step all of this, we have the ``cloe`` package, which is a
super-build of all other packages.

You can build in the Conan cache with::

make package

You can build it locally with::

make all

You can then launch a virtual environment with ``cloe-launch``::

cloe-launch shell tests/conanfile_all.py

.. _Conan local cache: https://docs.conan.io/en/latest/mastering/custom_cache.html
.. _Conan CMake integration: https://docs.conan.io/en/latest/integrations/build_system/cmake.html
13 changes: 7 additions & 6 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -69,14 +69,15 @@ Build Cloe Packages
-------------------
To build all packages, you should run the following::

make package
make export-all
make -C meta package

This will export all Conan recipes from this repository and create the cloe
package. Conan will download and build all necessary dependencies. Should
any errors occur during the build, you may have to force Conan to build
all packages instead of re-using packages it finds::

make package CONAN_OPTIONS="--build"
make -C meta package CONAN_OPTIONS="--build"

.. note::
Depending on your Conan profile, building the Cloe packages can involve
@@ -88,16 +89,16 @@ all packages instead of re-using packages it finds::
If you like, you can inspect what a Conan Cloe package looks like by browsing
the Conan cache directory under ``~/.conan/data/cloe``.

Run ``make help`` to get an overview of the available targets we expect you to
use. For more details on how this is done, have a look at the Makefiles in the
repository root.
Run ``make help`` to get an overview of the available targets we anticipate you
may want to use. For more details on how this is done, have a look at the
Makefiles in the repository root.

Run System Tests
----------------
To check that everything is working as it should, we recommend you run the
included test suite once before commencing with anything else::

make export smoketest-deps smoketest
make export-all smoketest-deps smoketest

.. _Conan: https://conan.io
.. _Conan documentation: https://docs.conan.io/en/latest/
117 changes: 45 additions & 72 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,9 +2,12 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_engine LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
find_package(fable REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(fable REQUIRED)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()
find_package(Boost REQUIRED)
find_package(CLI11 REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -20,21 +23,26 @@ set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION})
set(PROJECT_GIT_REF "unknown")

# Library libstack ---------------------------------------------------
add_library(cloe-stacklib
add_library(cloe-stacklib STATIC
src/config.hpp
src/stack.hpp
src/stack.cpp
src/stack_factory.hpp
src/stack_factory.cpp
src/plugin.hpp
src/plugin.cpp

# Built-in plugins:
src/plugins/nop_controller.cpp
src/plugins/nop_controller.hpp
src/plugins/nop_simulator.cpp
src/plugins/nop_simulator.hpp
)
add_library(cloe::stacklib ALIAS cloe-stacklib)
set_target_properties(cloe-stacklib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
OUTPUT_NAME stack
LIBRARY_OUTPUT_DIRECTORY "lib"
)
target_include_directories(cloe-stacklib
PRIVATE
@@ -43,6 +51,7 @@ target_include_directories(cloe-stacklib
target_link_libraries(cloe-stacklib
PUBLIC
cloe::runtime
cloe::models
fable::fable
Boost::headers
Threads::Threads
@@ -72,8 +81,8 @@ if(BUILD_TESTING)
gtest_add_tests(TARGET test-stacklib)
endif()

# Library liblua------------------------------------------------------
add_library(cloe-lualib
# Library libengine ----------------------------------------------
add_library(cloe-enginelib STATIC
src/lua_api.hpp
src/lua_api.cpp
src/lua_setup.hpp
@@ -82,63 +91,11 @@ add_library(cloe-lualib
src/lua_setup_fs.cpp
src/lua_setup_stack.cpp
src/lua_setup_sync.cpp
)
add_library(cloe::lualib ALIAS cloe-lualib)
target_compile_definitions(cloe-lualib
PUBLIC
SOL_ALL_SAFETIES_ON=1
LRDB_USE_BOOST_ASIO=1
)
set_target_properties(cloe-lualib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
OUTPUT_NAME lua
LIBRARY_OUTPUT_DIRECTORY "lib"
)
target_include_directories(cloe-lualib
PRIVATE
src
)
target_link_libraries(cloe-lualib
PUBLIC
boost::boost
sol2::sol2
cloe::stacklib
cloe::runtime
fable::fable
Threads::Threads
)
if(BUILD_TESTING)
add_executable(test-lualib
src/lua_stack_test.cpp
)
set_target_properties(test-lualib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(test-lualib
GTest::gtest
GTest::gtest_main
Boost::boost
cloe::models
cloe::stacklib
cloe::lualib
)
gtest_add_tests(TARGET test-lualib)
endif()

# Library libengine ----------------------------------------------
add_library(cloe-enginelib
src/coordinator.cpp
src/coordinator.hpp
src/lua_action.cpp
src/lua_action.hpp
src/plugins/nop_controller.cpp
src/plugins/nop_controller.hpp
src/plugins/nop_simulator.cpp
src/plugins/nop_simulator.hpp
src/registrar.hpp
src/server.hpp
# These are added below and depend on CLOE_ENGINE_WITH_SERVER:
# src/server.cpp
# src/server_mock.cpp
@@ -147,9 +104,6 @@ add_library(cloe-enginelib
src/simulation_context.cpp
src/simulation_context.hpp
src/simulation_progress.hpp
# These are added below and depend on CLOE_ENGINE_WITH_SERVER:
# src/server.cpp
# src/server_mock.cpp
src/utility/command.cpp
src/utility/command.hpp
src/utility/defer.hpp
@@ -162,10 +116,11 @@ set_target_properties(cloe-enginelib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
OUTPUT_NAME engine
LIBRARY_OUTPUT_DIRECTORY "lib"
)
target_compile_definitions(cloe-enginelib
PUBLIC
SOL_ALL_SAFETIES_ON=1
LRDB_USE_BOOST_ASIO=1
CLOE_ENGINE_VERSION="${CLOE_ENGINE_VERSION}"
CLOE_ENGINE_TIMESTAMP="${CLOE_ENGINE_TIMESTAMP}"
PROJECT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
@@ -176,26 +131,28 @@ target_include_directories(cloe-enginelib
)
target_link_libraries(cloe-enginelib
PUBLIC
cloe::lualib
cloe::stacklib
cloe::models
cloe::runtime
fable::fable
boost::boost
sol2::sol2
Threads::Threads
)

option(CLOE_ENGINE_WITH_SERVER "Enable integrated server component?" ON)
if(CLOE_ENGINE_WITH_SERVER)
message(STATUS "-> Enable server component")
find_package(cloe-oak REQUIRED)
if(CLOE_FIND_PACKAGES)
find_package(cloe-oak REQUIRED)
endif()
target_sources(cloe-enginelib PRIVATE src/server.cpp)
target_link_libraries(cloe-enginelib PRIVATE cloe::oak)
target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_SERVER=1)
target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_SERVER=1)
else()
message(STATUS "-> Disable server component")
target_sources(cloe-enginelib PRIVATE src/server_mock.cpp)
target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_SERVER=0)
target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_SERVER=0)
endif()

option(CLOE_ENGINE_WITH_LRDB "Enable LRDB Lua Debugger?" ON)
@@ -204,10 +161,29 @@ if(CLOE_ENGINE_WITH_LRDB)
add_subdirectory(vendor/lrdb)
target_sources(cloe-enginelib PRIVATE src/lua_debugger.cpp)
target_link_libraries(cloe-enginelib PRIVATE lrdb::lrdb)
target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_LRDB=1)
target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_LRDB=1)
else()
message(STATUS "-> Disable LRDB component")
target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_LRDB=0)
target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_LRDB=0)
endif()

if(BUILD_TESTING)
add_executable(test-enginelib
src/lua_stack_test.cpp
)
set_target_properties(test-enginelib PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(test-enginelib
GTest::gtest
GTest::gtest_main
Boost::boost
cloe::models
cloe::stacklib
cloe::enginelib
)
gtest_add_tests(TARGET test-enginelib)
endif()

# Executable ---------------------------------------------------------
@@ -226,17 +202,14 @@ set_target_properties(cloe-engine PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
OUTPUT_NAME cloe-engine
RUNTIME_OUTPUT_DIRECTORY bin
)
set_target_linting(cloe-engine)
target_include_directories(cloe-engine
PRIVATE
src
)
target_link_libraries(cloe-engine
PRIVATE
cloe::stacklib
cloe::lualib
cloe::enginelib
CLI11::CLI11
linenoise::linenoise
5 changes: 2 additions & 3 deletions engine/conanfile.py
Original file line number Diff line number Diff line change
@@ -70,7 +70,6 @@ def build_requirements(self):

def layout(self):
cmake.cmake_layout(self)
self.cpp.build.bindirs = ["bin"]

def generate(self):
tc = cmake.CMakeToolchain(self)
@@ -123,8 +122,8 @@ def package_info(self):
if self.in_local_cache:
bindir = os.path.join(self.package_folder, "bin")
luadir = os.path.join(self.package_folder, "lib/cloe/lua")
else:
bindir = os.path.join(self.build_folder, "bin")
else: # editable mode
bindir = os.path.join(self.build_folder)
luadir = os.path.join(self.source_folder, "lua")

self.output.info(f"Appending PATH environment variable: {bindir}")
32 changes: 0 additions & 32 deletions engine/tests/conanfile_with_server.py

This file was deleted.

35 changes: 0 additions & 35 deletions engine/tests/conanfile_without_server.py

This file was deleted.

45 changes: 0 additions & 45 deletions engine/tests/config_nop_infinite.json

This file was deleted.

20 changes: 0 additions & 20 deletions engine/tests/config_nop_smoketest.json

This file was deleted.

131 changes: 0 additions & 131 deletions engine/tests/wip_brainstorm.lua

This file was deleted.

99 changes: 0 additions & 99 deletions engine/tests/wip_config_nop_infinite.lua

This file was deleted.

51 changes: 0 additions & 51 deletions engine/tests/wip_config_nop_smoketest.lua

This file was deleted.

35 changes: 0 additions & 35 deletions engine/tests/wip_hello_plugin.lua

This file was deleted.

Empty file removed engine/tests/wip_hello_world.lua
Empty file.
17 changes: 0 additions & 17 deletions engine/tests/wip_include_json.lua

This file was deleted.

78 changes: 0 additions & 78 deletions engine/tests/wip_setup.lua

This file was deleted.

28 changes: 0 additions & 28 deletions engine/tests/wip_setup_v2.lua

This file was deleted.

37 changes: 0 additions & 37 deletions engine/tests/wip_test_controller_stuck.lua

This file was deleted.

37 changes: 0 additions & 37 deletions engine/tests/wip_test_engine_watchdog.lua

This file was deleted.

3 changes: 3 additions & 0 deletions meta/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
override BUILD_IN_SOURCE := false

include ../Makefile.package
64 changes: 64 additions & 0 deletions meta/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# mypy: ignore-errors
# pylint: skip-file

from pathlib import Path

from conan import ConanFile
from conan.tools import files, scm

required_conan_version = ">=1.52.0"


class CloeMeta(ConanFile):
name = "cloe-meta"
license = "Apache-2.0"
url = "https://github.com/eclipse/cloe"
description = "Closed-loop automated driving simulation environment"
topics = ["simulation"]
settings = "os", "compiler", "build_type", "arch"
options = {
"with_vtd": [True, False],
"with_engine": [True, False],
}
default_options = {
"with_vtd": False,
"with_engine": True,

"fable:allow_comments": True,
"engine:server": True,
"engine:lrdb": True,
}

def set_version(self):
version_file = Path(self.recipe_folder) / "../VERSION"
if version_file.exists():
self.version = files.load(self, version_file).strip()
else:
git = scm.Git(self, self.recipe_folder)
self.version = git.run("describe --dirty=-dirty")[1:]

def requirements(self):
def cloe_requires(dep):
self.requires(f"{dep}/{self.version}@cloe/develop")

cloe_requires("cloe-runtime")
cloe_requires("cloe-models")
cloe_requires("cloe-plugin-basic")
cloe_requires("cloe-plugin-gndtruth-extractor")
cloe_requires("cloe-plugin-minimator")
cloe_requires("cloe-plugin-mocks")
cloe_requires("cloe-plugin-noisy-sensor")
cloe_requires("cloe-plugin-speedometer")
cloe_requires("cloe-plugin-virtue")
if self.options.with_vtd:
cloe_requires("cloe-plugin-vtd")

if self.options.with_engine:
cloe_requires("cloe-engine")

# Overrides:
self.requires("fmt/9.1.0", override=True)
self.requires("inja/3.4.0", override=True)
self.requires("nlohmann_json/3.11.2", override=True)
self.requires("incbin/cci.20211107", override=True),
self.requires(f"boost/[>=1.65.0]", override=True)
29 changes: 14 additions & 15 deletions models/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -6,17 +6,17 @@ include(GNUInstallDirs)
include(TargetLinting)

# Module -------------------------------------------------------------
set(target cloe-models)
set(alias cloe::models)

find_package(cloe-runtime REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
endif()
find_package(Eigen3 REQUIRED)
find_package(Boost COMPONENTS headers REQUIRED)
find_package(sol2 REQUIRED)

message(STATUS "-> Building ${output} library.")
file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp")
add_library(${target}
message(STATUS "-> Building cloe-models library.")
file(GLOB cloe-models_PUBLIC_HEADERS "include/**/*.hpp")
add_library(cloe-models
# find src -type f -name "*.cpp" \! -name "*_test.cpp"
src/cloe/component/lane_boundary.cpp
src/cloe/component/utility/ego_sensor_canon.cpp
@@ -25,21 +25,20 @@ add_library(${target}
src/cloe/utility/lua_types.cpp

# For IDE integration
${${target}_PUBLIC_HEADERS}
${cloe-models_PUBLIC_HEADERS}
)
add_library(${alias} ALIAS ${target})
set_target_properties(${target} PROPERTIES
add_library(cloe::models ALIAS cloe-models)
set_target_properties(cloe-models PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
VERSION ${CLOE_PROJECT_VERSION}
)
set_target_linting(${target})
target_include_directories(${target}
target_include_directories(cloe-models
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_link_libraries(${target}
target_link_libraries(cloe-models
PUBLIC
cloe::runtime
Boost::headers
@@ -71,13 +70,13 @@ if(BUILD_TESTING)
GTest::gtest_main
Boost::boost
cloe::runtime
${target}
cloe-models
)
gtest_add_tests(TARGET test-models)
endif()

# Installation -------------------------------------------------------
install(TARGETS ${target}
install(TARGETS cloe-models
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE
27 changes: 13 additions & 14 deletions oak/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -6,37 +6,36 @@ include(GNUInstallDirs)
include(TargetLinting)

# Library ------------------------------------------------------------
set(target cloe-oak)
set(alias cloe::oak)

find_package(cloe-runtime REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
endif()
find_package(oatpp REQUIRED)

file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp")
add_library(${target}
file(GLOB cloe-oak_PUBLIC_HEADERS "include/**/*.hpp")
add_library(cloe-oak
# find src -type f -name "*.cpp" \! -name "*_test.cpp"
src/oak/registrar.cpp
src/oak/server.cpp

# For IDE integration
${${target}_PUBLIC_HEADERS}
${cloe-oak_PUBLIC_HEADERS}
src/oak/request_stub.hpp
src/oak/curl.hpp
)
add_library(${alias} ALIAS ${target})
set_target_linting(${target})
set_target_properties(${target} PROPERTIES
add_library(cloe::oak ALIAS cloe-oak)
set_target_properties(cloe-oak PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_include_directories(${target}
target_include_directories(cloe-oak
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_link_libraries(${target}
target_link_libraries(cloe-oak
PUBLIC
cloe::runtime
oatpp::oatpp
@@ -65,13 +64,13 @@ if(BUILD_TESTING)
target_link_libraries(test-oak
GTest::gtest
GTest::gtest_main
${target}
cloe-oak
)
gtest_add_tests(TARGET test-oak)
endif()

# Installation -------------------------------------------------------
install(TARGETS ${target}
install(TARGETS cloe-oak
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE
42 changes: 42 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This CMakeLists.txt configures a super-build of all plugins.
#
# It is currently experimental.
#
# This supports two use-cases:
#
# 1. Creating a cloe-plugins-core package containing all plugins.
# 2. Creating a cloe package containing everything from this repo.
#
# Other use-cases are currently not supported.
#

cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

if(NOT DEFINED PROJECT_NAME)
project(cloe_plugins_core LANGUAGES CXX)

# Speed up configuration by only finding Cloe packages once
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES OFF FORCE)
endif()

# Ensure output goes to one place so cloe-launch can find the plugins
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
elseif(NOT ${PROJECT_NAME} STREQUAL "cloe")
message(FATAL_ERROR "Building super-project unequal to cloe not suppoorted.")
endif()

# Ensure we can test from this level.
include(CTest)

add_subdirectory(basic)
add_subdirectory(gndtruth_extractor)
add_subdirectory(minimator)
add_subdirectory(mocks)
add_subdirectory(noisy_sensor)
add_subdirectory(speedometer)
add_subdirectory(virtue)
1 change: 1 addition & 0 deletions plugins/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../Makefile.package
7 changes: 5 additions & 2 deletions plugins/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_basic LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
2 changes: 1 addition & 1 deletion plugins/basic/conanfile.py
Original file line number Diff line number Diff line change
@@ -79,6 +79,6 @@ def package_info(self):
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache:
if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
88 changes: 88 additions & 0 deletions plugins/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools import cmake, files, scm, env

required_conan_version = ">=1.52.0"


class CloeControllerBasic(ConanFile):
name = "cloe-plugins-core"
url = "https://github.com/eclipse/cloe"
description = "Cloe core plugins"
license = "Apache-2.0"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "VirtualRunEnv"
no_copy_source = True
provides = [
"cloe-plugin-basic",
"cloe-plugin-gndtruth-extractor",
"cloe-plugin-minimator",
"cloe-plugin-mocks",
"cloe-plugin-noisy-sensor",
"cloe-plugin-speedometer",
"cloe-plugin-virtue",
]
exports_sources = [
"*/src/*",
"*/include/*",
"*/ui/*",
"*/CMakeLists.txt",
]

def set_version(self):
version_file = Path(self.recipe_folder) / "../VERSION"
if version_file.exists():
self.version = files.load(self, version_file).strip()
else:
git = scm.Git(self, self.recipe_folder)
self.version = git.run("describe --dirty=-dirty")[1:]

def requirements(self):
self.requires(f"cloe-runtime/{self.version}@cloe/develop")
self.requires(f"cloe-models/{self.version}@cloe/develop")

def build_requirements(self):
self.test_requires("gtest/1.13.0")

def layout(self):
cmake.cmake_layout(self)

def generate(self):
tc = cmake.CMakeToolchain(self)
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version
tc.cache_variables["TargetLintingExtended"] = True
tc.generate()

def build(self):
cm = cmake.CMake(self)
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
if self.should_install:
cm.install()

def package_id(self):
self.info.requires["boost"].full_package_mode()
del self.info.options.pedantic

def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache:
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
7 changes: 5 additions & 2 deletions plugins/gndtruth_extractor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_gndtruth_extractor LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
5 changes: 5 additions & 0 deletions plugins/gndtruth_extractor/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
@@ -76,3 +77,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_find_mode", f"both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
32 changes: 0 additions & 32 deletions plugins/gndtruth_extractor/tests/conanfile_default.py

This file was deleted.

7 changes: 5 additions & 2 deletions plugins/minimator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_minimator LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
5 changes: 5 additions & 0 deletions plugins/minimator/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
@@ -74,3 +75,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
35 changes: 0 additions & 35 deletions plugins/minimator/tests/conanfile_default.py

This file was deleted.

7 changes: 5 additions & 2 deletions plugins/mocks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_mocks LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
5 changes: 5 additions & 0 deletions plugins/mocks/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
@@ -71,3 +72,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
7 changes: 5 additions & 2 deletions plugins/noisy_sensor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_noisy_sensors LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
5 changes: 5 additions & 0 deletions plugins/noisy_sensor/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
@@ -76,3 +77,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
7 changes: 5 additions & 2 deletions plugins/speedometer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_speedometer LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
5 changes: 5 additions & 0 deletions plugins/speedometer/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
@@ -71,3 +72,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
7 changes: 5 additions & 2 deletions plugins/virtue/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_virtue LANGUAGES CXX)

find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
endif()

include(CloePluginSetup)
cloe_add_plugin(
5 changes: 5 additions & 0 deletions plugins/virtue/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mypy: ignore-errors
# pylint: skip-file

import os
from pathlib import Path

from conan import ConanFile
@@ -71,3 +72,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("pkg_config_name", self.name)

if not self.in_local_cache: # editable mode
libdir = os.path.join(self.build_folder, "lib");
self.runenv_info.append_path("LD_LIBRARY_PATH", libdir)
35 changes: 0 additions & 35 deletions plugins/virtue/tests/conanfile_default.py

This file was deleted.

7 changes: 4 additions & 3 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -8,10 +8,12 @@ set(CLOE_VERSION "0.0.0-undefined" CACHE STRING "Cloe version as MAJOR.MINOR.PAT
set(CLOE_VERSION_U32 0 CACHE STRING "Cloe version as (MAJOR<<16)|(MINOR<<8)|PATCH integer")

include(GNUInstallDirs)
include(cmake/TargetLinting.cmake)

# Library -------------------------------------------------------------
find_package(fable REQUIRED)
set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages")
if(CLOE_FIND_PACKAGES)
find_package(fable REQUIRED)
endif()
find_package(Boost COMPONENTS headers filesystem iostreams system REQUIRED)
find_package(spdlog REQUIRED)
find_package(inja REQUIRED)
@@ -54,7 +56,6 @@ set_target_properties(cloe-runtime PROPERTIES
CXX_STANDARD_REQUIRED ON
VERSION ${CLOE_VERSION}
)
set_target_linting(cloe-runtime)
configure_file(src/cloe/version.hpp.in include/cloe/version.hpp @ONLY)
target_include_directories(cloe-runtime
PUBLIC
6 changes: 3 additions & 3 deletions runtime/cmake/CloePluginSetup.cmake
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ include(TargetLinting)

function(cloe_add_plugin)
set(options
NO_LINTING
LINT
)
set(one_value_args
TARGET # [required]
@@ -44,7 +44,7 @@ function(cloe_add_plugin)
message(SEND_ERROR "cloe_add_plugin requires property SOURCES to be set")
endif()
if(NOT DEFINED _ARG_OUTPUT_DIRECTORY)
set(_ARG_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/cloe)
set(_ARG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cloe)
endif()

# Add the cloe plugin target:
@@ -71,7 +71,7 @@ function(cloe_add_plugin)
OUTPUT_NAME ${_ARG_OUTPUT_NAME}
PREFIX ""
)
if(NOT ${_ARG_NO_LINTING})
if(${_ARG_LINT})
set_target_linting(${target})
endif()
target_compile_options(${target}
12 changes: 8 additions & 4 deletions tests/conanfile_default.py → tests/conanfile_all.py
Original file line number Diff line number Diff line change
@@ -10,14 +10,17 @@ class CloeTest(ConanFile):
python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop"
python_requires_extend = "cloe-launch-profile.Base"

options = {
"with_vtd": [True, False]
}
default_options = {
"cloe:with_vtd": False,
"cloe-engine:server": True,
"with_vtd": False
}

@property
def cloe_launch_env(self):
return {
"CLOE_ENGINE_WITH_SERVER": "1",
"CLOE_LOG_LEVEL": "debug",
"CLOE_STRICT_MODE": "1",
"CLOE_WRITE_OUTPUT": "0",
@@ -29,8 +32,9 @@ def set_version(self):

def requirements(self):
self.requires(f"cloe/{self.version}@cloe/develop")
if self.options["cloe"].with_vtd:
# These dependencies aren't pulled in by the "cloe" package,
if self.options.with_vtd:
self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop")
# These dependencies aren't pulled in by the "cloe-plugin-vtd" package,
# because they are not required to build the package.
# We need them to run the tests though.
self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable")
16 changes: 9 additions & 7 deletions tests/conanfile_with_boost_1.78.py → tests/conanfile_split.py
Original file line number Diff line number Diff line change
@@ -10,14 +10,17 @@ class CloeTest(ConanFile):
python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop"
python_requires_extend = "cloe-launch-profile.Base"

options = {
"with_vtd": [True, False]
}
default_options = {
"cloe:with_vtd": False,
"cloe-engine:server": True,
"with_vtd": False
}

@property
def cloe_launch_env(self):
return {
"CLOE_ENGINE_WITH_SERVER": "1",
"CLOE_LOG_LEVEL": "debug",
"CLOE_STRICT_MODE": "1",
"CLOE_WRITE_OUTPUT": "0",
@@ -28,12 +31,11 @@ def set_version(self):
self.version = self.project_version("../VERSION")

def requirements(self):
self.requires(f"cloe/{self.version}@cloe/develop")
if self.options["cloe"].with_vtd:
# These dependencies aren't pulled in by the "cloe" package,
self.requires(f"cloe-meta/{self.version}@cloe/develop")
if self.options.with_vtd:
self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop")
# These dependencies aren't pulled in by the "cloe-plugin-vtd" package,
# because they are not required to build the package.
# We need them to run the tests though.
self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable")
self.requires("vtd/2.2.0@cloe-restricted/stable")

self.requires("boost/1.78.0", override=True)
43 changes: 43 additions & 0 deletions tests/conanfile_split_without_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# mypy: ignore-errors
# pylint: skip-file

from pathlib import Path

from conan import ConanFile


class CloeTest(ConanFile):
python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop"
python_requires_extend = "cloe-launch-profile.Base"

options = {
"with_vtd": [True, False]
}
default_options = {
"with_vtd": False,

"cloe-engine:server": False,
}

@property
def cloe_launch_env(self):
return {
"CLOE_ENGINE_WITH_SERVER": "1",
"CLOE_LOG_LEVEL": "debug",
"CLOE_STRICT_MODE": "1",
"CLOE_WRITE_OUTPUT": "0",
"CLOE_ROOT": Path(self.recipe_folder) / "..",
}

def set_version(self):
self.version = self.project_version("../VERSION")

def requirements(self):
self.requires(f"cloe-meta/{self.version}@cloe/develop")
if self.options.with_vtd:
self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop")
# These dependencies aren't pulled in by the "cloe-plugin-vtd" package,
# because they are not required to build the package.
# We need them to run the tests though.
self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable")
self.requires("vtd/2.2.0@cloe-restricted/stable")
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4",
"include": [
"${CLOE_ROOT}/tests/controller_basic.json"
"just_controller_basic.json"
],
"defaults": {
"controllers": [
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/config_nop_infinite.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "4",
"include": [
"controller_virtue.json",
"controller_basic.json"
"just_controller_virtue.json",
"just_controller_basic.json"
],
"simulators": [
{
43 changes: 1 addition & 42 deletions tests/config_nop_smoketest.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,12 @@
{
"version": "4",
"include": [
"controller_virtue.json",
"controller_basic.json"
"config_nop_infinite.json"
],
"simulators": [
{
"binding": "nop"
}
],
"vehicles": [
{
"name": "default",
"from": {
"simulator": "nop",
"index": 0
},
"components": {
"cloe::speedometer": {
"binding": "speedometer",
"name": "default_speed",
"from": "cloe::gndtruth_ego_sensor"
},
"cloe::default_world_sensor": {
"binding": "noisy_object_sensor",
"name": "noisy_object_sensor",
"from": "cloe::default_world_sensor",
"args": {
"noise": [
{
"target": "translation",
"distribution": {
"binding": "normal",
"mean": 0.0,
"std_deviation": 0.3
}
}
]
}
}
}
}
],

"server": {
"listen": false,
"listen_port": 23456
},

"triggers": [
{"event": "virtue/failure", "action": "fail"},
{
36 changes: 0 additions & 36 deletions tests/controller_basic.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/controller_virtue.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions tests/setup_bats.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bats

# All tests are run from within the tests/ directory.
cd "${BATS_TEST_DIRNAME}"

# The path to use whenever we need a temporary registry. Whenever we use this, we
# probably want to specify the `--write-output` flag too, otherwise nothing will
# be written to the registry.
@@ -45,3 +48,15 @@ test_plugin_exists() {

cloe-engine usage "${plugin}" &>/dev/null
}

require_program() {
if ! type $1 &>/dev/null; then
skip "required program not present: $1"
fi
}

require_engine_with_server() {
if ! cloe-engine version | grep -F "server: true" &>/dev/null; then
skip "required engine option not set: server"
fi
}
28 changes: 7 additions & 21 deletions engine/tests/test_engine.bats → tests/test_engine.bats
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#!/usr/bin/env bats

cd "${BATS_TEST_DIRNAME}"
export CLOE_ROOT="${BATS_TEST_DIRNAME}/../.."
load "${CLOE_ROOT}/tests/setup_bats.bash"
load "${CLOE_ROOT}/tests/setup_testname.bash"

require_program() {
if ! type $1 &>/dev/null; then
skip "required program not present: $1"
fi
}

require_engine_with_server() {
if ! cloe-engine version | grep -F "server: true" &>/dev/null; then
skip "required engine option not set: server"
fi
}
load setup_bats
load setup_testname

@test "$(testname 'Expect schema equality' 'test_engine_json_schema.json' '4d368665-b666-4289-8a7a-b76ca53db688')" {
# Note: you will have to update the schema files every time you change the schema,
@@ -37,9 +23,9 @@ require_engine_with_server() {
# This does not negatively affect the validity of the test.
reference_file=test_engine_nop_smoketest_dump.json
diff <(cloe-engine dump config_nop_smoketest.json |
sed -r -e 's#"/.*\/.*.conan/data/([^/]+)/.*"#"/.../\1/.../"#' \
-e '\#\.\.\./cloe-engine/\.\.\.#d' \
-e "\\#(${HOME-/root}|${CONAN_USER_HOME-/cloe_dev})/.*#d" \
sed -r -e '#"/.*\/.*.conan/data/([^/]+)/.*"#d' \
-e '\#\.\.\./cloe-engine/\.\.\.#d' \
-e "\\#(${HOME-/root}|${CONAN_USER_HOME-/cloe_dev})/.*#d" \
) \
${reference_file}
}
@@ -292,13 +278,13 @@ require_engine_with_server() {
}

@test "$(testname 'Expect check/run success' 'test_engine_smoketest.json [ts=5ms]' '1a31022c-e20c-4a9e-9373-ad54a3729442')" {
local timestep_stack="${CLOE_ROOT}/tests/option_timestep_5.json"
local timestep_stack="option_timestep_5.json"
cloe-engine check test_engine_smoketest.json "${timestep_stack}"
cloe-engine run test_engine_smoketest.json "${timestep_stack}"
}

@test "$(testname 'Expect check/run success' 'test_engine_smoketest.json [ts=60ms]' 'e7957fa0-1145-4458-b665-eec51c1f0da5')" {
local timestep_stack="${CLOE_ROOT}/tests/option_timestep_60.json"
local timestep_stack="option_timestep_60.json"
cloe-engine check test_engine_smoketest.json "${timestep_stack}"
cloe-engine run test_engine_smoketest.json "${timestep_stack}"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -252,6 +252,59 @@
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"components": {
"description": "array of components to be extracted",
"items": {
"type": "string"
},
"type": "array"
},
"output_file": {
"description": "file path to write groundtruth output to",
"type": "string"
},
"output_type": {
"description": "type of output file to write",
"enum": [
"json.bz2",
"json.gz",
"json.zip",
"json",
"msgpack.bz2",
"msgpack.gz",
"msgpack.zip",
"msgpack"
],
"type": "string"
}
},
"type": "object"
},
"binding": {
"const": "gndtruth_extractor",
"description": "name of factory"
},
"name": {
"description": "globally unique identifier for controller",
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
"type": "string"
},
"vehicle": {
"description": "vehicle controller is assigned to",
"type": "string"
}
},
"required": [
"binding"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
@@ -1083,6 +1136,37 @@
"description": "simulator configuration",
"items": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": false,
"properties": {
"vehicles": {
"description": "list of vehicle names to make available",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"binding": {
"const": "minimator",
"description": "name of factory"
},
"name": {
"description": "globally unique identifier for simulator",
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
"type": "string"
}
},
"required": [
"binding"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -32,11 +32,6 @@
"path": "${CLOE_SIMULATION_UUID}"
},
"plugin_path": [
"/.../cloe-plugin-basic/.../",
"/.../cloe-plugin-mocks/.../",
"/.../cloe-plugin-noisy-sensor/.../",
"/.../cloe-plugin-speedometer/.../",
"/.../cloe-plugin-virtue/.../"
],
"plugins": {
"allow_clobber": true,
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -4,10 +4,8 @@
# configuration of a simulation results in roughly the same output
# again, i.e., the simulation is reproducible.

cd "${BATS_TEST_DIRNAME}"
export CLOE_ROOT="${BATS_TEST_DIRNAME}/../.."
load "${CLOE_ROOT}/tests/setup_bats.bash"
load "${CLOE_ROOT}/tests/setup_testname.bash"
load setup_bats
load setup_testname

teardown() {
# Remove the temporary registry.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bats

cd "${BATS_TEST_DIRNAME}"
export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.."
load "${CLOE_ROOT}/tests/setup_bats.bash"
load "${CLOE_ROOT}/tests/setup_testname.bash"
load setup_bats
load setup_testname

# Usage: FILENAME=$(mktemp_gndtruth_out SUFFIX)
#
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4",
"include": [
"${CLOE_ROOT}/tests/controller_basic.json"
"${CLOE_ROOT}/tests/just_controller_basic.json"
],
"simulators": [
{
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4",
"include": [
"config_minimator_smoketest.json"
"test_gndtruth_config.json"
],
"controllers": [
{
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4",
"include": [
"config_minimator_smoketest.json"
"test_gndtruth_config.json"
],
"controllers": [
{
File renamed without changes.
12 changes: 2 additions & 10 deletions engine/tests/test_lua.bats → tests/test_lua.bats
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/usr/bin/env bats

cd "${BATS_TEST_DIRNAME}"
export CLOE_ROOT="${BATS_TEST_DIRNAME}/../.."
load "${CLOE_ROOT}/tests/setup_bats.bash"
load "${CLOE_ROOT}/tests/setup_testname.bash"

require_program() {
if ! type $1 &>/dev/null; then
skip "required program not present: $1"
fi
}
load setup_bats
load setup_testname

@test "$(testname 'Expect success' 'test_lua01_include_json.lua' '224b2b67-1aaf-4ba2-855c-9bf986574e30')" {
cloe-engine run test_lua01_include_json.lua
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ cloe.schedule_test {
on = cloe.events.time("5s"),
run = function(z)
z:expect(true, "TEST-B has been a good test!")
z:assert
end
}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bats

cd "${BATS_TEST_DIRNAME}"
export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.."
load "${CLOE_ROOT}/tests/setup_bats.bash"
load "${CLOE_ROOT}/tests/setup_testname.bash"
load setup_bats
load setup_testname

@test "$(testname 'Expect check success' 'test_minimator_smoketest.json' 'c7a427e7-eb2b-4ae7-85ec-a35b7540d4aa')" {
cloe-engine check test_minimator_smoketest.json
@@ -14,13 +12,13 @@ load "${CLOE_ROOT}/tests/setup_testname.bash"
}

@test "$(testname 'Expect check/run success' 'test_minimator_smoketest.json [ts=5ms]' '57254185-5480-4859-b2a5-6c3a211a22e0')" {
local timestep_stack="${CLOE_ROOT}/tests/option_timestep_5.json"
local timestep_stack="option_timestep_5.json"
cloe-engine check test_minimator_smoketest.json "${timestep_stack}"
cloe-engine run test_minimator_smoketest.json "${timestep_stack}"
}

@test "$(testname 'Expect check/run success' 'test_minimator_smoketest.json [ts=60ms]' 'a0d4982f-8c02-4759-bc88-cc30a1ccbbf0')" {
local timestep_stack="${CLOE_ROOT}/tests/option_timestep_60.json"
local timestep_stack="option_timestep_60.json"
cloe-engine check test_minimator_smoketest.json "${timestep_stack}"
cloe-engine run test_minimator_smoketest.json "${timestep_stack}"
}
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"version": "4",
"include": [
"config_minimator_multi_agent_infinite.json",
"${CLOE_ROOT}/tests/triggers_multi_agent.json"
"triggers_multi_agent.json"
],
"server": {
"listen": false,
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bats

cd "${BATS_TEST_DIRNAME}"
export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.."
load "${CLOE_ROOT}/tests/setup_bats.bash"
load "${CLOE_ROOT}/tests/setup_testname.bash"
load setup_bats
load setup_testname

@test "$(testname 'Expect check success' 'test_virtue_missing_lanes_fail.json' 'd9072cc3-62f3-4f11-bf9e-b514fea67e4b')" {
cloe-engine check test_virtue_missing_lanes_fail.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4",
"include": [
"${CLOE_ROOT}/tests/config_nop_infinite.json"
"config_nop_infinite.json"
],
"defaults": {
"controllers": [
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "4",
"include": [
"${CLOE_ROOT}/plugins/minimator/tests/config_minimator_infinite.json"
"config_minimator_infinite.json"
],
"server": {
"listen": false

0 comments on commit bb50a5e

Please sign in to comment.