Skip to content

Commit

Permalink
(#14501) (#14500) Bump perfetto to v31.0
Browse files Browse the repository at this point in the history
* (#14500) Bump perfetto to v31.0

Perfetto switches to C++17 standard and already breaks the compilation
right now, so enable C++17 starting from this version and for all test
packages to avoid overhead

* Improve min compiler version support

* Fix c++17 detection on MSVC

* Fix std_cxx for test package
  • Loading branch information
miklelappo authored Dec 12, 2022
1 parent ae36beb commit e80195c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
4 changes: 3 additions & 1 deletion recipes/perfetto/all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(perfetto LANGUAGES CXX)
set(PUBLIC_HEADERS ${PERFETTO_SRC_DIR}/sdk/perfetto.h)

add_library(perfetto ${PERFETTO_SRC_DIR}/sdk/perfetto.cc)
target_compile_features(perfetto PRIVATE cxx_std_11)
target_compile_features(perfetto PRIVATE ${PERFETTO_CXX_STANDARD})
set_target_properties(perfetto PROPERTIES
PUBLIC_HEADER "${PUBLIC_HEADERS}"
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
Expand All @@ -27,6 +27,8 @@ if (MSVC)
target_compile_options(perfetto PRIVATE "/bigobj")
# The perfetto library needs permissive flag on MSVC
target_compile_options(perfetto PRIVATE "/permissive-")
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
target_compile_options(perfetto PRIVATE "/Zc:__cplusplus")
endif (MSVC)

include(GNUInstallDirs)
Expand Down
3 changes: 3 additions & 0 deletions recipes/perfetto/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"31.0":
url: "https://github.com/google/perfetto/archive/refs/tags/v31.0.tar.gz"
sha256: "544c68293590f53391ea4267d5a9b1a4594e1c8216fc5f5ce9d0f1227797922e"
"30.0":
url: "https://github.com/google/perfetto/archive/refs/tags/v30.0.tar.gz"
sha256: "d1883793a2adb2a4105fc083478bf781badd566d72da45caa99095b61f938a2e"
Expand Down
35 changes: 32 additions & 3 deletions recipes/perfetto/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
import os

Expand Down Expand Up @@ -30,6 +31,20 @@ class PerfettoConan(ConanFile):

short_paths = True

@property
def _minimum_cpp_standard(self):
return 11 if Version(self.version) < "31.0" else 17

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "15" if Version(self.version) < "31.0" else "16",
"msvc": "190",
"gcc": "7",
"clang": "3.3" if Version(self.version) < "31.0" else "5",
"apple-clang": "5.0" if Version(self.version) < "31.0" else "9.1",
}

def export_sources(self):
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)
export_conandata_patches(self)
Expand All @@ -46,10 +61,21 @@ def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < 7:
raise ConanInvalidConfiguration ("perfetto requires gcc >= 7")
if self.info.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)
check_min_cppstd(self, self._minimum_cpp_standard)

def loose_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

compiler = self.info.settings.compiler
min_version = self._minimum_compilers_version.get(str(compiler))
if min_version and loose_lt_semver(str(compiler.version), min_version):
raise ConanInvalidConfiguration(
f"{self.ref} requires {compiler} {min_version}. The current compiler is {compiler} {compiler.version}."
)

def source(self):
get(self, **self.conan_data["sources"][self.version],
Expand All @@ -59,6 +85,7 @@ def generate(self):
tc = CMakeToolchain(self)
tc.variables["PERFETTO_SRC_DIR"] = self.source_folder.replace("\\", "/")
tc.variables["PERFETTO_DISABLE_LOGGING"] = self.options.disable_logging
tc.variables["PERFETTO_CXX_STANDARD"] = f"cxx_std_{self._minimum_cpp_standard}"
tc.generate()

def build(self):
Expand All @@ -78,4 +105,6 @@ def package_info(self):
self.cpp_info.system_libs.append("pthread")
if self.settings.os == "Windows":
self.cpp_info.system_libs.append("ws2_32")
if is_msvc(self):
self.cpp_info.cxxflags.append("/Zc:__cplusplus")

6 changes: 5 additions & 1 deletion recipes/perfetto/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ project(test_package LANGUAGES CXX)
find_package(perfetto REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
if(perfetto_VERSION VERSION_LESS "31.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE perfetto::perfetto)
2 changes: 2 additions & 0 deletions recipes/perfetto/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"31.0":
folder: all
"30.0":
folder: all
"27.1":
Expand Down

0 comments on commit e80195c

Please sign in to comment.