[DO-981] qt package (!15)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
This commit is contained in:
16
recipes/fontconfig/all/conandata.yml
Normal file
16
recipes/fontconfig/all/conandata.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
sources:
|
||||
"2.15.0":
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-freedesktop_org/software/fontconfig/release/fontconfig-2.15.0.tar.xz"
|
||||
sha256: "63a0658d0e06e0fa886106452b58ef04f21f58202ea02a94c39de0d3335d7c0e"
|
||||
"2.14.2":
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-freedesktop_org/software/fontconfig/release/fontconfig-2.14.2.tar.xz"
|
||||
sha256: "dba695b57bce15023d2ceedef82062c2b925e51f5d4cc4aef736cf13f60a468b"
|
||||
"2.13.93":
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-freedesktop_org/software/fontconfig/release/fontconfig-2.13.93.tar.gz"
|
||||
sha256: "0f302a18ee52dde0793fe38b266bf269dfe6e0c0ae140e30d72c6cca5dc08db5"
|
||||
patches:
|
||||
"2.13.93":
|
||||
- patch_file: "patches/0001-meson-win32.patch"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/7bfbaecf819a8b1630dfc8f56126e31f985d5fb3"
|
||||
patch_description: "Windows: Fix symlink privilege error detection"
|
||||
132
recipes/fontconfig/all/conanfile.py
Normal file
132
recipes/fontconfig/all/conanfile.py
Normal file
@@ -0,0 +1,132 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.apple import fix_apple_shared_install_name
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.files import (
|
||||
apply_conandata_patches, copy, export_conandata_patches, get,
|
||||
rm, rmdir
|
||||
)
|
||||
from conan.tools.gnu import PkgConfigDeps
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.meson import Meson, MesonToolchain
|
||||
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.64.0 <2 || >=2.2.0"
|
||||
|
||||
|
||||
class FontconfigConan(ConanFile):
|
||||
name = "fontconfig"
|
||||
license = "MIT"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
description = "Fontconfig is a library for configuring and customizing font access"
|
||||
homepage = "https://gitlab.freedesktop.org/fontconfig/fontconfig"
|
||||
topics = ("fonts", "freedesktop")
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
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 self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
self.requires("freetype/2.13.2")
|
||||
self.requires("expat/[>=2.6.2 <3]")
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("gperf/3.1")
|
||||
# self.tool_requires("meson/1.4.0")
|
||||
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
|
||||
self.tool_requires("pkgconf/[>=2.1.0]")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
env = VirtualBuildEnv(self)
|
||||
env.generate()
|
||||
|
||||
deps = PkgConfigDeps(self)
|
||||
deps.generate()
|
||||
|
||||
tc = MesonToolchain(self)
|
||||
tc.project_options.update({
|
||||
"doc": "disabled",
|
||||
"nls": "disabled",
|
||||
"tests": "disabled",
|
||||
"tools": "disabled",
|
||||
"sysconfdir": os.path.join("res", "etc"),
|
||||
"datadir": os.path.join("res", "share"),
|
||||
})
|
||||
tc.generate()
|
||||
|
||||
def _patch_files(self):
|
||||
apply_conandata_patches(self)
|
||||
|
||||
def build(self):
|
||||
self._patch_files()
|
||||
meson = Meson(self)
|
||||
meson.configure()
|
||||
meson.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
|
||||
meson = Meson(self)
|
||||
meson.install()
|
||||
rm(self, "*.pdb", self.package_folder, recursive=True)
|
||||
rm(self, "*.conf", os.path.join(self.package_folder, "res", "etc", "fonts", "conf.d"))
|
||||
rm(self, "*.def", os.path.join(self.package_folder, "lib"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
fix_apple_shared_install_name(self)
|
||||
fix_msvc_libname(self)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_file_name", "Fontconfig")
|
||||
self.cpp_info.set_property("cmake_target_name", "Fontconfig::Fontconfig")
|
||||
self.cpp_info.set_property("pkg_config_name", "fontconfig")
|
||||
self.cpp_info.libs = ["fontconfig"]
|
||||
if self.settings.os in ("Linux", "FreeBSD"):
|
||||
self.cpp_info.system_libs.extend(["m", "pthread"])
|
||||
|
||||
fontconfig_path = os.path.join(self.package_folder, "res", "etc", "fonts")
|
||||
self.runenv_info.append_path("FONTCONFIG_PATH", fontconfig_path)
|
||||
|
||||
# TODO: to remove in conan v2
|
||||
self.cpp_info.names["cmake_find_package"] = "Fontconfig"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "Fontconfig"
|
||||
self.env_info.FONTCONFIG_PATH = fontconfig_path
|
||||
|
||||
def fix_msvc_libname(conanfile, remove_lib_prefix=True):
|
||||
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
|
||||
if not conanfile.settings.get_safe("compiler.runtime"):
|
||||
return
|
||||
from conan.tools.files import rename
|
||||
import glob
|
||||
libdirs = getattr(conanfile.cpp.package, "libdirs")
|
||||
for libdir in libdirs:
|
||||
for ext in [".dll.a", ".dll.lib", ".a"]:
|
||||
full_folder = os.path.join(conanfile.package_folder, libdir)
|
||||
for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")):
|
||||
libname = os.path.basename(filepath)[0:-len(ext)]
|
||||
if remove_lib_prefix and libname[0:3] == "lib":
|
||||
libname = libname[3:]
|
||||
rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib"))
|
||||
19
recipes/fontconfig/all/patches/0001-meson-win32.patch
Normal file
19
recipes/fontconfig/all/patches/0001-meson-win32.patch
Normal file
@@ -0,0 +1,19 @@
|
||||
--- conf.d/link_confs.py
|
||||
+++ conf.d/link_confs.py
|
||||
@@ -3,6 +3,7 @@
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
+import platform
|
||||
|
||||
if __name__=='__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -26,7 +27,7 @@ if __name__=='__main__':
|
||||
break
|
||||
except OSError as e:
|
||||
# Symlink privileges are not available
|
||||
- if len(e.args) == 1 and 'privilege' in e.args[0]:
|
||||
+ if platform.system().lower() == 'windows' and e.winerror == 1314:
|
||||
break
|
||||
raise
|
||||
except FileExistsError:
|
||||
8
recipes/fontconfig/all/test_package/CMakeLists.txt
Normal file
8
recipes/fontconfig/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(Fontconfig REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Fontconfig::Fontconfig)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)
|
||||
10
recipes/fontconfig/all/test_package/CMakeUserPresets.json
Normal file
10
recipes/fontconfig/all/test_package/CMakeUserPresets.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/gcc-12-x86_64-gnu17-release/generators/CMakePresets.json",
|
||||
"build/gcc-11.5-x86_64-17-release/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
26
recipes/fontconfig/all/test_package/conanfile.py
Normal file
26
recipes/fontconfig/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
from conan.tools.build import can_run
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
24
recipes/fontconfig/all/test_package/test_package.c
Normal file
24
recipes/fontconfig/all/test_package/test_package.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
FcConfig* config = FcInitLoadConfigAndFonts();
|
||||
FcPattern* pat = FcNameParse((const FcChar8*)"Arial");
|
||||
FcConfigSubstitute(config, pat, FcMatchPattern);
|
||||
FcDefaultSubstitute(pat);
|
||||
char* fontFile;
|
||||
FcResult result;
|
||||
FcPattern* font = FcFontMatch(config, pat, &result);
|
||||
if (font) {
|
||||
FcChar8* file = NULL;
|
||||
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
|
||||
fontFile = (char*)file;
|
||||
printf("%s\n",fontFile);
|
||||
}
|
||||
} else {
|
||||
printf("Ops! I can't find any font!\n");
|
||||
}
|
||||
FcPatternDestroy(pat);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
9
recipes/fontconfig/all/test_v1_package/CMakeLists.txt
Normal file
9
recipes/fontconfig/all/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package C)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package/
|
||||
)
|
||||
17
recipes/fontconfig/all/test_v1_package/conanfile.py
Normal file
17
recipes/fontconfig/all/test_v1_package/conanfile.py
Normal file
@@ -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"
|
||||
|
||||
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)
|
||||
7
recipes/fontconfig/config.yml
Normal file
7
recipes/fontconfig/config.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
versions:
|
||||
"2.15.0":
|
||||
folder: all
|
||||
"2.14.2":
|
||||
folder: all
|
||||
"2.13.93":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user