Skip to content

Commit c69fc3c

Browse files
committed
vtd: Move vtd with dependencies into optional/vtd directory
1 parent 01d6138 commit c69fc3c

File tree

214 files changed

+655
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+655
-214
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
build/
33
**/build/
44
dist/docker/
5-
vendor/vtd/dl/
5+
optional/

Makefile.all

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Use WITHOUT_PKGS variable on the command line to opt-out of specific
1111
# packages:
1212
#
13-
# make WITHOUT_PKGS="plugins/vtd plugins/demo_printer" package
13+
# make WITHOUT_PKGS="plugins/demo_printer" package
1414
#
1515
# This extends the UNSELECT_PKGS variable. Set this variable directly
1616
# to override default omitted packages. Use make help to see which
@@ -21,7 +21,7 @@
2121
# Use WITH_PKGS variable on the command line to include specific by-default
2222
# unselected packages:
2323
#
24-
# make WITH_PKGS="plugins/vtd" package
24+
# make PLUGIN_PKGS= WITH_PKGS="plugins/minimator" package
2525
#
2626
# This extends the SELECT_PKGS variable. Set this variable directly
2727
# to explicitely specify exactly which packages are considered. Use make help

docs/develop/debugging-cloe.rst

+2-2

docs/reference/plugins/gndtruth_extractor.rst

+2-2

docs/reference/plugins/noisy_lane_sensor.rst

+5-5

docs/reference/plugins/noisy_object_sensor.rst

+5-5

optional/vtd/.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Dockerfile.ubuntu
2+
Makefile.docker
3+
vendor/vtd/dl
4+
setup.sh

optional/vtd/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
setup.sh
File renamed without changes.
File renamed without changes.

optional/vtd/Dockerfile.ubuntu

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# syntax = docker/dockerfile:1.4.3
2+
# Dockerfile
3+
#
4+
# This file acts as a Docker recipe for building cloe-plugin-vtd on Ubuntu.
5+
# It uses the base image from Cloe to reduce overhead.
6+
ARG IMAGE_BASE=cloe/cloe-engine
7+
ARG PROJECT_VERSION
8+
ARG UBUNTU_VERSION
9+
ARG IMAGE_VERSION=${PROJECT_VERSION}-ubuntu-${UBUNTU_VERSION}
10+
11+
# This is a work-around to not being able to use variables in RUN --mount=from:
12+
# If you want to use VTD in this image, you need to specify the Docker image
13+
# containing the distribution that can be mounted at /root/.conan/data/
14+
ARG VTD_IMAGE=scratch
15+
FROM ${VTD_IMAGE} as vtd
16+
WORKDIR /vtd
17+
18+
FROM ${IMAGE_BASE}:${IMAGE_VERSION} as stage-vendor
19+
WORKDIR /cloe-vtd
20+
ARG KEEP_SOURCES=0
21+
22+
# Download vendor packages:
23+
COPY vendor /cloe-vtd/vendor
24+
COPY Makefile /cloe-vtd
25+
COPY conanfile.py /cloe-vtd
26+
ARG VENDOR_TARGET="export-vendor download-vendor"
27+
RUN --mount=type=cache,target=/ccache \
28+
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
29+
--mount=type=bind,target=/root/.conan/data/vtd,source=/vtd,from=vtd,rw \
30+
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \
31+
conan search && \
32+
cat /root/.conan/data/vtd/2.2.0/cloe-restricted/stable/metadata.json && \
33+
make PROJECT_ROOT=/cloe ${VENDOR_TARGET} && \
34+
# Clean up:
35+
conan user --clean && \
36+
if [ ${KEEP_SOURCES} -eq 0 ]; then \
37+
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \
38+
conan remove \* -s -b -f; \
39+
else \
40+
conan remove \* -b -f; \
41+
fi
42+
43+
# Build cloe-plugin-vtd package:
44+
FROM stage-vendor as stage-package
45+
COPY . /cloe-vtd
46+
ARG PROJECT_VERSION=unknown
47+
ARG PACKAGE_TARGET="package"
48+
RUN --mount=type=cache,target=/ccache \
49+
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
50+
--mount=type=bind,target=/root/.conan/data/vtd,source=/vtd,from=vtd,rw \
51+
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \
52+
conan search && \
53+
echo "${PROJECT_VERSION}" > /cloe-vtd/VERSION && \
54+
make PROJECT_ROOT=/cloe ${PACKAGE_TARGET} && \
55+
# Clean up:
56+
conan user --clean && \
57+
if [ ${KEEP_SOURCES} -eq 0 ]; then \
58+
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \
59+
conan remove \* -s -b -f; \
60+
else \
61+
conan remove \* -b -f; \
62+
fi
63+
64+
# Build smoketest dependencies (in case they are different):
65+
FROM stage-package as stage-smoketest-deps
66+
RUN --mount=type=cache,target=/ccache \
67+
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
68+
--mount=type=bind,target=/root/.conan/data/vtd,source=/vtd,from=vtd,rw \
69+
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \
70+
make PROJECT_ROOT=/cloe smoketest-deps && \
71+
# Clean up:
72+
conan user --clean && \
73+
if [ ${KEEP_SOURCES} -eq 0 ]; then \
74+
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \
75+
conan remove \* -s -b -f; \
76+
else \
77+
conan remove \* -b -f; \
78+
fi

optional/vtd/Makefile

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
PROJECT_ROOT := ../..
2+
include ${PROJECT_ROOT}/Makefile.package
3+
4+
smoketest: smoketest-req
5+
6+
smoketest-req:
7+
@echo "VI_LIC_SERVER = $$VI_LIC_SERVER"
8+
test -n $$VI_LIC_SERVER
9+
10+
# -------------------------------------------------
11+
12+
SELECT_VENDOR := $(wildcard vendor/*)
13+
.PHONY: ${SELECT_VENDOR}
14+
vendor/osi-sensor-1.0.0-vtd2.2: vendor/vtd vendor/open-simulation-interface-3.0.1
15+
vendor/open-simulation-interface-3.0.1: vendor/protobuf-2.6.1
16+
vendor/open-simulation-interface-3.2.0: vendor/protobuf-2.6.1
17+
18+
REGEX_TARGET := 's/(-vendor|-select)?-each//'
19+
${SELECT_VENDOR}:
20+
${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET})
21+
22+
# Usage: $(call _make_target_rule, TARGET-NAME, MAKE-TARGET, HELP-DESCRIPTION, MAKE-ARGUMENTS)
23+
define _make_target_rule
24+
${1}:
25+
$(call print_header, "Proceeding to $(call unquote, ${3})")
26+
${MAKE} ${SUBMAKEFLAGS} PROJECT_ROOT=$(realpath ${PROJECT_ROOT}) ${4} ${2}
27+
endef
28+
29+
# Usage: $(call _make_target_rules, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY, PACKAGE-DIRS)
30+
define _make_target_rules
31+
help::
32+
$(call print_help_target, ${1}, ${2}, ${3})
33+
$(call _make_target_rule,${1},${1}-each,${2})
34+
${1}-each: ${4}
35+
endef
36+
37+
# Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY)
38+
define make_vendor_target
39+
$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR}))
40+
endef
41+
42+
help::
43+
$(call print_help_section, "Available vendor targets")
44+
45+
$(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]")
46+
$(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]")
47+
$(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]")

optional/vtd/Makefile.docker

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Usage: make [options] <target>
2+
#
3+
4+
PROJECT_ROOT := ../..
5+
PROJECT_VERSION := $(shell make --no-print-directory -C ${PROJECT_ROOT} -f Makefile.package info-version)
6+
7+
include ${PROJECT_ROOT}/Makefile.help
8+
9+
DOCKER := DOCKER_BUILDKIT=1 docker
10+
11+
DOCKER_NETWORK := \
12+
$(shell \
13+
if [ -n $$https_proxy ]; then \
14+
echo " --network=host"; \
15+
echo " --build-arg https_proxy=\"$$https_proxy\""; \
16+
echo " --build-arg http_proxy=\"$$http_proxy\""; \
17+
echo " --build-arg no_proxy=\"$$no_proxy\""; \
18+
fi \
19+
)
20+
21+
VTD_IMAGE := cloe/vtd-conan-package:2.2.0
22+
IMAGE_BASE := cloe/cloe-engine-with-vtd
23+
IMAGE_VERSION := ${PROJECT_VERSION}
24+
DOCKER_IMAGE := ${IMAGE_BASE}:${IMAGE_VERSION}
25+
DOCKER_CONTEXT := .
26+
27+
# Default build arguments
28+
VENDOR_TARGET :=
29+
PACKAGE_TARGET :=
30+
CONAN_PROFILE :=
31+
KEEP_SOURCES :=
32+
33+
DOCKER_BUILD_ARGS += ${DOCKER_NETWORK}
34+
DOCKER_BUILD_ARGS += --build-arg PROJECT_VERSION=${PROJECT_VERSION} --build-arg VTD_IMAGE=${VTD_IMAGE}
35+
36+
ifeq ($(shell [ -f setup.sh ] && echo "true"),true)
37+
DOCKER_BUILD_ARGS += --secret id=setup,src=setup.sh
38+
endif
39+
40+
ifneq (${CONAN_PROFILE},)
41+
DOCKER_BUILD_ARGS += --build-arg CONAN_PROFILE=${CONAN_PROFILE}
42+
endif
43+
44+
ifneq (${VENDOR_TARGET},)
45+
DOCKER_BUILD_ARGS += --build-arg VENDOR_TARGET=${VENDOR_TARGET}
46+
endif
47+
48+
ifneq (${PACKAGE_TARGET},)
49+
DOCKER_BUILD_ARGS += --build-arg PACKAGE_TARGET=${PACKAGE_TARGET}
50+
endif
51+
52+
ifeq (${KEEP_SOURCES},1)
53+
DOCKER_IMAGE := ${DOCKER_IMAGE}-with-src
54+
DOCKER_BUILD_ARGS += --build-arg KEEP_SOURCES=1
55+
endif
56+
57+
DOCKER_USER_ARGS :=
58+
DOCKER_ARGS := ${DOCKER_BUILD_ARGS} ${DOCKER_USER_ARGS}
59+
60+
DOCKER_RUN_ARGS=-it --rm --network=host -v $$(pwd)/setup.sh:/root/setup.sh -v conan-data-vtd:/root/.conan/data/vtd
61+
62+
.PHONY: help
63+
.SILENT: help
64+
.DEFAULT: help
65+
help:
66+
$(call print_help_usage)
67+
echo
68+
$(call print_help_section, "Available build targets")
69+
$(call print_help_target, all, "build all stable docker images: ubuntu-18.04 ubuntu-20.04 ubuntu-22.04")
70+
$(call print_help_target, ubuntu-VERSION, "build and test the Ubuntu VERSION (e.g. 20.04) image")
71+
$(call print_help_target, build-ubuntu-VERSION, "build the Ubuntu VERSION image")
72+
$(call print_help_target, test-ubuntu-VERSION, "test the Ubuntu VERSION image")
73+
$(call print_help_target, run-ubuntu-VERSION, "run the Ubuntu VERSION image")
74+
echo
75+
$(call print_help_section, "Available system targets")
76+
$(call print_help_target, release, "push Conan packages from current images to remote")
77+
$(call print_help_target, purge-current, "purge and prune current docker versions")
78+
$(call print_help_target, purge-all, "purge and prune all docker versions")
79+
echo
80+
$(call print_help_section, "Configuration")
81+
$(call print_help_define, IMAGE_BASE, ${IMAGE_BASE})
82+
$(call print_help_define, IMAGE_VERSION, ${IMAGE_VERSION})
83+
$(call print_help_define, DOCKER_CONTEXT, ${DOCKER_CONTEXT})
84+
$(call print_help_define_lines, DOCKER_ARGS, ${DOCKER_ARGS})
85+
86+
.PHONY: all ubuntu-%
87+
all: ubuntu-18.04 ubuntu-20.04 ubuntu-22.04
88+
ubuntu-%: | build-$@ test-$@
89+
90+
build-ubuntu-%: Dockerfile.ubuntu
91+
${DOCKER} build -f Dockerfile.ubuntu --build-arg UBUNTU_VERSION=$(subst build-ubuntu-,,$@) ${DOCKER_ARGS} -t ${DOCKER_IMAGE}-$(subst build-,,$@) ${DOCKER_CONTEXT}
92+
93+
.PHONY: test-ubuntu-%
94+
test-ubuntu-%:
95+
docker run ${DOCKER_RUN_ARGS} ${IMAGE_BASE}:${IMAGE_VERSION}-$(subst test-,,$@) bash -c "source /root/setup.sh && make PROJECT_ROOT=/cloe smoketest"
96+
97+
.PHONY: run-ubuntu-%
98+
run-ubuntu-%:
99+
docker run ${DOCKER_RUN_ARGS} ${IMAGE_BASE}:${IMAGE_VERSION}-$(subst run-,,$@) bash
100+
101+
release:
102+
@test -f setup.sh || echo 'Error: require setup.sh for user authentication'
103+
for dist in ubuntu-18.04 ubuntu-20.04 ubuntu-22.04; do \
104+
${DOCKER} run --rm \
105+
$(subst --build-arg,-e,${DOCKER_NETWORK}) \
106+
--mount "type=bind,source=$(CURDIR)/setup.sh,target=/root/setup.sh" \
107+
${DOCKER_IMAGE}-$${dist} \
108+
bash -c '. /root/setup.sh && conan upload --force --all -c "*"'; \
109+
done
110+
111+
.PHONY: purge-current purge-all
112+
purge-current:
113+
docker rmi $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep '${DOCKER_IMAGE}')
114+
115+
purge-all:
116+
docker rmi $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep '${IMAGE_BASE}:')

plugins/vtd/bin/vtd-launch renamed to optional/vtd/bin/vtd-launch

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def verify_runtime_contents(runtime_dir: Path) -> None:
179179
"-S",
180180
"--vtd-setup-cloe",
181181
type=click.Choice(
182+
# FIXME: Support .tgz AND directories!
182183
[Path(s).stem for s in os.listdir(os.getenv("VTD_SETUP_DIR"))],
183184
case_sensitive=False,
184185
),
File renamed without changes.
File renamed without changes.

plugins/vtd/conanfile.py renamed to optional/vtd/conanfile.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,26 @@ class CloeSimulatorVTD(ConanFile):
3737
_cmake = None
3838

3939
def set_version(self):
40-
version_file = Path(self.recipe_folder) / "../../VERSION"
41-
if version_file.exists():
42-
self.version = tools.load(version_file).strip()
43-
else:
44-
git = tools.Git(folder=self.recipe_folder)
45-
self.version = git.run("describe --dirty=-dirty")[1:]
40+
for version_path in ["VERSION", "../../VERSION"]:
41+
version_file = Path(self.recipe_folder) / version_path
42+
if version_file.exists():
43+
self.version = tools.load(version_file).strip()
44+
return
45+
git = tools.Git(folder=self.recipe_folder)
46+
self.version = git.run("describe --dirty=-dirty")[1:]
4647

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

52+
# Overrides, same as in the cloe conanfile.py:
53+
self.requires("protobuf/[>=3.9.1]", override=True)
54+
self.requires("zlib/1.2.12", override=True)
55+
self.requires("fmt/[~=8.1.1]", override=True)
56+
self.requires("inja/[~=3.3.0]", override=True)
57+
self.requires("nlohmann_json/[~=3.10.5]", override=True)
58+
self.requires("incbin/[~=0.88.0]@cloe/stable", override=True),
59+
5160
def build_requirements(self):
5261
if self.options.test:
5362
self.build_requires("gtest/[~1.10]")
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)