Skip to content

Commit

Permalink
Merge branch 'develop2' into ci/gh-action-osx
Browse files Browse the repository at this point in the history
  • Loading branch information
czoido authored Oct 29, 2024
2 parents 138fb5b + 123193a commit e171227
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 22 deletions.
3 changes: 2 additions & 1 deletion conan/internal/api/install/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"SConsDeps": "conan.tools.scons",
"QbsDeps": "conan.tools.qbs",
"QbsProfile": "conan.tools.qbs",
"CPSDeps": "conan.tools.cps"
"CPSDeps": "conan.tools.cps",
"ROSEnv": "conan.tools.ros"
}


Expand Down
40 changes: 24 additions & 16 deletions conan/internal/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
Linux:
iOS:
version: &ios_version
["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3",
"11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4",
["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4", "9.0", "9.1", "9.2", "9.3",
"10.0", "10.1", "10.2", "10.3",
"11.0", "11.1", "11.2", "11.3", "11.4",
"12.0", "12.1", "12.2", "12.3", "12.4", "12.5",
"13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7",
"14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8",
"15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1",
"16.2", "16.3", "16.4", "16.5", "16.6", "17.0", "17.1", "17.2", "17.3", "17.4", "17.5",
"15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "15.7", "15.8",
"16.0", "16.1", "16.2", "16.3", "16.4", "16.5", "16.6", "16.7",
"17.0", "17.1", "17.2", "17.3", "17.4", "17.5", "17.6", "17.8",
"18.0", "18.1"]
sdk: ["iphoneos", "iphonesimulator"]
sdk_version: [null, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4",
Expand All @@ -28,20 +31,25 @@
"15.5", "16.0", "16.1", "16.2", "16.4", "17.0", "17.1", "17.2", "17.4", "17.5",
"18.0", "18.1"]
watchOS:
version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2",
"7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "8.0", "8.1", "8.3", "8.4",
"8.5", "8.6", "8.7", "9.0", "9.1", "9.2", "9.3", "9.4", "9.5", "9.6",
"10.0", "10.1", "10.2", "10.3", "10.4", "10.5", "11.0", "11.1"]
version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2", "6.3",
"7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6",
"8.0", "8.1", "8.3", "8.4", "8.5", "8.6", "8.7",
"9.0","9.1", "9.2", "9.3", "9.4", "9.5", "9.6",
"10.0", "10.1", "10.2", "10.3", "10.4", "10.5", "10.6",
"11.0", "11.1"]
sdk: ["watchos", "watchsimulator"]
sdk_version: [null, "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2",
"7.0", "7.1", "7.2", "7.4", "8.0", "8.0.1", "8.3", "8.5", "9.0", "9.1",
"9.4", "10.0", "10.1", "10.2", "10.4", "10.5", "11.0", "11.1"]
tvOS:
version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4",
"13.0", "13.2", "13.3", "13.4", "14.0", "14.2", "14.3", "14.4", "14.5",
"14.6", "14.7", "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6",
"16.0", "16.1", "16.2", "16.3", "16.4", "16.5", "16.6", "17.0", "17.1", "17.2", "17.3", "17.4",
"17.5", "18.0", "18.1"]
version: ["11.0", "11.1", "11.2", "11.3", "11.4",
"12.0", "12.1", "12.2", "12.3", "12.4",
"13.0", "13.2", "13.3", "13.4",
"14.0", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7",
"15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6",
"16.0", "16.1", "16.2", "16.3", "16.4", "16.5", "16.6",
"17.0", "17.1", "17.2", "17.3", "17.4", "17.5", "17.6",
"18.0", "18.1"]
sdk: ["appletvos", "appletvsimulator"]
sdk_version: [null, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4",
"13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0",
Expand All @@ -55,8 +63,8 @@
version: [null, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15",
"11.0", "11.1", "11.2", "11.3", "11.4", "11.5", "11.6", "11.7",
"12.0", "12.1", "12.2", "12.3", "12.4", "12.5", "12.6", "12.7",
"13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6",
"14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6",
"13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7",
"14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7",
"15.0", "15.1"]
sdk_version: [null, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1",
"12.3", "13.0", "13.1", "13.3", "14.0", "14.2", "14.4", "14.5",
Expand Down Expand Up @@ -100,7 +108,7 @@
"8", "8.1", "8.2", "8.3", "8.4", "8.5",
"9", "9.1", "9.2", "9.3", "9.4", "9.5",
"10", "10.1", "10.2", "10.3", "10.4", "10.5",
"11", "11.1", "11.2", "11.3", "11.4",
"11", "11.1", "11.2", "11.3", "11.4", "11.5",
"12", "12.1", "12.2", "12.3", "12.4",
"13", "13.1", "13.2", "13.3",
"14", "14.1", "14.2"]
Expand Down
1 change: 1 addition & 0 deletions conan/tools/ros/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from conan.tools.ros.rosenv import ROSEnv
48 changes: 48 additions & 0 deletions conan/tools/ros/rosenv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
from conan.api.output import Color
from conan.tools.env import VirtualBuildEnv, Environment
from conan.tools.env.environment import create_env_script
from conan.tools.files import save


class ROSEnv:
"""
Generator to serve as integration for Robot Operating System 2 development workspaces.
It generates a conanrosenv.sh file that when sources sets variables so the Conan
dependencies are found by CMake and the run environment is also set.
IMPORTANT: This generator should be used together with CMakeDeps and CMakeToolchain generators.
"""

def __init__(self, conanfile):
self._conanfile = conanfile
self.variables = {}
self._build_script_file = "conanrosenv-build.sh"
self._wrapper_script_file = "conanrosenv.sh"

def generate(self):
cmake_toolchain_path = os.path.join(self._conanfile.generators_folder,
"conan_toolchain.cmake")
self.variables["CMAKE_TOOLCHAIN_FILE"] = f"\"{cmake_toolchain_path}\""
build_type = self._conanfile.settings.get_safe("build_type")
if build_type:
self.variables["CMAKE_BUILD_TYPE"] = build_type

# Add ROS required variables to VirtualBuildEnv
rosbuildenv = Environment()
for k, v in self.variables.items():
rosbuildenv.define(k, v)
rosbuildenv.vars(self._conanfile, "build").save_script(self._build_script_file)

# Generate conanrosenv.sh script wrapper that calls conanbuild.sh and conanrun.sh
# TODO: Windows .bat/.ps1 files still not supported for the wrapper
conanbuild_path = os.path.join(self._conanfile.generators_folder, "conanbuild.sh")
conanrun_path = os.path.join(self._conanfile.generators_folder, "conanrun.sh")
rosenv_wrapper_content = [f". \"{conanbuild_path}\"", f". \"{conanrun_path}\""]
create_env_script(self._conanfile, "\n".join(rosenv_wrapper_content),
self._wrapper_script_file, None)

conanrosenv_path = os.path.join(self._conanfile.generators_folder, self._wrapper_script_file)
msg = f"Generated ROSEnv Conan file: {self._wrapper_script_file}\n" + \
f"Use 'source {conanrosenv_path}' to set the ROSEnv Conan before 'colcon build'"
self._conanfile.output.info(msg, fg=Color.CYAN)
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHECKSUM_DEPLOY = "checksum_deploy" # Only when v2
REVISIONS = "revisions" # Only when enabled in config, not by default look at server_launcher.py

__version__ = '2.9.0-dev'
__version__ = '2.10.0-dev'
10 changes: 6 additions & 4 deletions pyinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import sys

from conans import __version__
from conans.util.files import save


def _run_bin(pyinstaller_path):
Expand Down Expand Up @@ -115,17 +114,20 @@ def pyinstall(source_folder, onefile=False):
"--hidden-import=conan.tools.layout --hidden-import=conan.tools.premake "
"--hidden-import=conan.tools.qbs --hidden-import=conan.tools.scm "
"--hidden-import=conan.tools.system --hidden-import=conan.tools.system.package_manager")

if not os.path.exists(pyinstaller_path):
os.mkdir(pyinstaller_path)

if platform.system() != "Windows":
hidden += " --hidden-import=setuptools.msvc"
win_ver = ""
else:
win_ver_file = os.path.join(pyinstaller_path, 'windows-version-file')
content = _windows_version_file(__version__)
save(win_ver_file, content)
with open(win_ver_file, 'w') as file:
file.write(content)
win_ver = ["--version-file", win_ver_file]

if not os.path.exists(pyinstaller_path):
os.mkdir(pyinstaller_path)

if onefile:
distpath = os.path.join(pyinstaller_path, "dist", "conan")
Expand Down
Empty file.
77 changes: 77 additions & 0 deletions test/integration/tools/ros/test_rosenv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import os
import textwrap
import platform

import pytest

from conan.test.assets.genconanfile import GenConanfile
from conan.test.utils.tools import TestClient


@pytest.mark.skipif(platform.system() == "Windows", reason="Uses UNIX commands")
def test_rosenv():
"""
Test that the ROSEnv generator generates the environment files and that the environment variables are correctly set
"""
client = TestClient()
conanfile3 = textwrap.dedent('''
[requires]
[generators]
CMakeDeps
CMakeToolchain
ROSEnv
''')
client.save({
"conanfile3.txt": conanfile3
})

client.run("install conanfile3.txt --output-folder install/conan")
assert "Generated ROSEnv Conan file: conanrosenv.sh" in client.out
install_folder = os.path.join(client.current_folder, "install", "conan")
conanrosenv_path = os.path.join(install_folder, "conanrosenv.sh")
assert os.path.exists(conanrosenv_path)
conanrosenvbuild_path = os.path.join(install_folder, "conanrosenv-build.sh")
assert os.path.exists(conanrosenvbuild_path)
client.run_command(f". \"{conanrosenv_path}\" && env")
toolchain_path = os.path.join(client.current_folder, "install", "conan", "conan_toolchain.cmake")
assert f"CMAKE_TOOLCHAIN_FILE=\"{toolchain_path}\"" in client.out
assert "CMAKE_BUILD_TYPE=Release" in client.out


@pytest.mark.skipif(platform.system() == "Windows", reason="Uses UNIX commands")
def test_rosenv_shared_libraries():
"""
Test that the library paths env vars are set up correctly so that the executables built with
colcon can found the shared libraries of conan packages
"""
client = TestClient()
c1 = GenConanfile("lib1", "1.0").with_shared_option(False).with_package_file("lib/lib1", "lib-content")
c2 = GenConanfile("lib2", "1.0").with_shared_option(False).with_requirement("lib1/1.0").with_package_file("lib/lib2", "lib-content")
c3 = textwrap.dedent('''
[requires]
lib2/1.0
[generators]
CMakeDeps
CMakeToolchain
ROSEnv
''')
client.save({
"conanfile1.py": c1,
"conanfile2.py": c2,
"conanfile3.txt": c3
})

client.run("create conanfile1.py -o *:shared=True")
client.run("create conanfile2.py -o *:shared=True")
client.run("install conanfile3.txt -o *:shared=True --output-folder install/conan")
conanrosenv_path = os.path.join(client.current_folder, "install", "conan", "conanrosenv.sh")
client.run_command(f". \"{conanrosenv_path}\" && env")
environment_content = client.out
client.run(
"cache path lib1/1.0#58723f478a96866dcbd9456d8eefd7c4:1744785cb24e3bdca70e27041dc5abd20476f947")
lib1_lib_path = os.path.join(client.out.strip(), "lib")
assert lib1_lib_path in environment_content
client.run(
"cache path lib2/1.0#4b7a6063ba107d770458ce10385beb52:5c3c2e56259489f7ffbc8e494921eda4b747ef21")
lib2_lib_path = os.path.join(client.out.strip(), "lib")
assert lib2_lib_path in environment_content

0 comments on commit e171227

Please sign in to comment.