[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:
16
recipes/freetype/all/conandata.yml
Normal file
16
recipes/freetype/all/conandata.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
sources:
|
||||
"2.12.1":
|
||||
url:
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.12.1.tar.xz"
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.12.1/freetype-2.12.1.tar.xz"
|
||||
sha256: "4766f20157cc4cf0cd292f80bf917f92d1c439b243ac3018debf6b9140c41a7f"
|
||||
"2.11.1":
|
||||
url:
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.11.1.tar.xz"
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.11.1/freetype-2.11.1.tar.xz"
|
||||
sha256: "3333ae7cfda88429c97a7ae63b7d01ab398076c3b67182e960e5684050f2c5c8"
|
||||
"2.10.4":
|
||||
url:
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.10.4.tar.xz"
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.10.4/freetype-2.10.4.tar.xz"
|
||||
sha256: "86a854d8905b19698bbc8f23b860bc104246ce4854dcea8e3b0fb21284f75784"
|
||||
264
recipes/freetype/all/conanfile.py
Normal file
264
recipes/freetype/all/conanfile.py
Normal file
@@ -0,0 +1,264 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
|
||||
from conan.tools.files import (
|
||||
apply_conandata_patches, collect_libs, copy, export_conandata_patches, load,
|
||||
get, rename, replace_in_file, rmdir, save
|
||||
)
|
||||
from conan.tools.scm import Version
|
||||
import os
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class FreetypeConan(ConanFile):
|
||||
name = "freetype"
|
||||
description = "FreeType is a freely available software library to render fonts."
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://www.freetype.org"
|
||||
license = "FTL"
|
||||
topics = ("freetype", "fonts")
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"with_png": [True, False],
|
||||
"with_zlib": [True, False],
|
||||
"with_bzip2": [True, False],
|
||||
"with_brotli": [True, False],
|
||||
"subpixel": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"with_png": True,
|
||||
"with_zlib": True,
|
||||
"with_bzip2": True,
|
||||
"with_brotli": True,
|
||||
"subpixel": False,
|
||||
}
|
||||
|
||||
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.cppstd")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.with_png:
|
||||
# self.requires("libpng/[>=1.6 <2]")
|
||||
self.requires("libpng/1.6.43")
|
||||
if self.options.with_zlib:
|
||||
#self.requires("zlib/[>=1.2.10 <2]")
|
||||
self.requires("zlib/1.3.1")
|
||||
if self.options.with_bzip2:
|
||||
self.requires("bzip2/1.0.8")
|
||||
if self.options.with_brotli:
|
||||
self.requires("brotli/1.1.0")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
|
||||
tc = CMakeToolchain(self)
|
||||
if Version(self.version) >= "2.11.0":
|
||||
tc.variables["FT_REQUIRE_ZLIB"] = self.options.with_zlib
|
||||
tc.variables["FT_DISABLE_ZLIB"] = not self.options.with_zlib
|
||||
tc.variables["FT_REQUIRE_PNG"] = self.options.with_png
|
||||
tc.variables["FT_DISABLE_PNG"] = not self.options.with_png
|
||||
tc.variables["FT_REQUIRE_BZIP2"] = self.options.with_bzip2
|
||||
tc.variables["FT_DISABLE_BZIP2"] = not self.options.with_bzip2
|
||||
# TODO: Harfbuzz can be added as an option as soon as it is available.
|
||||
tc.variables["FT_REQUIRE_HARFBUZZ"] = False
|
||||
tc.variables["FT_DISABLE_HARFBUZZ"] = True
|
||||
tc.variables["FT_REQUIRE_BROTLI"] = self.options.with_brotli
|
||||
tc.variables["FT_DISABLE_BROTLI"] = not self.options.with_brotli
|
||||
else:
|
||||
tc.variables["FT_WITH_ZLIB"] = self.options.with_zlib
|
||||
tc.variables["FT_WITH_PNG"] = self.options.with_png
|
||||
tc.variables["FT_WITH_BZIP2"] = self.options.with_bzip2
|
||||
# TODO: Harfbuzz can be added as an option as soon as it is available.
|
||||
tc.variables["FT_WITH_HARFBUZZ"] = False
|
||||
tc.variables["FT_WITH_BROTLI"] = self.options.with_brotli
|
||||
# Generate a relocatable shared lib on Macos
|
||||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
apply_conandata_patches(self)
|
||||
# Do not accidentally enable dependencies we have disabled
|
||||
cmakelists = os.path.join(self.source_folder, "CMakeLists.txt")
|
||||
if_harfbuzz_found = "if ({})".format("HARFBUZZ_FOUND" if Version(self.version) < "2.11.0" else "HarfBuzz_FOUND")
|
||||
replace_in_file(self, cmakelists, "find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION})", "")
|
||||
replace_in_file(self, cmakelists, if_harfbuzz_found, "if(0)")
|
||||
if not self.options.with_png:
|
||||
replace_in_file(self, cmakelists, "find_package(PNG)", "")
|
||||
replace_in_file(self, cmakelists, "if (PNG_FOUND)", "if(0)")
|
||||
if not self.options.with_zlib:
|
||||
replace_in_file(self, cmakelists, "find_package(ZLIB)", "")
|
||||
replace_in_file(self, cmakelists, "if (ZLIB_FOUND)", "if(0)")
|
||||
if not self.options.with_bzip2:
|
||||
replace_in_file(self, cmakelists, "find_package(BZip2)", "")
|
||||
replace_in_file(self, cmakelists, "if (BZIP2_FOUND)", "if(0)")
|
||||
# the custom FindBrotliDec of upstream is too fragile
|
||||
replace_in_file(self, cmakelists,
|
||||
"find_package(BrotliDec REQUIRED)",
|
||||
"find_package(Brotli REQUIRED)\n"
|
||||
"set(BROTLIDEC_FOUND 1)\n"
|
||||
"set(BROTLIDEC_LIBRARIES \"brotli::brotli\")")
|
||||
if not self.options.with_brotli:
|
||||
replace_in_file(self, cmakelists, "find_package(BrotliDec)", "")
|
||||
replace_in_file(self, cmakelists, "if (BROTLIDEC_FOUND)", "if(0)")
|
||||
|
||||
config_h = os.path.join(self.source_folder, "include", "freetype", "config", "ftoption.h")
|
||||
if self.options.subpixel:
|
||||
replace_in_file(self, config_h, "/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */", "#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING")
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def _make_freetype_config(self, version):
|
||||
freetype_config_in = os.path.join(self.source_folder, "builds", "unix", "freetype-config.in")
|
||||
if not os.path.isdir(os.path.join(self.package_folder, "bin")):
|
||||
os.makedirs(os.path.join(self.package_folder, "bin"))
|
||||
freetype_config = os.path.join(self.package_folder, "bin", "freetype-config")
|
||||
rename(self, freetype_config_in, freetype_config)
|
||||
libs = "-lfreetyped" if self.settings.build_type == "Debug" else "-lfreetype"
|
||||
staticlibs = f"-lm {libs}" if self.settings.os == "Linux" else libs
|
||||
replace_in_file(self, freetype_config, r"%PKG_CONFIG%", r"/bin/false") # never use pkg-config
|
||||
replace_in_file(self, freetype_config, r"%prefix%", r"$conan_prefix")
|
||||
replace_in_file(self, freetype_config, r"%exec_prefix%", r"$conan_exec_prefix")
|
||||
replace_in_file(self, freetype_config, r"%includedir%", r"$conan_includedir")
|
||||
replace_in_file(self, freetype_config, r"%libdir%", r"$conan_libdir")
|
||||
replace_in_file(self, freetype_config, r"%ft_version%", r"$conan_ftversion")
|
||||
replace_in_file(self, freetype_config, r"%LIBSSTATIC_CONFIG%", r"$conan_staticlibs")
|
||||
replace_in_file(self, freetype_config, r"-lfreetype", libs)
|
||||
replace_in_file(self, freetype_config, r"export LC_ALL", textwrap.dedent("""\
|
||||
export LC_ALL
|
||||
BINDIR=$(dirname $0)
|
||||
conan_prefix=$(dirname $BINDIR)
|
||||
conan_exec_prefix=${{conan_prefix}}/bin
|
||||
conan_includedir=${{conan_prefix}}/include
|
||||
conan_libdir=${{conan_prefix}}/lib
|
||||
conan_ftversion={version}
|
||||
conan_staticlibs="{staticlibs}"
|
||||
""").format(version=version, staticlibs=staticlibs))
|
||||
|
||||
def _extract_libtool_version(self):
|
||||
conf_raw = load(self, os.path.join(self.source_folder, "builds", "unix", "configure.raw"))
|
||||
return next(re.finditer(r"^version_info='([0-9:]+)'", conf_raw, flags=re.M)).group(1).replace(":", ".")
|
||||
|
||||
@property
|
||||
def _libtool_version_txt(self):
|
||||
return os.path.join(self.package_folder, "res", "freetype-libtool-version.txt")
|
||||
|
||||
def package(self):
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
|
||||
libtool_version = self._extract_libtool_version()
|
||||
save(self, self._libtool_version_txt, libtool_version)
|
||||
self._make_freetype_config(libtool_version)
|
||||
|
||||
doc_folder = os.path.join(self.source_folder, "docs")
|
||||
license_folder = os.path.join(self.package_folder, "licenses")
|
||||
copy(self, "FTL.TXT", doc_folder, license_folder)
|
||||
copy(self, "GPLv2.TXT", doc_folder, license_folder)
|
||||
copy(self, "LICENSE.TXT", doc_folder, license_folder)
|
||||
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
self._create_cmake_module_variables(
|
||||
os.path.join(self.package_folder, self._module_vars_rel_path)
|
||||
)
|
||||
self._create_cmake_module_alias_targets(
|
||||
os.path.join(self.package_folder, self._module_target_rel_path),
|
||||
{"freetype": "Freetype::Freetype"}
|
||||
)
|
||||
|
||||
def _create_cmake_module_variables(self, module_file):
|
||||
content = textwrap.dedent(f"""\
|
||||
set(FREETYPE_FOUND TRUE)
|
||||
if(DEFINED Freetype_INCLUDE_DIRS)
|
||||
set(FREETYPE_INCLUDE_DIRS ${{Freetype_INCLUDE_DIRS}})
|
||||
endif()
|
||||
if(DEFINED Freetype_LIBRARIES)
|
||||
set(FREETYPE_LIBRARIES ${{Freetype_LIBRARIES}})
|
||||
endif()
|
||||
set(FREETYPE_VERSION_STRING "{self.version}")
|
||||
""")
|
||||
save(self, module_file, content)
|
||||
|
||||
def _create_cmake_module_alias_targets(self, module_file, targets):
|
||||
content = ""
|
||||
for alias, aliased in targets.items():
|
||||
content += textwrap.dedent("""\
|
||||
if(TARGET {aliased} AND NOT TARGET {alias})
|
||||
add_library({alias} INTERFACE IMPORTED)
|
||||
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
|
||||
endif()
|
||||
""".format(alias=alias, aliased=aliased))
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_vars_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake")
|
||||
|
||||
@property
|
||||
def _module_target_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake")
|
||||
|
||||
@staticmethod
|
||||
def _chmod_plus_x(filename):
|
||||
if os.name == "posix" and (os.stat(filename).st_mode & 0o111) != 0o111:
|
||||
os.chmod(filename, os.stat(filename).st_mode | 0o111)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_module_file_name", "Freetype")
|
||||
self.cpp_info.set_property("cmake_file_name", "freetype")
|
||||
self.cpp_info.set_property("cmake_target_name", "Freetype::Freetype")
|
||||
self.cpp_info.set_property("cmake_target_aliases", ["freetype"]) # other possible target name in upstream config file
|
||||
self.cpp_info.set_property("cmake_build_modules", [self._module_vars_rel_path])
|
||||
self.cpp_info.set_property("pkg_config_name", "freetype2")
|
||||
self.cpp_info.libs = collect_libs(self)
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.append("m")
|
||||
self.cpp_info.includedirs.append(os.path.join("include", "freetype2"))
|
||||
|
||||
libtool_version = load(self, self._libtool_version_txt).strip()
|
||||
self.conf_info.define("user.freetype:libtool_version", libtool_version)
|
||||
self.cpp_info.set_property("system_package_version", libtool_version)
|
||||
|
||||
# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
|
||||
self.cpp_info.set_property("component_version", libtool_version)
|
||||
self.cpp_info.filenames["cmake_find_package"] = "Freetype"
|
||||
self.cpp_info.filenames["cmake_find_package_multi"] = "freetype"
|
||||
self.cpp_info.names["cmake_find_package"] = "Freetype"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "Freetype"
|
||||
self.cpp_info.build_modules["cmake_find_package"] = [self._module_vars_rel_path]
|
||||
self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_target_rel_path]
|
||||
self.cpp_info.names["pkg_config"] = "freetype2"
|
||||
freetype_config = os.path.join(self.package_folder, "bin", "freetype-config")
|
||||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
|
||||
self.env_info.FT2_CONFIG = freetype_config
|
||||
self._chmod_plus_x(freetype_config)
|
||||
self.user_info.LIBTOOL_VERSION = libtool_version
|
||||
7
recipes/freetype/all/test_package/CMakeLists.txt
Normal file
7
recipes/freetype/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(freetype REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE freetype)
|
||||
BIN
recipes/freetype/all/test_package/OpenSans-Bold.ttf
Normal file
BIN
recipes/freetype/all/test_package/OpenSans-Bold.ttf
Normal file
Binary file not shown.
28
recipes/freetype/all/test_package/conanfile.py
Normal file
28
recipes/freetype/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,28 @@
|
||||
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", "compiler", "build_type", "arch"
|
||||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", env="conanrun")
|
||||
142
recipes/freetype/all/test_package/test_package.c
Normal file
142
recipes/freetype/all/test_package/test_package.c
Normal file
@@ -0,0 +1,142 @@
|
||||
/* example1.c */
|
||||
/* */
|
||||
/* This small program shows how to print a rotated string with the */
|
||||
/* FreeType 2 library. */
|
||||
|
||||
#include "ft2build.h"
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
|
||||
|
||||
/* origin is the upper left corner */
|
||||
unsigned char image[HEIGHT][WIDTH];
|
||||
|
||||
|
||||
/* Replace this function with something useful. */
|
||||
|
||||
void
|
||||
draw_bitmap( FT_Bitmap* bitmap,
|
||||
FT_Int x,
|
||||
FT_Int y)
|
||||
{
|
||||
FT_Int i, j, p, q;
|
||||
FT_Int x_max = x + bitmap->width;
|
||||
FT_Int y_max = y + bitmap->rows;
|
||||
|
||||
|
||||
/* for simplicity, we assume that `bitmap->pixel_mode' */
|
||||
/* is `FT_PIXEL_MODE_GRAY' (i.e., not a bitmap font) */
|
||||
|
||||
for ( i = x, p = 0; i < x_max; i++, p++ )
|
||||
{
|
||||
for ( j = y, q = 0; j < y_max; j++, q++ )
|
||||
{
|
||||
if ( i < 0 || j < 0 ||
|
||||
i >= WIDTH || j >= HEIGHT )
|
||||
continue;
|
||||
|
||||
image[j][i] |= bitmap->buffer[q * bitmap->width + p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc,
|
||||
char** argv )
|
||||
{
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
FT_GlyphSlot slot;
|
||||
FT_Matrix matrix; /* transformation matrix */
|
||||
FT_Vector pen; /* untransformed origin */
|
||||
FT_Error error;
|
||||
|
||||
char* filename;
|
||||
char* text;
|
||||
|
||||
double angle;
|
||||
int target_height;
|
||||
size_t n, num_chars;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s FONT\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
text = "conan-center-index";
|
||||
num_chars = strlen( text );
|
||||
angle = ( 25.0 / 360 ) * 3.14159 * 2; /* use 25 degrees */
|
||||
target_height = HEIGHT;
|
||||
|
||||
error = FT_Init_FreeType( &library ); /* initialize library */
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
error = FT_New_Face( library, filename, 0, &face );/* create face object */
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* use 50pt at 100dpi */
|
||||
error = FT_Set_Char_Size( face, 50 * 64, 0, 100, 0 );
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* cmap selection omitted; */
|
||||
/* for simplicity we assume that the font contains a Unicode cmap */
|
||||
|
||||
slot = face->glyph;
|
||||
|
||||
/* set up matrix */
|
||||
matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
|
||||
matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
|
||||
matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
|
||||
matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );
|
||||
|
||||
/* the pen position in 26.6 cartesian space coordinates; */
|
||||
/* start at (300,200) relative to the upper left corner */
|
||||
pen.x = 300 * 64;
|
||||
pen.y = ( target_height - 200 ) * 64;
|
||||
|
||||
for ( n = 0; n < num_chars; n++ )
|
||||
{
|
||||
/* set transformation */
|
||||
FT_Set_Transform( face, &matrix, &pen );
|
||||
|
||||
/* load glyph image into the slot (erase previous one) */
|
||||
error = FT_Load_Char( face, text[n], FT_LOAD_RENDER);
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* now, draw to our target surface (convert position) */
|
||||
draw_bitmap( &slot->bitmap,
|
||||
slot->bitmap_left,
|
||||
target_height - slot->bitmap_top );
|
||||
|
||||
/* increment pen position */
|
||||
pen.x += slot->advance.x;
|
||||
pen.y += slot->advance.y;
|
||||
}
|
||||
|
||||
FT_Done_Face ( face );
|
||||
FT_Done_FreeType( library );
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
23
recipes/freetype/all/test_package_module/CMakeLists.txt
Normal file
23
recipes/freetype/all/test_package_module/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(Freetype REQUIRED MODULE)
|
||||
|
||||
add_executable(${PROJECT_NAME} ../test_package/test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Freetype::Freetype)
|
||||
|
||||
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindFreetype.html
|
||||
# are properly defined in conan generators
|
||||
set(_custom_vars
|
||||
FREETYPE_FOUND
|
||||
FREETYPE_INCLUDE_DIRS
|
||||
FREETYPE_LIBRARIES
|
||||
FREETYPE_VERSION_STRING
|
||||
)
|
||||
foreach(_custom_var ${_custom_vars})
|
||||
if(DEFINED ${_custom_var})
|
||||
message(STATUS "${_custom_var}: ${${_custom_var}}")
|
||||
else()
|
||||
message(FATAL_ERROR "${_custom_var} not defined")
|
||||
endif()
|
||||
endforeach()
|
||||
28
recipes/freetype/all/test_package_module/conanfile.py
Normal file
28
recipes/freetype/all/test_package_module/conanfile.py
Normal file
@@ -0,0 +1,28 @@
|
||||
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"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", env="conanrun")
|
||||
8
recipes/freetype/all/test_v1_package/CMakeLists.txt
Normal file
8
recipes/freetype/all/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package)
|
||||
19
recipes/freetype/all/test_v1_package/conanfile.py
Normal file
19
recipes/freetype/all/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package_multi"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", run_environment=True)
|
||||
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package_module
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package_module)
|
||||
19
recipes/freetype/all/test_v1_package_module/conanfile.py
Normal file
19
recipes/freetype/all/test_v1_package_module/conanfile.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", run_environment=True)
|
||||
13
recipes/freetype/config.yml
Normal file
13
recipes/freetype/config.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
versions:
|
||||
"2.13.3":
|
||||
folder: meson
|
||||
"2.13.2":
|
||||
folder: meson
|
||||
"2.13.0":
|
||||
folder: meson
|
||||
"2.12.1":
|
||||
folder: all
|
||||
"2.11.1":
|
||||
folder: all
|
||||
"2.10.4":
|
||||
folder: all
|
||||
40
recipes/freetype/meson/conandata.yml
Normal file
40
recipes/freetype/meson/conandata.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
sources:
|
||||
"2.13.3":
|
||||
url:
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.13.3.tar.xz"
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.13.3/freetype-2.13.3.tar.xz"
|
||||
sha256: "0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289"
|
||||
"2.13.2":
|
||||
url:
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.13.2.tar.xz"
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.13.2/freetype-2.13.2.tar.xz"
|
||||
sha256: "12991c4e55c506dd7f9b765933e62fd2be2e06d421505d7950a132e4f1bb484d"
|
||||
"2.13.0":
|
||||
url:
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.13.0.tar.xz"
|
||||
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.13.0/freetype-2.13.0.tar.xz"
|
||||
sha256: "5ee23abd047636c24b2d43c6625dcafc66661d1aca64dec9e0d05df29592624c"
|
||||
patches:
|
||||
"2.13.3":
|
||||
- patch_file: "patches/2.13.3-0002-meson-Fix-static-windows.patch"
|
||||
patch_description: "meson: define DLL_EXPORT for shared library only"
|
||||
patch_source: "https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/341"
|
||||
patch_type: "portability"
|
||||
"2.13.2":
|
||||
- patch_file: "patches/2.13.0-0001-meson-Use-the-standard-dependency-mechanism-to-find-.patch"
|
||||
patch_description: "meson: Use the standard dependency mechanism to find bzip2"
|
||||
patch_source: "https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/318"
|
||||
patch_type: "portability"
|
||||
- patch_file: "patches/2.13.0-0002-meson-Fix-static-windows.patch"
|
||||
patch_description: "meson: define DLL_EXPORT for shared library only"
|
||||
patch_source: "https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/341"
|
||||
patch_type: "portability"
|
||||
"2.13.0":
|
||||
- patch_file: "patches/2.13.0-0001-meson-Use-the-standard-dependency-mechanism-to-find-.patch"
|
||||
patch_description: "meson: Use the standard dependency mechanism to find bzip2"
|
||||
patch_source: "https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/318"
|
||||
patch_type: "portability"
|
||||
- patch_file: "patches/2.13.0-0002-meson-Fix-static-windows.patch"
|
||||
patch_description: "meson: define DLL_EXPORT for shared library only"
|
||||
patch_source: "https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/341"
|
||||
patch_type: "portability"
|
||||
258
recipes/freetype/meson/conanfile.py
Normal file
258
recipes/freetype/meson/conanfile.py
Normal file
@@ -0,0 +1,258 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.apple import fix_apple_shared_install_name
|
||||
from conan.tools.files import (
|
||||
apply_conandata_patches, copy, export_conandata_patches, load,
|
||||
get, rename, replace_in_file, rm, rmdir, save
|
||||
)
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.gnu import PkgConfigDeps
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.meson import Meson, MesonToolchain
|
||||
from conan.tools.scm import Version
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class FreetypeConan(ConanFile):
|
||||
name = "freetype"
|
||||
description = "FreeType is a freely available software library to render fonts."
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://www.freetype.org"
|
||||
license = "FTL"
|
||||
topics = ("freetype", "fonts")
|
||||
package_type = "library"
|
||||
short_paths = True
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"with_png": [True, False],
|
||||
"with_zlib": [True, False],
|
||||
"with_bzip2": [True, False],
|
||||
"with_brotli": [True, False],
|
||||
"subpixel": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"with_png": True,
|
||||
"with_zlib": True,
|
||||
"with_bzip2": True,
|
||||
"with_brotli": True,
|
||||
"subpixel": False,
|
||||
}
|
||||
|
||||
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.cppstd")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.with_png:
|
||||
self.requires("libpng/[>=1.6 <2]")
|
||||
if self.options.with_zlib:
|
||||
self.requires("zlib/[>=1.2.10 <2]")
|
||||
if self.options.with_bzip2:
|
||||
self.requires("bzip2/1.0.8")
|
||||
if self.options.get_safe("with_brotli"):
|
||||
self.requires("brotli/1.1.0")
|
||||
|
||||
def build_requirements(self):
|
||||
#self.tool_requires("meson/1.3.2")
|
||||
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):
|
||||
virtual_build_env = VirtualBuildEnv(self)
|
||||
virtual_build_env.generate()
|
||||
deps = PkgConfigDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def feature(option):
|
||||
return "enabled" if option else "disabled"
|
||||
|
||||
tc = MesonToolchain(self)
|
||||
tc.project_options["brotli"] = feature(self.options.with_brotli)
|
||||
tc.project_options["bzip2"] = feature(self.options.with_bzip2)
|
||||
# Harfbuzz support introduces a circular dependency between Harfbuzz and Freetype.
|
||||
# They both have options to require each other.
|
||||
tc.project_options["harfbuzz"] = "disabled"
|
||||
tc.project_options["png"] = feature(self.options.with_png)
|
||||
tc.project_options["tests"] = "disabled"
|
||||
tc.project_options["zlib"] = "system" if self.options.with_zlib else "disabled"
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
apply_conandata_patches(self)
|
||||
config_h = os.path.join(self.source_folder, "include", "freetype", "config", "ftoption.h")
|
||||
if self.options.subpixel:
|
||||
replace_in_file(self, config_h, "/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */", "#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING")
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
meson = Meson(self)
|
||||
meson.configure()
|
||||
meson.build()
|
||||
|
||||
def _make_freetype_config(self, version):
|
||||
freetype_config_in = os.path.join(self.source_folder, "builds", "unix", "freetype-config.in")
|
||||
if not os.path.isdir(os.path.join(self.package_folder, "bin")):
|
||||
os.makedirs(os.path.join(self.package_folder, "bin"))
|
||||
freetype_config = os.path.join(self.package_folder, "bin", "freetype-config")
|
||||
rename(self, freetype_config_in, freetype_config)
|
||||
staticlibs = "-lm -lfreetype" if self.settings.os == "Linux" else "-lfreetype"
|
||||
replace_in_file(self, freetype_config, r"%PKG_CONFIG%", r"/bin/false") # never use pkg-config
|
||||
replace_in_file(self, freetype_config, r"%prefix%", r"$conan_prefix")
|
||||
replace_in_file(self, freetype_config, r"%exec_prefix%", r"$conan_exec_prefix")
|
||||
replace_in_file(self, freetype_config, r"%includedir%", r"$conan_includedir")
|
||||
replace_in_file(self, freetype_config, r"%libdir%", r"$conan_libdir")
|
||||
replace_in_file(self, freetype_config, r"%ft_version%", r"$conan_ftversion")
|
||||
replace_in_file(self, freetype_config, r"%LIBSSTATIC_CONFIG%", r"$conan_staticlibs")
|
||||
replace_in_file(self, freetype_config, r"export LC_ALL", textwrap.dedent("""\
|
||||
export LC_ALL
|
||||
BINDIR=$(dirname $0)
|
||||
conan_prefix=$(dirname $BINDIR)
|
||||
conan_exec_prefix=${{conan_prefix}}/bin
|
||||
conan_includedir=${{conan_prefix}}/include
|
||||
conan_libdir=${{conan_prefix}}/lib
|
||||
conan_ftversion={version}
|
||||
conan_staticlibs="{staticlibs}"
|
||||
""").format(version=version, staticlibs=staticlibs))
|
||||
|
||||
def _extract_libtool_version(self):
|
||||
conf_raw = load(self, os.path.join(self.source_folder, "builds", "unix", "configure.raw"))
|
||||
return re.search(r"^version_info='([0-9:]+)'", conf_raw, flags=re.M).group(1).replace(":", ".")
|
||||
|
||||
@property
|
||||
def _libtool_version_txt(self):
|
||||
return os.path.join(self.package_folder, "res", "freetype-libtool-version.txt")
|
||||
|
||||
def package(self):
|
||||
meson = Meson(self)
|
||||
meson.install()
|
||||
|
||||
# As a workaround to support versions of CMake before 3.29, rename the libfreetype.a static library to freetype.lib on Windows.
|
||||
if self.settings.os == "Windows" and not self.options.shared:
|
||||
rename(self, os.path.join(self.package_folder, "lib", "libfreetype.a"), os.path.join(self.package_folder, "lib", "freetype.lib"))
|
||||
|
||||
ver = Version(self.version)
|
||||
if self.settings.os == "Windows" and self.options.shared and ver >= "2.13.0" and ver < "2.14.0":
|
||||
# Duplicate DLL name for backwards compatibility with earlier recipe revisions
|
||||
# See https://github.com/conan-io/conan-center-index/issues/23768
|
||||
suffix = "d" if self.settings.build_type == "Debug" else ""
|
||||
src = os.path.join(self.package_folder, "bin", "freetype-6.dll")
|
||||
dst = os.path.join(self.package_folder, "bin", f"freetype{suffix}.dll")
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
libtool_version = self._extract_libtool_version()
|
||||
|
||||
save(self, self._libtool_version_txt, libtool_version)
|
||||
self._make_freetype_config(libtool_version)
|
||||
|
||||
doc_folder = os.path.join(self.source_folder, "docs")
|
||||
license_folder = os.path.join(self.package_folder, "licenses")
|
||||
copy(self, "FTL.TXT", doc_folder, license_folder)
|
||||
copy(self, "GPLv2.TXT", doc_folder, license_folder)
|
||||
copy(self, "LICENSE.TXT", doc_folder, license_folder)
|
||||
|
||||
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
|
||||
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
self._create_cmake_module_variables(
|
||||
os.path.join(self.package_folder, self._module_vars_rel_path)
|
||||
)
|
||||
self._create_cmake_module_alias_targets(
|
||||
os.path.join(self.package_folder, self._module_target_rel_path),
|
||||
{"freetype": "Freetype::Freetype"}
|
||||
)
|
||||
|
||||
fix_apple_shared_install_name(self)
|
||||
|
||||
def _create_cmake_module_variables(self, module_file):
|
||||
content = textwrap.dedent(f"""\
|
||||
set(FREETYPE_FOUND TRUE)
|
||||
if(DEFINED Freetype_INCLUDE_DIRS)
|
||||
set(FREETYPE_INCLUDE_DIRS ${{Freetype_INCLUDE_DIRS}})
|
||||
endif()
|
||||
if(DEFINED Freetype_LIBRARIES)
|
||||
set(FREETYPE_LIBRARIES ${{Freetype_LIBRARIES}})
|
||||
endif()
|
||||
set(FREETYPE_VERSION_STRING "{self.version}")
|
||||
""")
|
||||
save(self, module_file, content)
|
||||
|
||||
def _create_cmake_module_alias_targets(self, module_file, targets):
|
||||
content = ""
|
||||
for alias, aliased in targets.items():
|
||||
content += textwrap.dedent("""\
|
||||
if(TARGET {aliased} AND NOT TARGET {alias})
|
||||
add_library({alias} INTERFACE IMPORTED)
|
||||
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
|
||||
endif()
|
||||
""".format(alias=alias, aliased=aliased))
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_vars_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake")
|
||||
|
||||
@property
|
||||
def _module_target_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake")
|
||||
|
||||
@staticmethod
|
||||
def _chmod_plus_x(filename):
|
||||
if os.name == "posix" and (os.stat(filename).st_mode & 0o111) != 0o111:
|
||||
os.chmod(filename, os.stat(filename).st_mode | 0o111)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_module_file_name", "Freetype")
|
||||
self.cpp_info.set_property("cmake_file_name", "freetype")
|
||||
self.cpp_info.set_property("cmake_target_name", "Freetype::Freetype")
|
||||
self.cpp_info.set_property("cmake_target_aliases", ["freetype"]) # other possible target name in upstream config file
|
||||
self.cpp_info.set_property("cmake_build_modules", [self._module_vars_rel_path])
|
||||
self.cpp_info.set_property("pkg_config_name", "freetype2")
|
||||
self.cpp_info.libs = ["freetype"]
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.append("m")
|
||||
self.cpp_info.includedirs.append(os.path.join("include", "freetype2"))
|
||||
|
||||
libtool_version = load(self, self._libtool_version_txt).strip()
|
||||
self.conf_info.define("user.freetype:libtool_version", libtool_version)
|
||||
self.cpp_info.set_property("system_package_version", libtool_version)
|
||||
|
||||
# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
|
||||
self.cpp_info.set_property("component_version", libtool_version)
|
||||
self.cpp_info.filenames["cmake_find_package"] = "Freetype"
|
||||
self.cpp_info.filenames["cmake_find_package_multi"] = "freetype"
|
||||
self.cpp_info.names["cmake_find_package"] = "Freetype"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "Freetype"
|
||||
self.cpp_info.build_modules["cmake_find_package"] = [self._module_vars_rel_path]
|
||||
self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_target_rel_path]
|
||||
self.cpp_info.names["pkg_config"] = "freetype2"
|
||||
freetype_config = os.path.join(self.package_folder, "bin", "freetype-config")
|
||||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
|
||||
self.env_info.FT2_CONFIG = freetype_config
|
||||
self._chmod_plus_x(freetype_config)
|
||||
self.user_info.LIBTOOL_VERSION = libtool_version
|
||||
@@ -0,0 +1,31 @@
|
||||
From 2598fa002859d2af1c846363ff64e72d2ebde16a Mon Sep 17 00:00:00 2001
|
||||
From: Jordan Williams <jordan@jwillikers.com>
|
||||
Date: Mon, 4 Mar 2024 12:14:51 -0600
|
||||
Subject: [PATCH] meson: Use the standard dependency mechanism to find bzip2
|
||||
|
||||
This follows standard conventions in Meson by using the pkg-config file.
|
||||
This change allows Conan to switch to the Meson build system.
|
||||
---
|
||||
meson.build | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index f81de3e2f..c5cb8ea52 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -316,8 +316,10 @@ else
|
||||
endif
|
||||
|
||||
# BZip2 support
|
||||
-bzip2_dep = cc.find_library('bz2',
|
||||
- required: get_option('bzip2'))
|
||||
+bzip2_dep = dependency('bzip2', required: false)
|
||||
+if not bzip2_dep.found()
|
||||
+ bzip2_dep = cc.find_library('bz2', has_headers: ['bzlib.h'], required: get_option('bzip2'))
|
||||
+endif
|
||||
|
||||
if bzip2_dep.found()
|
||||
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_BZIP2']
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -368,7 +368,8 @@ ftoption_h = custom_target('ftoption.h',
|
||||
ft2_sources += ftoption_h
|
||||
ft2_defines += ['-DFT_CONFIG_OPTIONS_H=<ftoption.h>']
|
||||
|
||||
-if host_machine.system() == 'windows'
|
||||
+if host_machine.system() == 'windows' and \
|
||||
+ get_option('default_library') == 'shared'
|
||||
ft2_defines += ['-DDLL_EXPORT=1']
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -373,7 +373,8 @@ ftoption_h = custom_target('ftoption.h',
|
||||
ft2_sources += ftoption_h
|
||||
ft2_defines += ['-DFT_CONFIG_OPTIONS_H=<ftoption.h>']
|
||||
|
||||
-if host_machine.system() == 'windows'
|
||||
+if host_machine.system() == 'windows' and \
|
||||
+ get_option('default_library') == 'shared'
|
||||
ft2_defines += ['-DDLL_EXPORT=1']
|
||||
endif
|
||||
|
||||
7
recipes/freetype/meson/test_package/CMakeLists.txt
Normal file
7
recipes/freetype/meson/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(freetype REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE freetype)
|
||||
BIN
recipes/freetype/meson/test_package/OpenSans-Bold.ttf
Normal file
BIN
recipes/freetype/meson/test_package/OpenSans-Bold.ttf
Normal file
Binary file not shown.
29
recipes/freetype/meson/test_package/conanfile.py
Normal file
29
recipes/freetype/meson/test_package/conanfile.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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", "compiler", "build_type", "arch"
|
||||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
short_paths = True
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", env="conanrun")
|
||||
142
recipes/freetype/meson/test_package/test_package.c
Normal file
142
recipes/freetype/meson/test_package/test_package.c
Normal file
@@ -0,0 +1,142 @@
|
||||
/* example1.c */
|
||||
/* */
|
||||
/* This small program shows how to print a rotated string with the */
|
||||
/* FreeType 2 library. */
|
||||
|
||||
#include "ft2build.h"
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
|
||||
|
||||
/* origin is the upper left corner */
|
||||
unsigned char image[HEIGHT][WIDTH];
|
||||
|
||||
|
||||
/* Replace this function with something useful. */
|
||||
|
||||
void
|
||||
draw_bitmap( FT_Bitmap* bitmap,
|
||||
FT_Int x,
|
||||
FT_Int y)
|
||||
{
|
||||
FT_Int i, j, p, q;
|
||||
FT_Int x_max = x + bitmap->width;
|
||||
FT_Int y_max = y + bitmap->rows;
|
||||
|
||||
|
||||
/* for simplicity, we assume that `bitmap->pixel_mode' */
|
||||
/* is `FT_PIXEL_MODE_GRAY' (i.e., not a bitmap font) */
|
||||
|
||||
for ( i = x, p = 0; i < x_max; i++, p++ )
|
||||
{
|
||||
for ( j = y, q = 0; j < y_max; j++, q++ )
|
||||
{
|
||||
if ( i < 0 || j < 0 ||
|
||||
i >= WIDTH || j >= HEIGHT )
|
||||
continue;
|
||||
|
||||
image[j][i] |= bitmap->buffer[q * bitmap->width + p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc,
|
||||
char** argv )
|
||||
{
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
FT_GlyphSlot slot;
|
||||
FT_Matrix matrix; /* transformation matrix */
|
||||
FT_Vector pen; /* untransformed origin */
|
||||
FT_Error error;
|
||||
|
||||
char* filename;
|
||||
char* text;
|
||||
|
||||
double angle;
|
||||
int target_height;
|
||||
size_t n, num_chars;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s FONT\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
text = "conan-center-index";
|
||||
num_chars = strlen( text );
|
||||
angle = ( 25.0 / 360 ) * 3.14159 * 2; /* use 25 degrees */
|
||||
target_height = HEIGHT;
|
||||
|
||||
error = FT_Init_FreeType( &library ); /* initialize library */
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
error = FT_New_Face( library, filename, 0, &face );/* create face object */
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* use 50pt at 100dpi */
|
||||
error = FT_Set_Char_Size( face, 50 * 64, 0, 100, 0 );
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* cmap selection omitted; */
|
||||
/* for simplicity we assume that the font contains a Unicode cmap */
|
||||
|
||||
slot = face->glyph;
|
||||
|
||||
/* set up matrix */
|
||||
matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
|
||||
matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
|
||||
matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
|
||||
matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );
|
||||
|
||||
/* the pen position in 26.6 cartesian space coordinates; */
|
||||
/* start at (300,200) relative to the upper left corner */
|
||||
pen.x = 300 * 64;
|
||||
pen.y = ( target_height - 200 ) * 64;
|
||||
|
||||
for ( n = 0; n < num_chars; n++ )
|
||||
{
|
||||
/* set transformation */
|
||||
FT_Set_Transform( face, &matrix, &pen );
|
||||
|
||||
/* load glyph image into the slot (erase previous one) */
|
||||
error = FT_Load_Char( face, text[n], FT_LOAD_RENDER);
|
||||
if (error) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* now, draw to our target surface (convert position) */
|
||||
draw_bitmap( &slot->bitmap,
|
||||
slot->bitmap_left,
|
||||
target_height - slot->bitmap_top );
|
||||
|
||||
/* increment pen position */
|
||||
pen.x += slot->advance.x;
|
||||
pen.y += slot->advance.y;
|
||||
}
|
||||
|
||||
FT_Done_Face ( face );
|
||||
FT_Done_FreeType( library );
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
23
recipes/freetype/meson/test_package_module/CMakeLists.txt
Normal file
23
recipes/freetype/meson/test_package_module/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(Freetype REQUIRED MODULE)
|
||||
|
||||
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindFreetype.html
|
||||
# are properly defined in conan generators
|
||||
set(_custom_vars
|
||||
FREETYPE_FOUND
|
||||
FREETYPE_INCLUDE_DIRS
|
||||
FREETYPE_LIBRARIES
|
||||
FREETYPE_VERSION_STRING
|
||||
)
|
||||
foreach(_custom_var ${_custom_vars})
|
||||
if(DEFINED ${_custom_var})
|
||||
message(STATUS "${_custom_var}: ${${_custom_var}}")
|
||||
else()
|
||||
message(FATAL_ERROR "${_custom_var} not defined")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_executable(${PROJECT_NAME} ../test_package/test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Freetype::Freetype)
|
||||
29
recipes/freetype/meson/test_package_module/conanfile.py
Normal file
29
recipes/freetype/meson/test_package_module/conanfile.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
short_paths = True
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", env="conanrun")
|
||||
8
recipes/freetype/meson/test_v1_package/CMakeLists.txt
Normal file
8
recipes/freetype/meson/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(test_package)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package)
|
||||
19
recipes/freetype/meson/test_v1_package/conanfile.py
Normal file
19
recipes/freetype/meson/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package_multi"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", run_environment=True)
|
||||
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(test_package)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package_module
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package_module)
|
||||
19
recipes/freetype/meson/test_v1_package_module/conanfile.py
Normal file
19
recipes/freetype/meson/test_v1_package_module/conanfile.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package"
|
||||
license = "OFL-1.1-no-RFN"
|
||||
|
||||
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")
|
||||
font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf")
|
||||
self.run(f"{bin_path} {font_path}", run_environment=True)
|
||||
Reference in New Issue
Block a user