Skip to content

Commit 14be6ca

Browse files
committed
cli: Source "cloe_launch_env.sh" if generated
This can be generated from within the `generate()` method in a Conan profile. A base Conan profile is provided by cloe-launch, called `cloe-launch-profile`, with the same version as cloe-launch. This can be used as a base class for profiles that want to make easy use of its methods.
1 parent 2e46a23 commit 14be6ca

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ deploy-cli:
7676
$(call print_header, "Deploying cloe-launch binary with pip...")
7777
${MAKE} -C cli install
7878

79+
export-cli:
80+
${MAKE} -C cli conan-profile
81+
7982
docker-test:
8083
$(call print_header, "Building ubuntu-18.04 Docker image...")
8184
${MAKE} -C dist/docker ubuntu-18.04
@@ -98,7 +101,7 @@ doxygen:
98101
mkdir -p ${BUILD_DIR}/doxygen
99102
doxygen Doxyfile
100103

101-
smoketest-deps: smoketest-deps-select
104+
smoketest-deps: | export-cli smoketest-deps-select
102105
# Call this target with WITH_VTD=1 to include VTD binding tests.
103106

104107
smoketest: smoketest-select

cli/Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ help:
2222
echo " install to install cloe-launch locally"
2323
echo " editable to install cloe-launch locally in editable mode"
2424

25-
.PHONY: install editable
26-
install:
25+
.PHONY: install editable conan-profile
26+
install: conan-profile
2727
command -v ${PIP} >/dev/null 2>&1
2828
mv pyproject.toml pyproject.toml.bak
2929
${PIP} install ${PIP_INSTALL_ARGS} . || ( \
@@ -32,11 +32,14 @@ install:
3232
)
3333
mv pyproject.toml.bak pyproject.toml
3434

35-
editable:
35+
editable: conan-profile
3636
command -v ${PIP} >/dev/null 2>&1
3737
mv pyproject.toml pyproject.toml.bak
3838
${PIP} install -e ${PIP_INSTALL_ARGS} . || ( \
3939
mv pyproject.toml.bak pyproject.toml; \
4040
exit 1; \
4141
)
4242
mv pyproject.toml.bak pyproject.toml
43+
44+
conan-profile:
45+
conan export .

cli/cloe_launch/exec.py

+3
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ def _read_conan_env(self) -> Environment:
421421
self.runtime_dir / "activate_run.sh",
422422
self.runtime_dir / "activate.sh",
423423
]
424+
cloe_launch_env = self.runtime_dir / "cloe_launch_env.sh"
425+
if cloe_launch_env.exists():
426+
env_paths.insert(0, cloe_launch_env)
424427
preserve = None if not self.preserve_env else list(os.environ.keys())
425428
return Environment(env_paths, preserve=preserve)
426429

cli/conanfile.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from conans import ConanFile, tools
2+
from conan.tools.env import Environment
3+
from pathlib import Path
4+
5+
class Base(object):
6+
settings = "os", "compiler", "build_type", "arch"
7+
generators = "virtualenv", "virtualrunenv"
8+
9+
def generate(self):
10+
if "cloe_launch_env" not in dir(self):
11+
return
12+
13+
env = Environment()
14+
for k, v in self.cloe_launch_env.items():
15+
env.define(k, str(v))
16+
env.vars(self).save_script("cloe_launch_env")
17+
18+
def project_version(self, version_path):
19+
if version_path:
20+
version_file = Path(self.recipe_folder) / version_path
21+
if version_file.exists():
22+
return tools.load(version_file).strip()
23+
git = tools.Git(folder=self.recipe_folder)
24+
return git.run("describe --dirty=-dirty")[1:]
25+
26+
27+
class CloeLaunchProfile(ConanFile):
28+
name = "cloe-launch-profile"
29+
license = "Apache-2.0"
30+
url = "https://github.com/eclipse/cloe"
31+
description = "Provides base class for cloe-launch profiles"
32+
user = "cloe"
33+
channel = "develop"
34+
35+
def set_version(self):
36+
for line in tools.load("setup.py").split("\n"):
37+
if not line.strip().startswith("version="):
38+
continue
39+
self.version = line.strip().split("=")[1].strip('",')
40+
return
41+
raise Exception("cannot find cloe-launch version")

0 commit comments

Comments
 (0)