Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#14500) Bump perfetto to v31.0 #14501

Merged
merged 4 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")

2 changes: 1 addition & 1 deletion recipes/perfetto/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ 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)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we condition this based on the version? Otherwise if you're stuck on an old compiler which doesn't support GCC 17 you wont be able to consume this package anymore. You should at least be able to consume the older versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

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