Skip to content

Commit

Permalink
[doxygen] Model libstdc++ compatibility
Browse files Browse the repository at this point in the history
* Add model of libstdc++ compatibility to ensure that binaries can not
  be used with older version of libstdc++ than what it was compiled for.
* Remove deletion of self.info.settings.compiler because this _is_
  relevant metadata for executables, as it inserts a dependency on a
  libstdc++ version at least what it was compiled with.
* Modify the dependency version impact on package id to use
  full_version_mode. This ensures that the dependency package id's don't
  impact doxygen's package id - only version changes in dependencies
  will impact doxygen's package id. This is necessary to allow doxygen
  built with gcc 10 to be identified as compatible with a gcc 12
  profile. Without this, compiler.version=12 propagates through the
  dependency tree and the package id of the doxygen package built with
  gcc 10 does not match appropriately and is not resolved as compatible.

Relates to conan-io#17034
  • Loading branch information
samuel-emrys committed Dec 30, 2023
1 parent a21ba9f commit c200bf6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions recipes/doxygen/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from conan import ConanFile
from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get
from conan.tools.microsoft import check_min_vs, is_msvc_static_runtime
from conan.tools.scm import Version
import os
import pathlib
import yaml

required_conan_version = ">=1.52.0"

Expand Down Expand Up @@ -45,6 +47,12 @@ def _minimum_compiler_version(self):
"msvc": "191",
}

@property
def _conan_home(self):
conan_home_env = "CONAN_USER_HOME" if Version(conan_version).major < 2 else "CONAN_HOME"
conan_home_dir = ".conan" if Version(conan_version).major < 2 else ".conan2"
return os.environ.get(conan_home_env, pathlib.Path(pathlib.Path.home(), conan_home_dir))

def export_sources(self):
export_conandata_patches(self)

Expand All @@ -59,8 +67,18 @@ def requirements(self):
# INFO: Doxygen uses upper case CMake variables to link/include IConv, so we are using patches for targets.
self.requires("libiconv/1.17")

def package_id(self):
self.info.requires.full_version_mode()

def compatibility(self):
return [{"settings": [("build_type", "Release")]}]
# is there a better way of reading all possible versions from settings.yml?
settings_yml_path = pathlib.Path(self._conan_home, "settings.yml")
with open(settings_yml_path, "r") as f:
settings_yml = yaml.safe_load(f)

compatible_versions = [{"settings": [("compiler.version", v), ("build_type", "Release")]}
for v in settings_yml["compiler"][str(self.settings.compiler)]["version"] if v <= Version(self.settings.compiler.version)]
return compatible_versions

def validate(self):
minimum_compiler_version = self._minimum_compiler_version.get(str(self.settings.compiler))
Expand Down

0 comments on commit c200bf6

Please sign in to comment.