Skip to content

Commit e401c0f

Browse files
committed
tests: Add (disabled) test combining cloe with external package
1 parent a249482 commit e401c0f

File tree

8 files changed

+243
-1
lines changed

8 files changed

+243
-1
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,26 @@ both. Unfortunately, this is only fixed in Conan 2.
275275
The use-case for build-all is to build everything in editable mode.
276276
For that, use the new super-build instead of building individual packages.
277277
278+
### Superbuild 'cloe' package "provides the same functionality" error
279+
280+
When using the `cloe` super-build package in tests, you may run into the
281+
following error:
282+
283+
ERROR: At least two recipes provides the same functionality:
284+
- 'fable' provided by 'cloe/0.25.0@cloe/develop', 'fable/0.25.0@cloe/develop'
285+
- 'cloe-runtime' provided by 'cloe/0.25.0@cloe/develop', 'cloe-runtime/0.25.0@cloe/develop'
286+
- 'cloe-models' provided by 'cloe/0.25.0@cloe/develop', 'cloe-models/0.25.0@cloe/develop'
287+
288+
This problem occurs when both `cloe` and one of the packages that `cloe`
289+
*provides* are pulled in as dependencies. Ideally, Conan should then
290+
use `cloe` instead, but it would appear that Conan, at least in v1,
291+
is unable to do this.
292+
293+
The `cloe` super-build package is primarily used for development purposes,
294+
and until these kinks can be worked out, you should use the set of
295+
individual packages for production.
296+
297+
278298
[1]: https://conan.io
279299
[2]: https://docs.microsoft.com/en-us/windows/wsl/about
280300
[3]: https://ubuntu.com

conanfile.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ class Cloe(ConanFile):
1515
name = "cloe"
1616
license = "Apache-2.0"
1717
url = "https://github.com/eclipse/cloe"
18-
description = "Closed-loop automated driving simulation environment"
18+
description = """
19+
Development package containing most cloe-* packages from the primary Eclipse repository.
20+
21+
WARNING:
22+
This package "provides" the cloe-* packages it contains,
23+
but unfortunately this is NOT compatible with other packages that
24+
require these. This is a severe limitation of Conan (v1).
25+
26+
As such, this package should only be used for development purposes.
27+
"""
1928
topics = ["simulation"]
2029
settings = "os", "compiler", "build_type", "arch"
2130
provides = (

optional/example_external/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR)
2+
3+
project(cloe_plugin_example_external LANGUAGES CXX)
4+
5+
find_package(cloe-runtime REQUIRED QUIET)
6+
find_package(cloe-models REQUIRED QUIET)
7+
8+
include(CloePluginSetup)
9+
cloe_add_plugin(
10+
TARGET controller_example_external
11+
SOURCES
12+
src/external_printer.cpp
13+
LINK_LIBRARIES
14+
cloe::runtime
15+
cloe::models
16+
)

optional/example_external/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.package
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# mypy: ignore-errors
2+
# pylint: skip-file
3+
4+
from pathlib import Path
5+
6+
from conan import ConanFile
7+
from conan.tools import cmake, files, scm
8+
9+
required_conan_version = ">=1.52.0"
10+
11+
12+
class CloeControllerExampleExternal(ConanFile):
13+
"""
14+
This package is used for internal tests, and is not part of the
15+
cloe package distribution. This is used for testing combining
16+
external packages and cloe with Conan.
17+
"""
18+
19+
name = "cloe-plugin-example-external"
20+
url = "https://github.com/eclipse/cloe"
21+
description = "Cloe controller plugin mocks used for testing integration"
22+
license = "Apache-2.0"
23+
settings = "os", "compiler", "build_type", "arch"
24+
generators = "CMakeDeps", "CMakeToolchain"
25+
no_copy_source = True
26+
exports_sources = [
27+
"src/*",
28+
"CMakeLists.txt",
29+
]
30+
31+
def set_version(self):
32+
version_file = Path(self.recipe_folder) / "../../VERSION"
33+
if version_file.exists():
34+
self.version = files.load(self, version_file).strip()
35+
else:
36+
git = scm.Git(self, self.recipe_folder)
37+
self.version = git.run("describe --dirty=-dirty")[1:]
38+
39+
def requirements(self):
40+
self.requires(f"cloe-runtime/{self.version}@cloe/develop")
41+
self.requires(f"cloe-models/{self.version}@cloe/develop")
42+
43+
def layout(self):
44+
cmake.cmake_layout(self)
45+
46+
def build(self):
47+
cm = cmake.CMake(self)
48+
if self.should_configure:
49+
cm.configure()
50+
if self.should_build:
51+
cm.build()
52+
53+
def package(self):
54+
cm = cmake.CMake(self)
55+
if self.should_install:
56+
cm.install()
57+
58+
def package_info(self):
59+
self.cpp_info.set_property("cmake_find_mode", "both")
60+
self.cpp_info.set_property("cmake_file_name", self.name)
61+
self.cpp_info.set_property("pkg_config_name", self.name)
62+
63+
if not self.in_local_cache: # editable mode
64+
libdir = Path(self.build_folder) / "lib"
65+
self.runenv_info.append_path("LD_LIBRARY_PATH", str(libdir))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright 2024 Robert Bosch GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
*/
18+
/**
19+
* \file external_printer.cpp
20+
*/
21+
22+
#include <cassert> // for assert
23+
24+
#include <cloe/component/object_sensor.hpp> // for ObjectSensor
25+
#include <cloe/controller.hpp> // for Controller, ControllerFactory, ...
26+
#include <cloe/models.hpp> // for CloeComponent
27+
#include <cloe/plugin.hpp> // for EXPORT_CLOE_PLUGIN
28+
#include <cloe/sync.hpp> // for Sync
29+
#include <cloe/vehicle.hpp> // for Vehicle
30+
31+
namespace external {
32+
33+
struct ExternalPrinterConf : public cloe::Confable {
34+
CONFABLE_FRIENDS(ExternalPrinterConf)
35+
};
36+
37+
class ExternalPrinter : public cloe::Controller {
38+
public:
39+
using Controller::Controller;
40+
41+
void reset() override {
42+
// Nothing to do here.
43+
}
44+
45+
void abort() override {
46+
// Nothing to do here.
47+
}
48+
49+
cloe::Duration process(const cloe::Sync& sync) override {
50+
assert(veh_ != nullptr);
51+
auto log = this->logger();
52+
log->info("External Step {} @ {}", sync.step(), sync.time().count());
53+
if (veh_->has(cloe::CloeComponent::DEFAULT_WORLD_SENSOR)) {
54+
auto sensor = veh_->get<cloe::ObjectSensor>(cloe::CloeComponent::DEFAULT_WORLD_SENSOR);
55+
auto& objs = sensor->sensed_objects();
56+
log->info(" {} Objects", objs.size());
57+
for (auto o : objs) {
58+
log->info(" id={} pos=({:3f}, {:3f}, {:3f})", o->id, o->pose.translation()(0),
59+
o->pose.translation()(1), o->pose.translation()(2));
60+
}
61+
}
62+
return sync.time();
63+
}
64+
};
65+
66+
DEFINE_CONTROLLER_FACTORY(ExternalPrinterFactory, ExternalPrinterConf, "external_printer",
67+
"print a lot of information")
68+
69+
std::unique_ptr<cloe::Controller> ExternalPrinterFactory::make(const cloe::Conf&) const {
70+
return std::make_unique<ExternalPrinter>(this->name());
71+
}
72+
73+
} // namespace external
74+
75+
// Register factory as plugin entrypoint
76+
EXPORT_CLOE_PLUGIN(external::ExternalPrinterFactory)

tests/test_conanfile_external.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# mypy: ignore-errors
2+
# pylint: skip-file
3+
#
4+
# NOTE:
5+
# This filename needs to not match ^conanfile_*.py$ in order to not be
6+
# used in the automatic smoketest test suite.
7+
8+
from pathlib import Path
9+
10+
from conan import ConanFile
11+
from conan.tools import files, scm
12+
13+
required_conan_version = ">=1.52.0"
14+
15+
16+
class CloeSuperbuildWithExternalTest(ConanFile):
17+
"""
18+
This recipe shows how to combine the cloe package -- which provides
19+
cloe-runtime, etc. -- with packages that depend on these provided
20+
packages.
21+
22+
NOTE:
23+
This test is disabled until the use-case works with Conan.
24+
See "Known Issues" in the README.md of the repository.
25+
"""
26+
27+
python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop"
28+
python_requires_extend = "cloe-launch-profile.Base"
29+
30+
name = "cloe-superbuild-test"
31+
license = "Apache-2.0"
32+
url = "https://github.com/eclipse/cloe"
33+
description = "Closed-loop automated driving simulation environment"
34+
topics = ["simulation"]
35+
settings = "os", "compiler", "build_type", "arch"
36+
37+
@property
38+
def cloe_launch_env(self):
39+
return {
40+
"CLOE_ENGINE_WITH_SERVER": "1" if self.options["cloe"].engine_server else "0",
41+
"CLOE_LOG_LEVEL": "debug",
42+
"CLOE_STRICT_MODE": "1",
43+
"CLOE_WRITE_OUTPUT": "0",
44+
"CLOE_ROOT": Path(self.recipe_folder) / "..",
45+
}
46+
47+
def set_version(self):
48+
self.version = self.project_version("../VERSION")
49+
50+
def requirements(self):
51+
self.requires(f"cloe/{self.version}@cloe/develop")
52+
self.requires(f"cloe-plugin-example-external/{self.version}@cloe/develop")
53+
self.requires("esmini-data/2.37.4@cloe/stable")
54+
self.requires("fmt/9.1.0", override=True)

0 commit comments

Comments
 (0)