From e5e71ac3227fa98c84c5a78c8c69e22123c75816 Mon Sep 17 00:00:00 2001 From: Tatyana Vaneeva Date: Wed, 28 Aug 2024 16:11:15 +0200 Subject: [PATCH] [level-zero] added new recipe --- recipes/level-zero/all/conandata.yml | 4 + recipes/level-zero/all/conanfile.py | 76 ++++++++++++ .../1.17.28/001-patch-install-rules.patch | 116 ++++++++++++++++++ .../all/test_package/CMakeLists.txt | 10 ++ .../level-zero/all/test_package/conanfile.py | 52 ++++++++ .../all/test_package/test_package.cpp | 5 + recipes/level-zero/config.yml | 3 + 7 files changed, 266 insertions(+) create mode 100644 recipes/level-zero/all/conandata.yml create mode 100644 recipes/level-zero/all/conanfile.py create mode 100644 recipes/level-zero/all/patches/1.17.28/001-patch-install-rules.patch create mode 100644 recipes/level-zero/all/test_package/CMakeLists.txt create mode 100644 recipes/level-zero/all/test_package/conanfile.py create mode 100644 recipes/level-zero/all/test_package/test_package.cpp create mode 100644 recipes/level-zero/config.yml diff --git a/recipes/level-zero/all/conandata.yml b/recipes/level-zero/all/conandata.yml new file mode 100644 index 00000000000000..8af0d4a432d2fb --- /dev/null +++ b/recipes/level-zero/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.17.28": + url: "https://github.com/oneapi-src/level-zero/archive/refs/tags/v1.17.28.tar.gz" + sha256: "54638426802df958af91f6a6013242d272b89f4bc9b0c9c4663eabc20210ab50" \ No newline at end of file diff --git a/recipes/level-zero/all/conanfile.py b/recipes/level-zero/all/conanfile.py new file mode 100644 index 00000000000000..7ee748b7313308 --- /dev/null +++ b/recipes/level-zero/all/conanfile.py @@ -0,0 +1,76 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.files import apply_conandata_patches, get, export_conandata_patches + +class LevelZeroConan(ConanFile): + name = "level-zero" + package_type = "library" + + license = "MIT" + homepage = "https://github.com/oneapi-src/level-zero" + url = "https://github.com/conan-io/conan-center-index" + description = "OneAPI Level Zero Specification Headers and Loader" + topics = ("api-headers", "loader", "level-zero", "oneapi") + package_id_non_embed_mode = "patch_mode" + package_type = "library" + + # Binary configuration + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def source(self): + version_data = self.conan_data["sources"][self.version] + get(self, **version_data, strip_root=True) + apply_conandata_patches(self) + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + deps = CMakeDeps(self) + deps.generate() + + toolchain = CMakeToolchain(self) + + toolchain.cache_variables["SYSTEM_SPDLOG"] = True + toolchain.generate() + + def validate_build(self): + if not self.options.shared: + raise ConanInvalidConfiguration( + f"{self.ref} does not support static build") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["ze_loader", "ze_core"] + self.cpp_info.includedirs = ["include"] diff --git a/recipes/level-zero/all/patches/1.17.28/001-patch-install-rules.patch b/recipes/level-zero/all/patches/1.17.28/001-patch-install-rules.patch new file mode 100644 index 00000000000000..841fc0ebc7e559 --- /dev/null +++ b/recipes/level-zero/all/patches/1.17.28/001-patch-install-rules.patch @@ -0,0 +1,116 @@ +diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt +index 5ef252c..c9d05dd 100644 +--- a/source/CMakeLists.txt ++++ b/source/CMakeLists.txt +@@ -49,21 +49,10 @@ endif() + target_link_libraries(${TARGET_LOADER_NAME} utils) + + install(TARGETS ze_loader +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero +- NAMELINK_SKIP +-) +- +-install(TARGETS ze_loader +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero-devel +- NAMELINK_ONLY ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero-devel ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT level-zero ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero ++ NAMELINK_COMPONENT level-zero-devel + ) + + if(UNIX) +diff --git a/source/drivers/null/CMakeLists.txt b/source/drivers/null/CMakeLists.txt +index b384434..0cb8801 100644 +--- a/source/drivers/null/CMakeLists.txt ++++ b/source/drivers/null/CMakeLists.txt +@@ -21,18 +21,10 @@ target_include_directories(${TARGET_NAME} + + if(INSTALL_NULL_DRIVER) + install(TARGETS ze_null +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero +- NAMELINK_SKIP +- ) +- install(TARGETS ze_null +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero-devel +- NAMELINK_ONLY ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero-devel ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT level-zero ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero ++ NAMELINK_COMPONENT level-zero-devel + ) + endif() + +diff --git a/source/layers/tracing/CMakeLists.txt b/source/layers/tracing/CMakeLists.txt +index 1dde028..63e0b20 100644 +--- a/source/layers/tracing/CMakeLists.txt ++++ b/source/layers/tracing/CMakeLists.txt +@@ -49,20 +49,8 @@ set_target_properties(${TARGET_NAME} PROPERTIES + ) + + install(TARGETS ze_tracing_layer +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero +- NAMELINK_SKIP ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero-devel ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT level-zero ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero ++ NAMELINK_COMPONENT level-zero-devel + ) +- +-install(TARGETS ze_tracing_layer +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero-devel +- NAMELINK_ONLY +-) +- +diff --git a/source/layers/validation/CMakeLists.txt b/source/layers/validation/CMakeLists.txt +index 3a4162c..ced5f21 100644 +--- a/source/layers/validation/CMakeLists.txt ++++ b/source/layers/validation/CMakeLists.txt +@@ -37,21 +37,10 @@ set_target_properties(${TARGET_NAME} PROPERTIES + ) + + install(TARGETS ze_validation_layer +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero +- NAMELINK_SKIP +-) +- +-install(TARGETS ze_validation_layer +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY +- DESTINATION ${CMAKE_INSTALL_LIBDIR} +- COMPONENT level-zero-devel +- NAMELINK_ONLY ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero-devel ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT level-zero ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero ++ NAMELINK_COMPONENT level-zero-devel + ) + + add_subdirectory(handle_lifetime_tracking) diff --git a/recipes/level-zero/all/test_package/CMakeLists.txt b/recipes/level-zero/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..44722de93a7cea --- /dev/null +++ b/recipes/level-zero/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.2.0) +project(test_package LANGUAGES CXX) + +add_component(SYSTEM_SPDLOG SPDLOG) + +find_package(level-zero CONFIG REQUIRED COMPONENTS SYSTEM_SPDLOG SPDLOG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE level-zero::ze_loader) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) \ No newline at end of file diff --git a/recipes/level-zero/all/test_package/conanfile.py b/recipes/level-zero/all/test_package/conanfile.py new file mode 100644 index 00000000000000..9d90e91b9a9f9a --- /dev/null +++ b/recipes/level-zero/all/test_package/conanfile.py @@ -0,0 +1,52 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + deps = CMakeDeps(self) + # deps.check_components_exist = True + deps.generate() + + tc = CMakeToolchain(self) + tc.variables["CMAKE_VERBOSE_MAKEFILE"] = True + # HW plugins + tc.variables["ENABLE_INTEL_CPU"] = self.dependencies[self.tested_reference_str].options.enable_cpu + tc.variables["ENABLE_INTEL_GPU"] = self.dependencies[self.tested_reference_str].options.get_safe("enable_gpu", False) + # SW plugins + tc.variables["ENABLE_AUTO"] = self.dependencies[self.tested_reference_str].options.enable_auto + tc.variables["ENABLE_HETERO"] = self.dependencies[self.tested_reference_str].options.enable_hetero + tc.variables["ENABLE_AUTO_BATCH"] = self.dependencies[self.tested_reference_str].options.enable_auto_batch + # Frontends + tc.variables["ENABLE_IR_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_ir_frontend + tc.variables["ENABLE_ONNX_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_onnx_frontend + tc.variables["ENABLE_TF_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_tf_frontend + tc.variables["ENABLE_TF_LITE_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_tf_lite_frontend + tc.variables["ENABLE_PADDLE_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_paddle_frontend + tc.variables["ENABLE_PYTORCH_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_pytorch_frontend + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path_c = os.path.join(self.cpp.build.bindirs[0], "test_package_c") + self.run(bin_path_c, env="conanrun") + + bin_path_cpp = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + self.run(bin_path_cpp, env="conanrun") diff --git a/recipes/level-zero/all/test_package/test_package.cpp b/recipes/level-zero/all/test_package/test_package.cpp new file mode 100644 index 00000000000000..11a8c3580b4d2d --- /dev/null +++ b/recipes/level-zero/all/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include "ze_api.h" + +int main() { + zeInit(0); +} diff --git a/recipes/level-zero/config.yml b/recipes/level-zero/config.yml new file mode 100644 index 00000000000000..667d626ac050ed --- /dev/null +++ b/recipes/level-zero/config.yml @@ -0,0 +1,3 @@ +versions: + "1.17.28": + folder: "all"