[DO-971] ffmpeg recipe with requirements (!9)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/9
This commit is contained in:
16
recipes/cpuinfo/all/conandata.yml
Normal file
16
recipes/cpuinfo/all/conandata.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
sources:
|
||||
"cci.20231129":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/9d809924011af8ff49dadbda1499dc5193f1659c.tar.gz"
|
||||
sha256: "0d769b7e3cc7d16205f4cc8988f869910db19f2d274db005c1ed74e961936d34"
|
||||
"cci.20230118":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/3dc310302210c1891ffcfb12ae67b11a3ad3a150.tar.gz"
|
||||
sha256: "f2f4df6d2b01036f36c5e372954e536881cdd59f5c2461c67aa0a92c6d755c61"
|
||||
"cci.20220618":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/082deffc80ce517f81dc2f3aebe6ba671fcd09c9.tar.gz"
|
||||
sha256: "4379348ec3127b37e854a0a66f85ea1d3c606e5f3a6dce235dc9c69ce663c026"
|
||||
"cci.20220228":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/6288930068efc8dff4f3c0b95f062fc5ddceba04.tar.gz"
|
||||
sha256: "9e9e937b3569320d23d8b1c8c26ed3603affe55c3e4a3e49622e8a2c6d6e1696"
|
||||
"cci.20201217":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.tar.gz"
|
||||
sha256: "f3c16d5d393d6d1fa6b6ed8621dd0a535552df9bc88cbba739375dde38a93142"
|
||||
113
recipes/cpuinfo/all/conanfile.py
Normal file
113
recipes/cpuinfo/all/conanfile.py
Normal file
@@ -0,0 +1,113 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||
from conan.tools.files import copy, get, replace_in_file, rmdir
|
||||
from conan.tools.microsoft import is_msvc
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class CpuinfoConan(ConanFile):
|
||||
name = "cpuinfo"
|
||||
description = "cpuinfo is a library to detect essential for performance " \
|
||||
"optimization information about host CPU."
|
||||
license = "BSD-2-Clause"
|
||||
topics = ("cpu", "cpuid", "cpu-cache", "cpu-model", "instruction-set", "cpu-topology")
|
||||
homepage = "https://github.com/pytorch/cpuinfo"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"log_level": ["default", "debug", "info", "warning", "error", "fatal", "none"],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"log_level": "default",
|
||||
}
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def configure(self):
|
||||
if is_msvc(self):
|
||||
# Only static for msvc
|
||||
# Injecting CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is not sufficient since there are global symbols
|
||||
del self.options.shared
|
||||
self.package_type = "static-library"
|
||||
if self.options.get_safe("shared"):
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
# cpuinfo
|
||||
tc.cache_variables["CPUINFO_LIBRARY_TYPE"] = "default"
|
||||
tc.cache_variables["CPUINFO_RUNTIME_TYPE"] = "default"
|
||||
tc.cache_variables["CPUINFO_LOG_LEVEL"] = self.options.log_level
|
||||
tc.variables["CPUINFO_BUILD_TOOLS"] = False
|
||||
tc.variables["CPUINFO_BUILD_UNIT_TESTS"] = False
|
||||
tc.variables["CPUINFO_BUILD_MOCK_TESTS"] = False
|
||||
tc.variables["CPUINFO_BUILD_BENCHMARKS"] = False
|
||||
# clog (always static)
|
||||
tc.cache_variables["CLOG_RUNTIME_TYPE"] = "default"
|
||||
tc.variables["CLOG_BUILD_TESTS"] = False
|
||||
tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True)
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
cmakelists = os.path.join(self.source_folder, "CMakeLists.txt")
|
||||
|
||||
# Fix install dir of dll
|
||||
replace_in_file(
|
||||
self,
|
||||
cmakelists,
|
||||
"LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}",
|
||||
"LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}",
|
||||
)
|
||||
|
||||
if self.version < "cci.20230118":
|
||||
# Honor fPIC option
|
||||
replace_in_file(self, cmakelists, "SET_PROPERTY(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)", "")
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "cpuinfo")
|
||||
self.cpp_info.set_property("pkg_config_name", "libcpuinfo")
|
||||
|
||||
if self.version < "cci.20230118":
|
||||
self.cpp_info.components["clog"].libs = ["clog"]
|
||||
cpuinfo_clog_target = "clog" if self.version < "cci.20220618" else "cpuinfo::clog"
|
||||
self.cpp_info.components["clog"].set_property("cmake_target_name", cpuinfo_clog_target)
|
||||
|
||||
self.cpp_info.components["cpuinfo"].set_property("cmake_target_name", "cpuinfo::cpuinfo")
|
||||
self.cpp_info.components["cpuinfo"].libs = ["cpuinfo"]
|
||||
if self.version < "cci.20230118":
|
||||
self.cpp_info.components["cpuinfo"].requires = ["clog"]
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.components["cpuinfo"].system_libs.append("pthread")
|
||||
|
||||
if self.settings.os == "Android":
|
||||
self.cpp_info.components["cpuinfo"].system_libs.append("log")
|
||||
14
recipes/cpuinfo/all/test_package/CMakeLists.txt
Normal file
14
recipes/cpuinfo/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(cpuinfo REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
if ((${CPUINFO_VERSION} GREATER_EQUAL "20220618") AND (${CPUINFO_VERSION} LESS "20230118"))
|
||||
# in that version range cpuinfo exposed cpuinfo::clog. Check that is available through conan recipe
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE cpuinfo::cpuinfo cpuinfo::clog)
|
||||
else ()
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE cpuinfo::cpuinfo)
|
||||
endif()
|
||||
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)
|
||||
31
recipes/cpuinfo/all/test_package/conanfile.py
Normal file
31
recipes/cpuinfo/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["CPUINFO_VERSION"] = str(self.dependencies["cpuinfo"].ref.version).split('.')[1]
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
23
recipes/cpuinfo/all/test_package/test_package.c
Normal file
23
recipes/cpuinfo/all/test_package/test_package.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <cpuinfo.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
bool initialized = cpuinfo_initialize();
|
||||
if (!initialized) {
|
||||
printf("cpuinfo doesn't support this platforn\n");
|
||||
return 0;
|
||||
}
|
||||
printf("processors count: %u\n", cpuinfo_get_processors_count());
|
||||
printf("cores count: %u\n", cpuinfo_get_cores_count());
|
||||
printf("clusters count: %u\n", cpuinfo_get_clusters_count());
|
||||
printf("packages count: %u\n", cpuinfo_get_packages_count());
|
||||
printf("uarchs count: %u\n", cpuinfo_get_uarchs_count());
|
||||
printf("l1i caches count: %u\n", cpuinfo_get_l1i_caches_count());
|
||||
printf("l1d caches count: %u\n", cpuinfo_get_l1d_caches_count());
|
||||
printf("l2 count: %u\n", cpuinfo_get_l2_caches_count());
|
||||
printf("l3 count: %u\n", cpuinfo_get_l3_caches_count());
|
||||
printf("l4 count: %u\n", cpuinfo_get_l4_caches_count());
|
||||
cpuinfo_deinitialize();
|
||||
return 0;
|
||||
}
|
||||
11
recipes/cpuinfo/config.yml
Normal file
11
recipes/cpuinfo/config.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
versions:
|
||||
"cci.20231129":
|
||||
folder: all
|
||||
"cci.20230118":
|
||||
folder: all
|
||||
"cci.20220618":
|
||||
folder: all
|
||||
"cci.20220228":
|
||||
folder: all
|
||||
"cci.20201217":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user