Skip to content

Commit

Permalink
(#4247) add recipe for Apple libdispatch (aka Grand Central Dispatch)
Browse files Browse the repository at this point in the history
* add recipe for Apple libdispatch (aka Grand Central Dispatch)

* changed reciped description

* recipe configure() method removed

* fixed config.yml

* removes share folder

* adds pthread on Linux

* Requires Clang >= 10

* accepts Clang 9 or higher

* Just Release builds allowed

* fix

* allow another compilers

* Just Clang compiler

* Update recipes/libdispatch/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/libdispatch/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/libdispatch/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/libdispatch/all/conanfile.py

Co-authored-by: Yoann Potinet <intelligide@hotmail.fr>

* Update recipes/libdispatch/all/conanfile.py

Co-authored-by: Yoann Potinet <intelligide@hotmail.fr>

Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Yoann Potinet <intelligide@hotmail.fr>
  • Loading branch information
3 people authored Jan 15, 2021
1 parent 226c6bc commit 320456e
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/libdispatch/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/libdispatch/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"5.3.2":
sha256: d18ad8f24e3461108d8e2e0c838c8fca671f808ab8d06a2c32a7065f321995a1
url: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-5.3.2-RELEASE.tar.gz
63 changes: 63 additions & 0 deletions recipes/libdispatch/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.32.0"

class LibDispatchConan(ConanFile):
name = "libdispatch"
homepage = "https://github.com/apple/swift-corelibs-libdispatch"
description = "Grand Central Dispatch (GCD or libdispatch) provides comprehensive support for concurrent code execution on multicore hardware."
topics = ("conan", "libdispatch", "apple", "GCD", "concurrency")
url = "https://github.com/conan-io/conan-center-index"
license = "Apache-2.0"
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "compiler", "build_type", "arch"

options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

_cmake = None

def validate(self):
if self.settings.build_type != "Release":
raise ConanInvalidConfiguration("Just Release builds allowed.")

if self.settings.compiler != "clang":
raise ConanInvalidConfiguration("Clang compiler is required.")

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

@property
def _build_subfolder(self):
return "build_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "swift-corelibs-{}-swift-{}-RELEASE".format(self.name, self.version)
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
12 changes: 12 additions & 0 deletions recipes/libdispatch/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.1.2)
project(test_package CXX)

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

find_package(libdispatch REQUIRED)

# TEST_PACKAGE #################################################################
add_executable(${CMAKE_PROJECT_NAME} test_package.cpp)
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14)
target_link_libraries(${CMAKE_PROJECT_NAME} libdispatch::libdispatch)
16 changes: 16 additions & 0 deletions recipes/libdispatch/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from conans import ConanFile, CMake, tools


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

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

def test(self):
if not tools.cross_building(self.settings):
self.run(os.path.join("bin","test_package"), run_environment=True)
6 changes: 6 additions & 0 deletions recipes/libdispatch/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <dispatch/dispatch.h>

int main() {
dispatch_queue_t main_q = dispatch_get_main_queue();
return 0;
}
3 changes: 3 additions & 0 deletions recipes/libdispatch/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"5.3.2":
folder: all

0 comments on commit 320456e

Please sign in to comment.