[DO-973] harfbuzz package (!10)

Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/10
This commit is contained in:
Aleksandr Vodyanov
2024-12-26 12:02:17 +03:00
parent 39afe6a1dd
commit c807f2514e
126 changed files with 6604 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.4)
project(elf LANGUAGES C)
if(EXISTS "${LIBELF_SRC_DIR}/lib/sys_elf.h.w32")
file(RENAME "${LIBELF_SRC_DIR}/lib/sys_elf.h.w32" "${LIBELF_SRC_DIR}/lib/sys_elf.h")
file(RENAME "${LIBELF_SRC_DIR}/lib/config.h.w32" "${LIBELF_SRC_DIR}/lib/config.h")
endif()
file(GLOB_RECURSE SOURCES "${LIBELF_SRC_DIR}/lib/*.c")
file(GLOB_RECURSE HEADERS "${LIBELF_SRC_DIR}/lib/*.h")
add_library(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES
PUBLIC_HEADER "${HEADERS}"
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
)
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${LIBELF_SRC_DIR}/lib")
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_MEMCMP=1 HAVE_MEMCPY=1 HAVE_MEMMOVE=1 HAVE_CONFIG_H=1)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libelf
)
install(FILES "${LIBELF_SRC_DIR}/lib/libelf.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES "${LIBELF_SRC_DIR}/lib/gelf.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES "${LIBELF_SRC_DIR}/lib/nlist.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

View File

@@ -0,0 +1,4 @@
sources:
"0.8.13":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-fossies_org/linux/misc/old/libelf-0.8.13.tar.gz"
sha256: "591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d"

View File

@@ -0,0 +1,119 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, replace_in_file, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import unix_path
import os
required_conan_version = ">=1.54.0"
class LibelfConan(ConanFile):
name = "libelf"
description = "ELF object file access library"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://directory.fsf.org/wiki/Libelf"
license = "LGPL-2.0"
topics = ("elf", "fsf", "libelf", "object-file")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
exports_sources = "CMakeLists.txt"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.settings.os not in ["Linux", "FreeBSD", "Windows"]:
self.options.rm_safe("shared")
self.package_type = "static-library"
if self.options.get_safe("shared"):
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
if self.settings.os == "Windows":
cmake_layout(self, src_folder="src")
else:
basic_layout(self, src_folder="src")
def build_requirements(self):
if self.settings.os != "Windows":
# self.tool_requires("autoconf/2.71")
# self.tool_requires("gnu-config/cci.20210814")
if self.settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
if self.settings.os == "Windows":
tc = CMakeToolchain(self)
tc.variables["LIBELF_SRC_DIR"] = self.source_folder.replace("\\", "/")
tc.generate()
else:
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.configure_args.extend([
# it's required, libelf doesnt seem to understand DESTDIR
f"--prefix={unix_path(self, self.package_folder)}",
])
tc.generate()
def build(self):
if self.settings.os == "Windows":
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
cmake.build()
else:
replace_in_file(self, os.path.join(self.source_folder, "lib", "Makefile.in"),
"$(LINK_SHLIB)",
"$(LINK_SHLIB) $(LDFLAGS)")
# libelf sources contains really outdated 'config.sub' and
# 'config.guess' files. It not allows to build libelf for armv8 arch.
for gnu_config in [
self.conf.get("user.gnu-config:config_guess", check_type=str),
self.conf.get("user.gnu-config:config_sub", check_type=str),
]:
if gnu_config:
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder)
autotools = Autotools(self)
autotools.autoreconf()
autotools.configure()
autotools.make()
def package(self):
copy(self, "COPYING.LIB", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
if self.settings.os == "Windows":
cmake = CMake(self)
cmake.install()
else:
autotools = Autotools(self)
autotools.install()
rmdir(self, os.path.join(self.package_folder, "lib", "locale"))
if self.options.get_safe("shared"):
rm(self, "*.a", os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.set_property("pkg_config_name", "libelf")
self.cpp_info.libs = ["elf"]
self.cpp_info.includedirs.append(os.path.join("include", "libelf"))

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(libelf REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE libelf::libelf)

View 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"
]
}

View File

@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "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")

View File

@@ -0,0 +1,114 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#ifdef _MSC_VER
#include <io.h>
#else
#include <unistd.h>
#endif
#include "libelf.h"
int main(int argc , char **argv) {
int fd;
Elf *e;
const char *k;
Elf_Kind ek;
if (elf_version(EV_CURRENT) == EV_NONE) {
printf("ELF library initialization failed: %s\n", elf_errmsg ( -1));
return EXIT_FAILURE;
}
#ifdef _WIN32
return EXIT_SUCCESS;
#endif
#ifdef _MSVC_VER
if ((fd = _open(argv[0], _O_RDONLY , 0)) < 0) {
#else
if ((fd = open(argv[0], O_RDONLY , 0)) < 0) {
#endif
printf("open %s failed\n", argv [0]);
return EXIT_FAILURE;
}
if(ELF_C_NULL != 0)
{
printf("ELF_C_NULL has wrong value: %d\n", ELF_C_NULL);
return EXIT_FAILURE;
}
if(ELF_C_READ != 1)
{
printf("ELF_C_READ has wrong value: %d\n", ELF_C_READ);
return EXIT_FAILURE;
}
if(ELF_C_WRITE != 2)
{
printf("ELF_C_WRITE has wrong value: %d\n", ELF_C_WRITE);
return EXIT_FAILURE;
}
if(ELF_C_CLR != 3)
{
printf("ELF_C_CLR has wrong value: %d\n", ELF_C_CLR);
return EXIT_FAILURE;
}
if(ELF_C_SET != 4)
{
printf("ELF_C_SET has wrong value: %d\n", ELF_C_SET);
return EXIT_FAILURE;
}
if(ELF_C_FDDONE != 5)
{
printf("ELF_C_FDDONE has wrong value: %d\n", ELF_C_FDDONE);
return EXIT_FAILURE;
}
if(ELF_C_FDREAD != 6)
{
printf("ELF_C_FDREAD has wrong value: %d\n", ELF_C_FDREAD);
return EXIT_FAILURE;
}
if(ELF_C_RDWR != 7)
{
printf("ELF_C_RDWR has wrong value: %d\n", ELF_C_RDWR);
return EXIT_FAILURE;
}
if(ELF_C_NUM != 8)
{
printf("ELF_C_NUM has wrong value: %d\n", ELF_C_NUM);
return EXIT_FAILURE;
}
if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
printf("elf_begin () failed: %s.\n", elf_errmsg ( -1));
return EXIT_FAILURE;
}
ek = elf_kind(e);
switch (ek) {
case ELF_K_AR:
k = "ar(1) archive";
break;
case ELF_K_ELF:
k = "elf object";
break;
case ELF_K_NONE:
k = "data";
break;
default:
k = "unrecognized";
}
printf("%s: %s\n", argv[0], k);
elf_end(e);
#ifdef _MSVC_VER
_close(fd);
#else
close(fd);
#endif
return EXIT_SUCCESS;
}