Skip to content

Commit

Permalink
esmini: Move from optional to base
Browse files Browse the repository at this point in the history
The optional directory contains projects that are hard to build. ESMini does not
fall into this category, since the sources are freely available.

This commit does the following:

- Move optional/esmini to plugins/esmini
- Move optional/osi to osi
- Replace Conan recipe for vendor/esmini and vendor/esmini-data
- Replace Conan recipe for vendor/open-simulation-interface
- Patch the esmini and osi Cloe libraries for compatibility with new open-simulation-interface.
  In particular, the generated headers are now namespaced with osi3/
- Fix several findings in esmini and osi Cloe libraries highlighted by clang-tidy.

The vendored libraries are written in a manner similar to how it is done in
the Conan-Center-Index.
  • Loading branch information
cassava committed Mar 27, 2024
1 parent ddff0cb commit c16fab7
Show file tree
Hide file tree
Showing 90 changed files with 3,153 additions and 1,283 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-cloe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- "cloe-normal"
package_target:
# 1. Build each test configuration in Conan cache and run all tests
- "export smoketest-deps smoketest"
- "export export-vendor smoketest-deps smoketest"
env:
CONAN_NON_INTERACTIVE: "yes"
DEBIAN_FRONTEND: noninteractive
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ setup.sh
# Standard out-of-source build
build/

# Vendored Conan recipes sometimes extract fetched sources
vendor/**/src/

# Documentation
docs/_build/
docs/_extra/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ WORKDIR /cloe
SHELL ["/bin/bash", "-c"]

ARG PROJECT_VERSION=unknown
ARG PACKAGE_TARGET="export smoketest-deps"
ARG PACKAGE_TARGET="export-vendor export smoketest-deps"
ARG KEEP_SOURCES=0

COPY . /cloe
Expand Down
28 changes: 17 additions & 11 deletions Makefile.all
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SUBMAKEFLAGS :=

META_PKG := cloe
PLUGIN_PKGS := $(wildcard plugins/*)
ALL_PKGS := fable runtime models oak engine ${PLUGIN_PKGS} ${META_PKG}
ALL_PKGS := fable runtime models oak osi engine ${PLUGIN_PKGS} ${META_PKG}
WITHOUT_PKGS :=
UNSELECT_PKGS := ${WITHOUT_PKGS}
WITH_PKGS :=
Expand All @@ -48,7 +48,7 @@ SELECT_PKGS := $(call uniq, $(filter-out ${UNSELECT_PKGS}, ${ALL_PKGS}) ${WITH_P
##
## Functions analogously to normal package selection.
##
ALL_VENDOR :=
ALL_VENDOR := $(wildcard vendor/*)
WITHOUT_VENDOR :=
UNSELECT_VENDOR := ${WITHOUT_VENDOR}
WITH_VENDOR :=
Expand All @@ -61,7 +61,13 @@ runtime: fable
models: runtime
oak: runtime
engine: models oak
osi: runtime models vendor/open-simulation-interface
${PLUGIN_PKGS}: runtime models
plugins/esmini: vendor/open-simulation-interface vendor/esmini

vendor/esmini: vendor/open-simulation-interface
vendor/esmini-data:
vendor/open-simulation-interface:

## BUILD_POLICY
## Usage: make BUILD_POLICY="missing"
Expand Down Expand Up @@ -119,9 +125,9 @@ ${META_PKG}:
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
Expand All @@ -141,9 +147,9 @@ endef
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 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::
echo
Expand Down Expand Up @@ -179,15 +185,15 @@ $(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}")
$(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}")
$(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})
$(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR})
$(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR})
$(call print_help_define_lines, UNSELECT_PKGS, ${UNSELECT_PKGS})
$(call print_help_define_lines, SELECT_PKGS, ${SELECT_PKGS})
echo
Expand Down
203 changes: 39 additions & 164 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# 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
Expand All @@ -18,56 +16,22 @@ 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 = {
"shared": [True, False],
"fPIC": [True, False],
"fable_allow_comments": [True, False],
"engine_server": [True, False],
"engine_lrdb": [True, False]
"with_vtd": [True, False],
"with_engine": [True, False],

# Doesn't affect package ID:
"pedantic": [True, False],
}
default_options = {
"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",
"with_vtd": False,
"with_engine": True,

"fable/examples/*",
"pedantic": True,

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

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

"CMakelists.txt"
]
"cloe-engine:server": True,
}
no_copy_source = True

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

def requirements(self):
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)
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
1 change: 0 additions & 1 deletion optional/esmini/.gitignore

This file was deleted.

43 changes: 0 additions & 43 deletions optional/esmini/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions optional/esmini/README.md

This file was deleted.

Loading

0 comments on commit c16fab7

Please sign in to comment.