Skip to content

Commit a43a542

Browse files
committed
libobjc2: Add new recipe for 2.2.1
Adds a new recipe for libobjc2. This package can only be built with clang.
1 parent 5b17b87 commit a43a542

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed

recipes/libobjc2/all/conandata.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"2.2.1":
3+
url: "https://github.com/gnustep/libobjc2/archive/v2.2.1.zip"
4+
sha256: "b0afc1d98a6f7208fb5ce1fc8b5848b5ba6dba1f4fcd755fbe3fc78b5e4b3308"

recipes/libobjc2/all/conanfile.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from conan import ConanFile
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.build import check_min_cppstd
4+
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
5+
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir
6+
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
7+
import os
8+
9+
required_conan_version = ">=2.0.9"
10+
11+
class PackageConan(ConanFile):
12+
name = "libobjc2"
13+
description = "Objective-C runtime library intended for use with Clang."
14+
license = "MIT"
15+
url = "https://github.com/conan-io/conan-center-index"
16+
homepage = "https://github.com/gnustep/libobjc2"
17+
topics = ("objective-c", "objective-c-plus-plus", "clang", "gnustep", "objective-c-runtime", "runtime-library")
18+
package_type = "library"
19+
settings = "os", "arch", "compiler", "build_type"
20+
options = {
21+
"shared": [True, False],
22+
"fPIC": [True, False],
23+
}
24+
default_options = {
25+
"shared": False,
26+
"fPIC": True,
27+
}
28+
29+
def export_sources(self):
30+
export_conandata_patches(self)
31+
32+
def configure(self):
33+
if self.options.shared:
34+
self.options.rm_safe("fPIC")
35+
36+
def layout(self):
37+
cmake_layout(self, src_folder="src")
38+
39+
def requirements(self):
40+
self.requires("tsl-robin-map/[^1.3.0]")
41+
42+
def validate(self):
43+
if self.settings.compiler != "apple-clang" and self.settings.compiler != "clang":
44+
raise ConanInvalidConfiguration("libobjc2 supports clang only.")
45+
46+
def build_requirements(self):
47+
self.tool_requires("cmake/[>=3.16 <4]")
48+
49+
def source(self):
50+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
51+
apply_conandata_patches(self)
52+
53+
def generate(self):
54+
tc = CMakeToolchain(self)
55+
# Prevent picking up a default install location through gnustep-config
56+
tc.variables["GNUSTEP_INSTALL_TYPE"] = "NONE"
57+
tc.variables["TESTS"] = not self.conf.get("tools.build:skip_test", default=False)
58+
tc.generate()
59+
60+
deps = CMakeDeps(self)
61+
deps.generate()
62+
63+
def build(self):
64+
cmake = CMake(self)
65+
cmake.configure()
66+
cmake.build()
67+
cmake.test()
68+
69+
def package(self):
70+
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
71+
cmake = CMake(self)
72+
cmake.install()
73+
74+
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
75+
rm(self, "*.pdb", self.package_folder, recursive=True)
76+
77+
def package_info(self):
78+
self.cpp_info.libs = ["objc"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(test_package LANGUAGES C)
3+
4+
find_package(libobjc2 REQUIRED CONFIG)
5+
6+
add_executable(${PROJECT_NAME} test_package.c)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE libobjc2::libobjc2)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import cmake_layout, CMake
4+
import os
5+
6+
7+
class TestPackageConan(ConanFile):
8+
settings = "os", "arch", "compiler", "build_type"
9+
generators = "CMakeDeps", "CMakeToolchain"
10+
11+
def layout(self):
12+
cmake_layout(self)
13+
14+
def requirements(self):
15+
self.requires(self.tested_reference_str)
16+
17+
def build(self):
18+
cmake = CMake(self)
19+
cmake.configure()
20+
cmake.build()
21+
22+
def test(self):
23+
if can_run(self):
24+
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
25+
self.run(bin_path, env="conanrun")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdlib.h>
2+
#include "objc/objc.h"
3+
#include "objc/encoding.h"
4+
5+
int main(void) {
6+
char type = _C_CLASS;
7+
objc_sizeof_type(&type);
8+
return EXIT_SUCCESS;
9+
}

recipes/libobjc2/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"2.2.1":
3+
folder: all

0 commit comments

Comments
 (0)