Commit 22981e9b authored by Raghunandan Netrapalli Madhusudhan's avatar Raghunandan Netrapalli Madhusudhan Committed by Reinhard Biegel
Browse files

feat(CI): Provide protobuf via conan


Also-by: Reinhard Biegel's avatarReinhard Biegel <reinhard.biegel@in-tech.com>
parent 0dd9fc13
Pipeline #4148 passed with stage
in 0 seconds
################################################################################
# Copyright (c) 2021 ITK Engineering GmbH
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
################################################################################
################################################################################
# Install file for building ThirdParty libraries for OpenPASS with Conan
################################################################################
[requires]
OSI/3.3.1@openpass/testing
FMILibrary/2.0.3@openpass/testing
[generators]
cmake
......@@ -13,7 +13,8 @@
# Install file for building OSI with Conan
################################################################################
from conans import ConanFile, CMake, tools
from os import environ
from conans import ConanFile, CMake, tools, errors
class OsiConan(ConanFile):
name = "OSI"
......@@ -26,28 +27,26 @@ class OsiConan(ConanFile):
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": True, "fPIC": True, "protobuf:shared": True}
generators = "cmake"
#requires = "protobuf/3.20.0" this should be used when distinguishing static and shared protobuf is possible via conan
def configure(self):
if self.settings.os == "Linux": #For Windows it is required that Protobuf is installed via pacman or pip in MSYS2
self.generators = "cmake_find_package", "cmake_paths"
if not environ.get("WORKSPACE"):
raise errors.ConanInvalidConfiguration("WORKSPACE environment variable has to be set")
def source(self):
git = tools.Git(folder="osi3")
git.clone("https://github.com/OpenSimulationInterface/open-simulation-interface.git", "v3.3.1", "--recursive")
if self.settings.os == "Linux":
tools.replace_in_file("osi3/CMakeLists.txt",
"project(open_simulation_interface)",
'project(open_simulation_interface)\n' +
'include(${CMAKE_BINARY_DIR}/conan_paths.cmake)\n' +
'include_directories(${CONAN_PROTOBUF_ROOT}/include)\n')
self.run("find . -maxdepth 1 -name '*.proto' -exec sed -i '2i option cc_enable_arenas = true;' {} \;", win_bash=True, cwd="osi3")
def build(self):
cmake = CMake(self)
cmake.configure(source_folder="osi3",
defs={"CMAKE_INSTALL_PREFIX":"./temp-deploy"})
defs={
"CMAKE_INSTALL_PREFIX": "./temp-deploy",
"CMAKE_PREFIX_PATH": f"{environ.get('WORKSPACE')}/deps/protobuf-shared"
})
cmake.build()
cmake.install()
......
......@@ -2,6 +2,7 @@
################################################################################
# Copyright (c) 2021 in-tech GmbH
# 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
......@@ -23,7 +24,7 @@ if [ ! -d repo ]; then
fi
# wipe build directories and pyOpenPASS results
rm -rf artifacts build build-fmi-library build-osi
rm -rf artifacts build build-fmi-library build-osi deps
rm -f repo/sim/tests/endToEndTests/pyOpenPASS/result_*.xml
# prepare
......
......@@ -2,6 +2,7 @@
################################################################################
# Copyright (c) 2021 ITK Engineering GmbH
# 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
......@@ -17,25 +18,31 @@
MYDIR="$(dirname "$(readlink -f $0)")"
cd "$MYDIR/../../.."
WORKSPACE_ROOT="$PWD"
REPO_ROOT="$PWD"
# requires by OSI conan build
if [[ -z "$WORKSPACE" ]]; then
export WORKSPACE="$REPO_ROOT/.."
fi
# Set python command depending on OS
if [[ "${OSTYPE}" = "msys" ]]; then
PYTHON_COMMAND="${PYTHON_WINDOWS_EXE}"
else
PYTHON_COMMAND=python3
fi
fi
# Detect system settings and create a conan profile
"$PYTHON_COMMAND" -m conans.conan profile new default --detect
"$PYTHON_COMMAND" -m conans.conan profile new default --detect --force
"$PYTHON_COMMAND" -m conans.conan profile update settings.compiler.libcxx=libstdc++11 default
# export conan recipes of thirdParty dependencies to conans local cache
"$PYTHON_COMMAND" -m conans.conan export $WORKSPACE_ROOT/utils/ci/conan/recipe/osi openpass/testing
"$PYTHON_COMMAND" -m conans.conan export $WORKSPACE_ROOT/utils/ci/conan/recipe/fmi openpass/testing
"$PYTHON_COMMAND" -m conans.conan export $REPO_ROOT/utils/ci/conan/recipe/osi openpass/testing
"$PYTHON_COMMAND" -m conans.conan export $REPO_ROOT/utils/ci/conan/recipe/fmi openpass/testing
# prepare a build directory
mkdir -p build-thirdParty && cd build-thirdParty
"$PYTHON_COMMAND" -m conans.conan install FMILibrary/2.0.3@openpass/testing --build --install-folder="$REPO_ROOT/../deps" -g deploy
"$PYTHON_COMMAND" -m conans.conan install protobuf/3.20.0@ --build --install-folder="$REPO_ROOT/../deps" -g deploy -g cmake_paths -o protobuf:shared=True
mv $REPO_ROOT/../deps/protobuf $REPO_ROOT/../deps/protobuf-shared # rename the deployed protobuf folder as protobuf-shared (to distinguish between protobuf static and shared)
"$PYTHON_COMMAND" -m conans.conan install protobuf/3.20.0@ --build --install-folder="$REPO_ROOT/../deps" -g deploy -o protobuf:shared=False
"$PYTHON_COMMAND" -m conans.conan install OSI/3.3.1@openpass/testing --build --install-folder="$REPO_ROOT/../deps" -g deploy
# (build and) install thirdParty dependencies to conans local cache and deploy them
"$PYTHON_COMMAND" -m conans.conan install $WORKSPACE_ROOT/utils/ci/conan/install_file/thirdParty --build --install-folder="$WORKSPACE_ROOT/../deps/" -g deploy
......@@ -2,6 +2,7 @@
################################################################################
# Copyright (c) 2021 in-tech GmbH
# 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
......@@ -28,6 +29,8 @@ cd "$MYDIR/../../../../build" || exit 1
DEPS=(
"$PWD/../deps/FMILibrary"
"$PWD/../deps/OSI"
"$PWD/../deps/protobuf"
"$PWD/../deps/protobuf-shared"
)
# preparations for building on Windows/MSYS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment