[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:
30
recipes/libffi/all/conandata.yml
Normal file
30
recipes/libffi/all/conandata.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
sources:
|
||||
"3.4.6":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz"
|
||||
sha256: "b0dea9df23c863a7a50e825440f3ebffabd65df1497108e5d437747843895a4e"
|
||||
"3.4.4":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz"
|
||||
sha256: "d66c56ad259a82cf2a9dfc408b32bf5da52371500b84745f7fb8b645712df676"
|
||||
"3.3":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz"
|
||||
sha256: "72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056"
|
||||
patches:
|
||||
"3.4.6":
|
||||
- patch_file: "patches/0002-3.4.6-fix-libtool-path.patch"
|
||||
- patch_file: "patches/0004-3.4.6-fix-complex-type-msvc.patch"
|
||||
- patch_file: "patches/0005-3.4.4-do-not-install-libraries-to-arch-dependent-directories.patch"
|
||||
- patch_file: "patches/0006-3.4.6-library-no-version-suffix.patch"
|
||||
"3.4.4":
|
||||
- patch_file: "patches/0002-3.4.3-fix-libtool-path.patch"
|
||||
- patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch"
|
||||
- patch_file: "patches/0005-3.4.4-do-not-install-libraries-to-arch-dependent-directories.patch"
|
||||
- patch_file: "patches/0006-3.4.4-library-no-version-suffix.patch"
|
||||
- patch_file: "patches/0007-3.4.3-forward-declare-open_temp_exec_file.patch"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://github.com/libffi/libffi/pull/764"
|
||||
patch_description: "Forward declare the open_temp_exec_file function which is required by the C99 standard"
|
||||
"3.3":
|
||||
- patch_file: "patches/0002-3.3-fix-libtool-path.patch"
|
||||
- patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch"
|
||||
- patch_file: "patches/0005-3.3-do-not-install-libraries-to-arch-dependent-directories.patch"
|
||||
- patch_file: "patches/0006-3.3-library-no-version-suffix.patch"
|
||||
169
recipes/libffi/all/conanfile.py
Normal file
169
recipes/libffi/all/conanfile.py
Normal file
@@ -0,0 +1,169 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rm, rmdir
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime, msvc_runtime_flag, unix_path
|
||||
from conan.tools.scm import Version
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
|
||||
required_conan_version = ">=1.57.0"
|
||||
|
||||
|
||||
class LibffiConan(ConanFile):
|
||||
name = "libffi"
|
||||
description = "A portable, high level programming interface to various calling conventions"
|
||||
license = "MIT"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://sourceware.org/libffi/"
|
||||
topics = ("runtime", "foreign-function-interface", "runtime-library")
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
package_type = "library"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
@property
|
||||
def _settings_build(self):
|
||||
# TODO: Remove for Conan v2
|
||||
return getattr(self, "settings_build", self.settings)
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def validate(self):
|
||||
if is_apple_os(self) and self.settings.arch == "armv8" and Version(self.version) < "3.4.0":
|
||||
raise ConanInvalidConfiguration(f"{self.ref} does not support Apple ARM CPUs")
|
||||
|
||||
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 build_requirements(self):
|
||||
if self._settings_build.os == "Windows":
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
if is_msvc(self):
|
||||
self.tool_requires("automake/1.16.5")
|
||||
|
||||
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()
|
||||
|
||||
yes_no = lambda v: "yes" if v else "no"
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.configure_args.extend([
|
||||
f"--enable-debug={yes_no(self.settings.build_type == 'Debug')}",
|
||||
"--enable-builddir=no",
|
||||
"--enable-docs=no",
|
||||
])
|
||||
|
||||
if self._settings_build.compiler == "apple-clang":
|
||||
tc.configure_args.append("--disable-multi-os-directory")
|
||||
|
||||
if self.options.shared:
|
||||
tc.extra_defines.append("FFI_BUILDING_DLL")
|
||||
if Version(self.version) < "3.4.6":
|
||||
tc.extra_defines.append("FFI_BUILDING")
|
||||
elif not self.options.shared:
|
||||
tc.extra_defines.append("FFI_STATIC_BUILD")
|
||||
|
||||
env = tc.environment()
|
||||
if self._settings_build.os == "Windows" and (is_msvc(self) or self.settings.compiler == "clang"):
|
||||
build = "{}-{}-{}".format(
|
||||
"x86_64" if self._settings_build.arch == "x86_64" else "i686",
|
||||
"pc" if self._settings_build.arch == "x86" else "win64",
|
||||
"mingw64")
|
||||
host = "{}-{}-{}".format(
|
||||
"x86_64" if self.settings.arch == "x86_64" else "i686",
|
||||
"pc" if self.settings.arch == "x86" else "win64",
|
||||
"mingw64")
|
||||
tc.update_configure_args({
|
||||
"--build": build,
|
||||
"--host": host
|
||||
})
|
||||
|
||||
if is_msvc(self) and check_min_vs(self, "180", raise_invalid=False):
|
||||
# https://github.com/conan-io/conan/issues/6514
|
||||
tc.extra_cflags.append("-FS")
|
||||
|
||||
if is_msvc_static_runtime(self):
|
||||
tc.extra_defines.append("USE_STATIC_RTL")
|
||||
if "d" in msvc_runtime_flag(self):
|
||||
tc.extra_defines.append("USE_DEBUG_RTL")
|
||||
|
||||
architecture_flag = ""
|
||||
if is_msvc(self):
|
||||
if self.settings.arch == "x86_64":
|
||||
architecture_flag = "-m64"
|
||||
elif self.settings.arch == "x86":
|
||||
architecture_flag = "-m32"
|
||||
elif self.settings.compiler == "clang":
|
||||
architecture_flag = "-clang-cl"
|
||||
|
||||
compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh"))
|
||||
if architecture_flag:
|
||||
compile_wrapper = f"{compile_wrapper} {architecture_flag}"
|
||||
|
||||
ar_wrapper = unix_path(self, self.dependencies.build["automake"].conf_info.get("user.automake:lib-wrapper"))
|
||||
env.define("CC", f"{compile_wrapper}")
|
||||
env.define("CXX", f"{compile_wrapper}")
|
||||
env.define("LD", "link -nologo")
|
||||
env.define("AR", f"{ar_wrapper} \"lib -nologo\"")
|
||||
env.define("NM", "dumpbin -symbols")
|
||||
env.define("OBJDUMP", ":")
|
||||
env.define("RANLIB", ":")
|
||||
env.define("STRIP", ":")
|
||||
env.define("CXXCPP", "cl -nologo -EP")
|
||||
env.define("CPP", "cl -nologo -EP")
|
||||
env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh")))
|
||||
env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh")))
|
||||
tc.generate(env=env)
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
|
||||
autotools = Autotools(self)
|
||||
autotools.configure()
|
||||
autotools.make()
|
||||
|
||||
def package(self):
|
||||
autotools = Autotools(self)
|
||||
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem
|
||||
fix_apple_shared_install_name(self)
|
||||
mkdir(self, os.path.join(self.package_folder, "bin"))
|
||||
for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")):
|
||||
shutil.move(dll, os.path.join(self.package_folder, "bin"))
|
||||
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
|
||||
rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True)
|
||||
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.libs = ["{}ffi".format("lib" if is_msvc(self) else "")]
|
||||
self.cpp_info.set_property("pkg_config_name", "libffi")
|
||||
if not self.options.shared:
|
||||
static_define = "FFI_STATIC_BUILD" if Version(self.version) >= "3.4.6" else "FFI_BUILDING"
|
||||
self.cpp_info.defines = [static_define]
|
||||
20
recipes/libffi/all/patches/0002-3.3-fix-libtool-path.patch
Normal file
20
recipes/libffi/all/patches/0002-3.3-fix-libtool-path.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
--- configure
|
||||
+++ configure
|
||||
@@ -8964,7 +8964,7 @@
|
||||
LIBTOOL_DEPS=$ltmain
|
||||
|
||||
# Always use our own libtool.
|
||||
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
||||
+LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh'
|
||||
|
||||
|
||||
|
||||
@@ -9057,7 +9057,7 @@
|
||||
esac
|
||||
|
||||
# Global variables:
|
||||
-ofile=libtool
|
||||
+ofile=libtool.sh
|
||||
can_build_shared=yes
|
||||
|
||||
# All known linkers require a '.a' archive for static linking (except MSVC,
|
||||
20
recipes/libffi/all/patches/0002-3.4.3-fix-libtool-path.patch
Normal file
20
recipes/libffi/all/patches/0002-3.4.3-fix-libtool-path.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
--- configure
|
||||
+++ configure
|
||||
@@ -9940,7 +9940,7 @@
|
||||
LIBTOOL_DEPS=$ltmain
|
||||
|
||||
# Always use our own libtool.
|
||||
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
||||
+LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh'
|
||||
|
||||
|
||||
|
||||
@@ -10032,7 +10032,7 @@
|
||||
esac
|
||||
|
||||
# Global variables:
|
||||
-ofile=libtool
|
||||
+ofile=libtool.sh
|
||||
can_build_shared=yes
|
||||
|
||||
# All known linkers require a '.a' archive for static linking (except MSVC and
|
||||
20
recipes/libffi/all/patches/0002-3.4.6-fix-libtool-path.patch
Normal file
20
recipes/libffi/all/patches/0002-3.4.6-fix-libtool-path.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
--- configure
|
||||
+++ configure
|
||||
@@ -9882,7 +9882,7 @@
|
||||
LIBTOOL_DEPS=$ltmain
|
||||
|
||||
# Always use our own libtool.
|
||||
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
||||
+LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh'
|
||||
|
||||
|
||||
|
||||
@@ -9974,7 +9974,7 @@
|
||||
esac
|
||||
|
||||
# Global variables:
|
||||
-ofile=libtool
|
||||
+ofile=libtool.sh
|
||||
can_build_shared=yes
|
||||
|
||||
# All known linkers require a '.a' archive for static linking (except MSVC and
|
||||
@@ -0,0 +1,56 @@
|
||||
--- src/types.c
|
||||
+++ src/types.c
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
+#include <complex.h>
|
||||
+
|
||||
/* Type definitions */
|
||||
|
||||
#define FFI_TYPEDEF(name, type, id, maybe_const)\
|
||||
@@ -45,17 +47,17 @@
|
||||
id, NULL \
|
||||
}
|
||||
|
||||
-#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \
|
||||
+#define FFI_COMPLEX_TYPEDEF(name, complex_type, maybe_const) \
|
||||
static ffi_type *ffi_elements_complex_##name [2] = { \
|
||||
(ffi_type *)(&ffi_type_##name), NULL \
|
||||
}; \
|
||||
struct struct_align_complex_##name { \
|
||||
char c; \
|
||||
- _Complex type x; \
|
||||
+ complex_type x; \
|
||||
}; \
|
||||
FFI_EXTERN \
|
||||
maybe_const ffi_type ffi_type_complex_##name = { \
|
||||
- sizeof(_Complex type), \
|
||||
+ sizeof(complex_type), \
|
||||
offsetof(struct struct_align_complex_##name, x), \
|
||||
FFI_TYPE_COMPLEX, \
|
||||
(ffi_type **)ffi_elements_complex_##name \
|
||||
@@ -99,10 +101,20 @@
|
||||
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST);
|
||||
#endif
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+# define FLOAT_COMPLEX _C_float_complex
|
||||
+# define DOUBLE_COMPLEX _C_double_complex
|
||||
+# define LDOUBLE_COMPLEX _C_ldouble_complex
|
||||
+#else
|
||||
+# define FLOAT_COMPLEX float _Complex
|
||||
+# define DOUBLE_COMPLEX double _Complex
|
||||
+# define LDOUBLE_COMPLEX long double _Complex
|
||||
+#endif
|
||||
+
|
||||
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
|
||||
-FFI_COMPLEX_TYPEDEF(float, float, const);
|
||||
-FFI_COMPLEX_TYPEDEF(double, double, const);
|
||||
+FFI_COMPLEX_TYPEDEF(float, FLOAT_COMPLEX, const);
|
||||
+FFI_COMPLEX_TYPEDEF(double, DOUBLE_COMPLEX, const);
|
||||
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
||||
-FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST);
|
||||
+FFI_COMPLEX_TYPEDEF(longdouble, LDOUBLE_COMPLEX, FFI_LDBL_CONST);
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
diff --git a/src/types.c b/src/types.c
|
||||
index c1c27f3..d5d52bb 100644
|
||||
--- a/src/types.c
|
||||
+++ b/src/types.c
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
+#include <complex.h>
|
||||
+
|
||||
/* Type definitions */
|
||||
|
||||
#define FFI_TYPEDEF(name, type, id, maybe_const)\
|
||||
@@ -45,17 +47,17 @@ maybe_const ffi_type ffi_type_##name = { \
|
||||
id, NULL \
|
||||
}
|
||||
|
||||
-#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \
|
||||
+#define FFI_COMPLEX_TYPEDEF(name, complex_type, maybe_const) \
|
||||
static ffi_type *ffi_elements_complex_##name [2] = { \
|
||||
(ffi_type *)(&ffi_type_##name), NULL \
|
||||
}; \
|
||||
struct struct_align_complex_##name { \
|
||||
char c; \
|
||||
- _Complex type x; \
|
||||
+ complex_type x; \
|
||||
}; \
|
||||
FFI_EXTERN \
|
||||
maybe_const ffi_type ffi_type_complex_##name = { \
|
||||
- sizeof(_Complex type), \
|
||||
+ sizeof(complex_type), \
|
||||
offsetof(struct struct_align_complex_##name, x), \
|
||||
FFI_TYPE_COMPLEX, \
|
||||
(ffi_type **)ffi_elements_complex_##name \
|
||||
@@ -99,8 +101,18 @@ const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
|
||||
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST);
|
||||
#endif
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+# define FLOAT_COMPLEX _C_float_complex
|
||||
+# define DOUBLE_COMPLEX _C_double_complex
|
||||
+# define LDOUBLE_COMPLEX _C_ldouble_complex
|
||||
+#else
|
||||
+# define FLOAT_COMPLEX float _Complex
|
||||
+# define DOUBLE_COMPLEX double _Complex
|
||||
+# define LDOUBLE_COMPLEX long double _Complex
|
||||
+#endif
|
||||
+
|
||||
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
|
||||
-FFI_COMPLEX_TYPEDEF(float, float, const);
|
||||
-FFI_COMPLEX_TYPEDEF(double, double, const);
|
||||
-FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST);
|
||||
+FFI_COMPLEX_TYPEDEF(float, FLOAT_COMPLEX, const);
|
||||
+FFI_COMPLEX_TYPEDEF(double, DOUBLE_COMPLEX, const);
|
||||
+FFI_COMPLEX_TYPEDEF(longdouble, LDOUBLE_COMPLEX, FFI_LDBL_CONST);
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
--- Makefile.in
|
||||
+++ Makefile.in
|
||||
@@ -510,7 +510,7 @@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
toolexecdir = @toolexecdir@
|
||||
-toolexeclibdir = @toolexeclibdir@
|
||||
+toolexeclibdir = @libdir@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/Makefile.in b/Makefile.in
|
||||
index 86eb4a5..450200a 100644
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -521,7 +521,7 @@ target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
tmake_file = @tmake_file@
|
||||
toolexecdir = @toolexecdir@
|
||||
-toolexeclibdir = @toolexeclibdir@
|
||||
+toolexeclibdir = @libdir@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
@@ -0,0 +1,11 @@
|
||||
--- Makefile.in
|
||||
+++ Makefile.in
|
||||
@@ -613,7 +613,7 @@
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep =
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun
|
||||
-libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
|
||||
+libffi_version_info = -avoid-version
|
||||
libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/Makefile.in b/Makefile.in
|
||||
index 450200a..abcee85 100644
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -616,7 +616,7 @@ AM_CFLAGS = $(am__append_3)
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep =
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun
|
||||
-libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
|
||||
+libffi_version_info = -avoid-version
|
||||
libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/Makefile.in b/Makefile.in
|
||||
index 450200a..abcee85 100644
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -618,7 +618,7 @@ AM_CFLAGS = $(am__append_3)
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep =
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map
|
||||
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun
|
||||
-libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
|
||||
+libffi_version_info = -avoid-version
|
||||
libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
|
||||
@@ -0,0 +1,30 @@
|
||||
diff --git a/include/ffi_common.h b/include/ffi_common.h
|
||||
index 2bd31b0..c53a794 100644
|
||||
--- a/include/ffi_common.h
|
||||
+++ b/include/ffi_common.h
|
||||
@@ -128,6 +128,10 @@ void *ffi_data_to_code_pointer (void *data) FFI_HIDDEN;
|
||||
static trampoline. */
|
||||
int ffi_tramp_is_present (void *closure) FFI_HIDDEN;
|
||||
|
||||
+/* Return a file descriptor of a temporary zero-sized file in a
|
||||
+ writable and executable filesystem. */
|
||||
+int open_temp_exec_file(void) FFI_HIDDEN;
|
||||
+
|
||||
/* Extended cif, used in callback from assembly routine */
|
||||
typedef struct
|
||||
{
|
||||
diff --git a/src/tramp.c b/src/tramp.c
|
||||
index b9d273a..c3f4c99 100644
|
||||
--- a/src/tramp.c
|
||||
+++ b/src/tramp.c
|
||||
@@ -39,6 +39,10 @@
|
||||
#ifdef __linux__
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
+
|
||||
+#include <ffi.h>
|
||||
+#include <ffi_common.h>
|
||||
+
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
8
recipes/libffi/all/test_package/CMakeLists.txt
Normal file
8
recipes/libffi/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(libffi REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE libffi::libffi)
|
||||
10
recipes/libffi/all/test_package/CMakeUserPresets.json
Normal file
10
recipes/libffi/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"
|
||||
]
|
||||
}
|
||||
37
recipes/libffi/all/test_package/conanfile.py
Normal file
37
recipes/libffi/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,37 @@
|
||||
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 VirtualRunEnv
|
||||
from conan.tools.microsoft import msvc_runtime_flag
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
test_type = "explicit"
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def generate(self):
|
||||
cmake_deps = CMakeDeps(self)
|
||||
cmake_deps.generate()
|
||||
tc = CMakeToolchain(self)
|
||||
if "d" in msvc_runtime_flag(self):
|
||||
tc.preprocessor_definitions["DISABLE_FFI_CALL"] = 1
|
||||
tc.generate()
|
||||
virtual_run_env = VirtualRunEnv(self)
|
||||
virtual_run_env.generate()
|
||||
|
||||
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")
|
||||
99
recipes/libffi/all/test_package/test_package.c
Normal file
99
recipes/libffi/all/test_package/test_package.c
Normal file
@@ -0,0 +1,99 @@
|
||||
#if defined(_MSC_VER)
|
||||
#pragma runtime_checks("s", off)
|
||||
#endif
|
||||
|
||||
#include <ffi.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned print_uint(unsigned arg) {
|
||||
printf("print_int(%u)\n", arg);
|
||||
return 3 * arg;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
FILE *stream;
|
||||
} puts_binding_userdata;
|
||||
|
||||
void puts_binding(ffi_cif *cif, void *ret, void** args, void *userdata)
|
||||
{
|
||||
fputs(*(char **)args[0], ((puts_binding_userdata *)userdata)->stream);
|
||||
*((unsigned*)ret) = 1337;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
ffi_type *argtypes[1] = {&ffi_type_uint32};
|
||||
ffi_cif cif;
|
||||
ffi_status status = FFI_BAD_ABI;
|
||||
status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint32, argtypes);
|
||||
if (status != FFI_OK)
|
||||
{
|
||||
puts("1 ffi_prep_cif FAILED.\n\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#ifndef DISABLE_FFI_CALL
|
||||
// this fails on msvc debug runtime because of https://github.com/libffi/libffi/issues/456
|
||||
unsigned rvalue = 0;
|
||||
unsigned arg1 = 13;
|
||||
const unsigned expected_ret = 3 * arg1;
|
||||
void *args[] = {(void*)(&arg1)};
|
||||
ffi_call(&cif, FFI_FN(&print_uint), (void *) &rvalue, args);
|
||||
printf("ffi_call returns %d (should be %d)\n", rvalue, expected_ret);
|
||||
if (rvalue != expected_ret) {
|
||||
printf("ffi_call FAILED. Expected %d, but got %d.\n", expected_ret, rvalue);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
{
|
||||
#ifdef FFI_CLOSURES
|
||||
ffi_type *argtypes[1] = {&ffi_type_uint};
|
||||
ffi_cif cif;
|
||||
ffi_status status = FFI_BAD_ABI;
|
||||
status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint32, argtypes);
|
||||
if (status != FFI_OK)
|
||||
{
|
||||
puts("2 ffi_prep_cif FAILED.\n\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
unsigned (*bound_puts)(const char *) = NULL;
|
||||
ffi_closure *closure = NULL;
|
||||
closure = (ffi_closure *) ffi_closure_alloc(sizeof(ffi_closure), (void **)&bound_puts);
|
||||
if (closure == NULL) {
|
||||
puts("ffi_closure_alloc FAILED\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
puts_binding_userdata userdata;
|
||||
userdata.stream = stdout;
|
||||
status = ffi_prep_closure_loc(closure, &cif, puts_binding,
|
||||
&userdata, (void *) bound_puts);
|
||||
if (status != FFI_OK) {
|
||||
puts("ffi_prep_closure_loc FAILED\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
puts("Start calling bound_put():");
|
||||
bound_puts("Hello");
|
||||
bound_puts(" ");
|
||||
bound_puts("World");
|
||||
unsigned rc = bound_puts("\n");
|
||||
printf("bounds_puts returned %d.\n", rc);
|
||||
if (rc != 1337) {
|
||||
puts("bounds_put returned wrong number.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ffi_closure_free(closure);
|
||||
#endif
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma runtime_checks("s", restore)
|
||||
#endif
|
||||
11
recipes/libffi/all/test_v1_package/CMakeLists.txt
Normal file
11
recipes/libffi/all/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package C)
|
||||
|
||||
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
|
||||
conan_basic_setup()
|
||||
if(CONAN_SETTINGS_COMPILER_RUNTIME MATCHES ".*d")
|
||||
add_compile_definitions(DISABLE_FFI_CALL)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ../test_package/test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
|
||||
17
recipes/libffi/all/test_v1_package/conanfile.py
Normal file
17
recipes/libffi/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", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user