Skip to content

Commit

Permalink
Add recipe for 2021.x versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jhabermas committed Jul 12, 2022
1 parent 933b848 commit d89938a
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions recipes/onedpl/2021.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"2021.7.0":
url: "https://github.com/oneapi-src/oneDPL/archive/refs/tags/oneDPL-2021.7.0-release.tar.gz"
sha256: "5484c6de482790206d877a4947dcef6e0a1e082dbfa5c6a5362e18072c4a3de3"
"2021.6.1":
url: "https://github.com/oneapi-src/oneDPL/archive/refs/tags/oneDPL-2021.6.1-release.tar.gz"
sha256: "4995fe2ed2724b89cdb52c4b6c9af22e146b48d2561abdafdaaa06262dbd67c4"
64 changes: 64 additions & 0 deletions recipes/onedpl/2021.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from conans import ConanFile, tools
from conan.tools import files
import os

required_conan_version = ">=1.43.0"


class OneDplConan(ConanFile):
name = "onedpl"
description = ("OneDPL (Formerly Parallel STL) is an implementation of "
"the C++ standard library algorithms"
"with support for execution policies, as specified in "
"ISO/IEC 14882:2017 standard, commonly called C++17")
license = ("Apache-2.0", "LLVM-exception")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/oneapi-src/oneDPL"
topics = ("stl", "parallelism")

settings = "os", "arch", "build_type", "compiler"
options = {
"backend": ["tbb", "serial"],
}
default_options = {
"backend": "tbb",
}

no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

def requirements(self):
if self.options.backend == "tbb":
self.requires("onetbb/2021.3.0")

def package_id(self):
self.info.header_only()

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

def source(self):
files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)

def package(self):
self.copy("*", src=os.path.join(self._source_subfolder, "include"), dst="include")
self.copy("LICENSE.txt", src=self._source_subfolder, dst="licensing")

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "ParallelSTL")
self.cpp_info.set_property("cmake_target_name", "pstl::ParallelSTL")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.filenames["cmake_find_package"] = "ParallelSTL"
self.cpp_info.filenames["cmake_find_package_multi"] = "ParallelSTL"
self.cpp_info.names["cmake_find_package"] = "pstl"
self.cpp_info.names["cmake_find_package_multi"] = "pstl"
self.cpp_info.components["_onedpl"].names["cmake_find_package"] = "ParallelSTL"
self.cpp_info.components["_onedpl"].names["cmake_find_package_multi"] = "ParallelSTL"
self.cpp_info.components["_onedpl"].set_property("cmake_target_name", "pstl::ParallelSTL")
if self.options.backend == "tbb":
self.cpp_info.components["_onedpl"].requires = ["onetbb::onetbb"]
11 changes: 11 additions & 0 deletions recipes/onedpl/2021.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(ParallelSTL REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} pstl::ParallelSTL)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
17 changes: 17 additions & 0 deletions recipes/onedpl/2021.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
12 changes: 12 additions & 0 deletions recipes/onedpl/2021.x/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <vector>
#include <oneapi/dpl/execution>
#include <oneapi/dpl/algorithm>

int main()
{
std::vector<int> data(10000000);
auto policy = oneapi::dpl::execution::par_unseq;
std::fill_n(policy, data.begin(), data.size(), -1);

return 0;
}
6 changes: 5 additions & 1 deletion recipes/onedpl/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
versions:
"20200330":
folder: all
folder: 2020
"2021.6.1":
folder: 2021.x
"2021.7.0":
folder: 2021.x

0 comments on commit d89938a

Please sign in to comment.