[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:
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
|
||||
Reference in New Issue
Block a user