[DO-972][DO-980] add freetype and pkgconf recipes (!6)

Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/6
This commit is contained in:
Aleksandr Vodyanov
2024-12-06 16:48:28 +03:00
parent 25212f3eed
commit cb6a88b7f4
184 changed files with 1708 additions and 9302 deletions

View File

@@ -0,0 +1,47 @@
sources:
"2.2.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-2.2.0.tar.xz"
sha256: "b06ff63a83536aa8c2f6422fa80ad45e4833f590266feb14eaddfe1d4c853c69"
"2.1.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-2.1.0.tar.xz"
sha256: "266d5861ee51c52bc710293a1d36622ae16d048d71ec56034a02eb9cf9677761"
"2.0.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-2.0.3.tar.xz"
sha256: "cabdf3c474529854f7ccce8573c5ac68ad34a7e621037535cbc3981f6b23836c"
"2.0.2":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-2.0.2.tar.xz"
sha256: "ea5a25ef8f251eb5377ec0e21c75fb61894433cfbdbf0b2559ba33e4c2664401"
"1.9.5":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-1.9.5.tar.xz"
sha256: "1ac1656debb27497563036f7bffc281490f83f9b8457c0d60bcfb638fb6b6171"
"1.9.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-1.9.3.tar.xz"
sha256: "5fb355b487d54fb6d341e4f18d4e2f7e813a6622cf03a9e87affa6a40565699d"
"1.7.4":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-1.7.4.tar.xz"
sha256: "d73f32c248a4591139a6b17777c80d4deab6b414ec2b3d21d0a24be348c476ab"
"1.7.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-distfiles_ariadne_space/pkgconf/pkgconf-1.7.3.tar.xz"
sha256: "b846aea51cf696c3392a0ae58bef93e2e72f8e7073ca6ad1ed8b01c85871f9c0"
patches:
"2.2.0":
- patch_file: "patches/2.2.0-0001-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"2.1.0":
- patch_file: "patches/2.1.0-0001-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"2.0.3":
- patch_file: "patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"2.0.2":
- patch_file: "patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"1.9.5":
- patch_file: "patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"1.9.3":
- patch_file: "patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"1.7.4":
- patch_file: "patches/1.7.4-0001-clang-12-strndup-not-in-string-h.patch"
- patch_file: "patches/1.7.4-0002-fix-static-link.patch"
- patch_file: "patches/1.7.4-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"
"1.7.3":
- patch_file: "patches/1.7.3-0001-meson-use-declare-dependencies.patch"
- patch_file: "patches/1.7.3-0002-clang-12-strndup-not-in-string-h.patch"
- patch_file: "patches/1.7.3-0003-meson-use-library.patch"
- patch_file: "patches/1.7.3-0004-PKG_CONF_PATH-allow-colon+semicolon-separator.patch"

View File

@@ -0,0 +1,145 @@
import os
from conan import ConanFile
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm, rmdir, replace_in_file
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.microsoft import is_msvc, unix_path_package_info_legacy
from conan.tools.scm import Version
required_conan_version = ">=1.57.0"
class PkgConfConan(ConanFile):
name = "pkgconf"
url = "https://github.com/conan-io/conan-center-index"
topics = ("build", "configuration")
homepage = "https://git.sr.ht/~kaniini/pkgconf"
license = "ISC"
description = "package compiler and linker metadata toolkit"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"enable_lib": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"enable_lib": False,
}
def layout(self):
basic_layout(self, src_folder="src")
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 not self.options.enable_lib:
self.options.rm_safe("fPIC")
self.options.rm_safe("shared")
elif self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
def package_id(self):
if not self.info.options.enable_lib:
del self.info.settings.compiler
#def build_requirements(self):
# self.tool_requires("meson/1.2.2")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def _patch_sources(self):
apply_conandata_patches(self)
if not self.options.get_safe("shared", False):
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
"'-DLIBPKGCONF_EXPORT'",
"'-DPKGCONFIG_IS_STATIC'")
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
"project('pkgconf', 'c',",
"project('pkgconf', 'c',\ndefault_options : ['c_std=gnu99'],")
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = MesonToolchain(self)
if Version(self.version) >= "1.9.4":
tc.project_options["tests"] = "disabled"
else:
tc.project_options["tests"] = False
if not self.options.enable_lib:
tc.project_options["default_library"] = "static"
tc.generate()
def build(self):
self._patch_sources()
meson = Meson(self)
meson.configure()
meson.build()
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder,"licenses"))
meson = Meson(self)
meson.install()
if is_msvc(self):
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
if self.options.enable_lib and not self.options.shared:
rename(self, os.path.join(self.package_folder, "lib", "libpkgconf.a"),
os.path.join(self.package_folder, "lib", "pkgconf.lib"),)
if not self.options.enable_lib:
rmdir(self, os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "include"))
rmdir(self, os.path.join(self.package_folder, "share", "man"))
rename(self, os.path.join(self.package_folder, "share", "aclocal"),
os.path.join(self.package_folder, "bin", "aclocal"))
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
def package_info(self):
if self.options.enable_lib:
self.cpp_info.set_property("pkg_config_name", "libpkgconf")
if Version(self.version) >= "1.7.4":
self.cpp_info.includedirs.append(os.path.join("include", "pkgconf"))
self.cpp_info.libs = ["pkgconf"]
if not self.options.shared:
self.cpp_info.defines = ["PKGCONFIG_IS_STATIC"]
else:
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
bindir = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bindir)
exesuffix = ".exe" if self.settings.os == "Windows" else ""
pkg_config = os.path.join(bindir, "pkgconf" + exesuffix).replace("\\", "/")
self.buildenv_info.define_path("PKG_CONFIG", pkg_config)
pkgconf_aclocal = os.path.join(self.package_folder, "bin", "aclocal")
self.buildenv_info.prepend_path("ACLOCAL_PATH", pkgconf_aclocal)
# TODO: evaluate if `ACLOCAL_PATH` is enough and we can stop using `AUTOMAKE_CONAN_INCLUDES`
self.buildenv_info.prepend_path("AUTOMAKE_CONAN_INCLUDES", pkgconf_aclocal)
# TODO: remove in conanv2
automake_extra_includes = unix_path_package_info_legacy(self, pkgconf_aclocal.replace("\\", "/"))
self.env_info.PKG_CONFIG = pkg_config
self.env_info.AUTOMAKE_CONAN_INCLUDES.append(automake_extra_includes)

View File

@@ -0,0 +1,20 @@
--- meson.build
+++ meson.build
@@ -84,12 +84,16 @@
soversion : '3',
)
+libpkgconf_dep = declare_dependency(
+ link_with: libpkgconf,
+ compile_args: '-DLIBPKGCONF_EXPORT',
+)
pkgconf_exe = executable('pkgconf',
'cli/main.c',
'cli/getopt_long.c',
'cli/renderer-msvc.c',
- link_with : libpkgconf,
+ dependencies: libpkgconf_dep,
install : true)
if get_option('tests')

View File

@@ -0,0 +1,19 @@
--- meson.build
+++ meson.build
@@ -31,11 +31,11 @@
- ['HAVE_CYGWIN_CONV_PATH', 'cygwin_conv_path', 'sys/cygwin.h'],
- ['HAVE_STRLCAT', 'strlcat', 'string.h'],
- ['HAVE_STRLCPY', 'strlcpy', 'string.h'],
- ['HAVE_STRNDUP', 'strndup', 'string.h'],
+ ['HAVE_CYGWIN_CONV_PATH', 'cygwin_conv_path(CCP_POSIX_TO_WIN_A, (void*)0, (void*)0, 0)', 'sys/cygwin.h'],
+ ['HAVE_STRLCAT', 'strlcat((void*)0, (void*)0, 0)', 'string.h'],
+ ['HAVE_STRLCPY', 'strlcpy((void*)0, (void*)0, 0)', 'string.h'],
+ ['HAVE_STRNDUP', 'strndup((void*)0, 0)', 'string.h'],
]
foreach f : check_functions
- if cc.has_function(f.get(1), prefix : '#include <' + f.get(2) + '>') and cc.has_header_symbol(f.get(2), f.get(1))
+ if cc.links('#include <' + f.get(2) + '>\nint main() { ' + f.get(1) + ';}')
cdata.set(f.get(0), 1)
endif
endforeach

View File

@@ -0,0 +1,11 @@
--- meson.build
+++ meson.build
@@ -63,7 +63,7 @@
subdir('libpkgconf')
-libpkgconf = shared_library('pkgconf',
+libpkgconf = library('pkgconf',
'libpkgconf/argvsplit.c',
'libpkgconf/audit.c',
'libpkgconf/bsdstubs.c',

View File

@@ -0,0 +1,11 @@
--- libpkgconf/path.c
+++ libpkgconf/path.c
@@ -146,7 +146,7 @@
return 0;
iter = workbuf = strdup(text);
- while ((p = strtok(iter, PKG_CONFIG_PATH_SEP_S)) != NULL)
+ while ((p = strtok(iter, ":;")) != NULL)
{
pkgconf_path_add(p, dirlist, filter);

View File

@@ -0,0 +1,19 @@
--- meson.build
+++ meson.build
@@ -13,11 +13,11 @@
- ['HAVE_CYGWIN_CONV_PATH', 'cygwin_conv_path', 'sys/cygwin.h'],
- ['HAVE_STRLCAT', 'strlcat', 'string.h'],
- ['HAVE_STRLCPY', 'strlcpy', 'string.h'],
- ['HAVE_STRNDUP', 'strndup', 'string.h'],
+ ['HAVE_CYGWIN_CONV_PATH', 'cygwin_conv_path(CCP_POSIX_TO_WIN_A, (void*)0, (void*)0, 0)', 'sys/cygwin.h'],
+ ['HAVE_STRLCAT', 'strlcat((void*)0, (void*)0, 0)', 'string.h'],
+ ['HAVE_STRLCPY', 'strlcpy((void*)0, (void*)0, 0)', 'string.h'],
+ ['HAVE_STRNDUP', 'strndup((void*)0, 0)', 'string.h'],
]
foreach f : check_functions
- if cc.has_function(f.get(1), prefix : '#include <' + f.get(2) + '>') and cc.has_header_symbol(f.get(2), f.get(1))
+ if cc.links('#include <' + f.get(2) + '>\nint main() { ' + f.get(1) + ';}')
cdata.set(f.get(0), 1)
endif
endforeach

View File

@@ -0,0 +1,44 @@
diff --git a/meson.build b/meson.build
index e7822b8da..8f7aa0075 100644
--- a/meson.build
+++ b/meson.build
@@ -45,6 +45,13 @@ cdata.set('abs_top_builddir', meson.build_root())
subdir('libpkgconf')
+libtype = get_option('default_library')
+if libtype == 'static'
+ build_static = '-DPKGCONFIG_IS_STATIC'
+else
+ build_static = '-DLIBPKGCONF_EXPORT'
+endif
+
libpkgconf = library('pkgconf',
'libpkgconf/argvsplit.c',
'libpkgconf/audit.c',
@@ -60,7 +67,7 @@ libpkgconf = library('pkgconf',
'libpkgconf/pkg.c',
'libpkgconf/queue.c',
'libpkgconf/tuple.c',
- c_args: '-DLIBPKGCONF_EXPORT',
+ c_args: build_static,
install : true,
version : '3.0.0',
soversion : '3',
@@ -73,13 +80,16 @@ pkg.generate(libpkgconf,
url: 'http://github.com/pkgconf/pkgconf',
filebase : 'libpkgconf',
subdirs: ['pkgconf'],
+ extra_cflags : build_static
)
+
pkgconf_exe = executable('pkgconf',
'cli/main.c',
'cli/getopt_long.c',
'cli/renderer-msvc.c',
link_with : libpkgconf,
+ c_args: build_static,
install : true)
if get_option('tests')

View File

@@ -0,0 +1,11 @@
--- libpkgconf/path.c
+++ libpkgconf/path.c
@@ -142,7 +142,7 @@
return 0;
iter = workbuf = strdup(text);
- while ((p = strtok(iter, PKG_CONFIG_PATH_SEP_S)) != NULL)
+ while ((p = strtok(iter, ":;")) != NULL)
{
pkgconf_path_add(p, dirlist, filter);

View File

@@ -0,0 +1,11 @@
--- libpkgconf/path.c
+++ libpkgconf/path.c
@@ -138,7 +138,7 @@
return 0;
iter = workbuf = strdup(text);
- while ((p = strtok(iter, PKG_CONFIG_PATH_SEP_S)) != NULL)
+ while ((p = strtok(iter, ":;")) != NULL)
{
pkgconf_path_add(p, dirlist, filter);

View File

@@ -0,0 +1,11 @@
--- libpkgconf/path.c
+++ libpkgconf/path.c
@@ -170,7 +170,7 @@
return 0;
iter = workbuf = strdup(text);
- while ((p = strtok(iter, PKG_CONFIG_PATH_SEP_S)) != NULL)
+ while ((p = strtok(iter, ":;")) != NULL)
{
pkgconf_path_add(p, dirlist, filter);

View File

@@ -0,0 +1,11 @@
--- libpkgconf/path.c
+++ libpkgconf/path.c
@@ -170,7 +170,7 @@
return 0;
iter = workbuf = strdup(text);
- while ((p = strtok(iter, PKG_CONFIG_PATH_SEP_S)) != NULL)
+ while ((p = strtok(iter, ";:")) != NULL)
{
pkgconf_path_add(p, dirlist, filter);

View File

@@ -0,0 +1,83 @@
from io import StringIO
import os
from pathlib import Path
import re
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain
from conan.tools.env import Environment, VirtualBuildEnv
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.microsoft import unix_path
# It will become the standard on Conan 2.x
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
test_type = "explicit"
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
def requirements(self):
self.requires(self.tested_reference_str, run=True)
def layout(self):
cmake_layout(self, src_folder="src")
def generate(self):
# Expose `PKG_CONFIG_PATH` to be able to find libexample1.pc
env = Environment()
self.output.info(f"Source folder: {self.source_folder}")
env.prepend_path("PKG_CONFIG_PATH", self.source_folder)
env.vars(self, scope="run").save_script("pkgconf-config-path")
# CMake project to test that we can link against the library,
# when the library is built
if self.dependencies[self.tested_reference_str].options.enable_lib:
ct = CMakeToolchain(self)
ct.generate()
deps = CMakeDeps(self)
deps.generate()
# Check build environment postconditions
buildenv = VirtualBuildEnv(self)
env = buildenv.vars(scope='build')
assert 'PKG_CONFIG' in env.keys()
assert 'ACLOCAL_PATH' in env.keys()
assert 'AUTOMAKE_CONAN_INCLUDES' in env.keys()
buildenv.generate()
@property
def _testing_library(self):
# Workaround, in Conan >=2.0 we should be able to remove this in favour of:
# self.dependencies[self.tested_reference_str].options.enable_lib
has_toolchain = sorted(Path(self.build_folder).rglob('conan_toolchain.cmake'))
return has_toolchain
def build(self):
if self._testing_library:
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
# Check that we can find pkgconf in build environment
# and that it is the expected version
if can_run(self):
output = StringIO()
self.run("pkgconf --about", output, env="conanrun")
# TODO: When recipe is Conan 2+ only, this can be simplified
# to: self.dependencies['pkgconf'].ref.version
tokens = re.split('[@#]', self.tested_reference_str)
pkgconf_expected_version = tokens[0].split("/", 1)[1]
assert f"pkgconf {pkgconf_expected_version}" in output.getvalue()
self.run("pkgconf libexample1 -cflags", env="conanrun")
# Test that executable linked against library runs as expected
if can_run(self) and self._testing_library:
test_executable = unix_path(self, os.path.join(self.cpp.build.bindirs[0], "test_package"))
self.run(test_executable, env="conanrun")

View File

@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES C)
find_package(pkgconf REQUIRED)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE pkgconf::pkgconf)

View File

@@ -0,0 +1,6 @@
Name: libexample1
Description: This is a description of libexample1.
Requires:
Version: 0.42
Libs: -L/usr/lib -lexample1
Cflags: -I/usr/include/libexample1 -I/usr/include -DEXAMPLE1_STATIC

View File

@@ -0,0 +1,24 @@
#include "libpkgconf/libpkgconf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
bool error_callback(const char *msg, const pkgconf_client_t *client, const void *data) {
printf("error callback: %s\n", msg);
fflush(stdout);
return 1; // 1/true means message handled
}
int main() {
pkgconf_client_t client;
memset(&client, 0, sizeof(client));
pkgconf_client_init(&client, error_callback, NULL, pkgconf_cross_personality_default());
pkgconf_error(&client, "%s:%d %s: %s", __FILE__, __LINE__, __FUNCTION__, "test error");
pkgconf_client_deinit(&client);
return 0;
}

View File

@@ -0,0 +1,17 @@
versions:
"2.2.0":
folder: "all"
"2.1.0":
folder: "all"
"2.0.3":
folder: "all"
"2.0.2":
folder: "all"
"1.9.5":
folder: "all"
"1.9.3":
folder: "all"
"1.7.4":
folder: "all"
"1.7.3":
folder: "all"