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

add recipe for Apple libdispatch (aka Grand Central Dispatch) #4247

Merged
merged 17 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 15 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
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
64 changes: 64 additions & 0 deletions recipes/libdispatch/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os

fpelliccioni marked this conversation as resolved.
Show resolved Hide resolved
required_conan_version = ">=1.32.0"

class LibDispatchConan(ConanFile):
name = "libdispatch"
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a lot of forks of this... perhaps an apple prefix needs to be added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, forks of what?
libdispatch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is from Apple, you are right, but I think the one from Apple is the original one.

https://github.com/apple/swift-corelibs-libdispatch

Copy link
Contributor

Choose a reason for hiding this comment

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

forks of what? libdispatch?

Yes

I think it was OSS that apple ran with since they needed it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I know of is a project run by Apple.
Any variant is a fork of Apple's.

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.."
fpelliccioni marked this conversation as resolved.
Show resolved Hide resolved
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)

fpelliccioni marked this conversation as resolved.
Show resolved Hide resolved
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