Restored FFI to working order (#28)

* Restored FFI to working order

* Disabled incompatible tests, fixed string conversion

* Use extension_loaded instead of checking PHP version

* Added better checks for FFI

* Do not build FFI deps if no FFI is present
This commit is contained in:
Justin Boswell
2021-06-16 11:26:31 -07:00
committed by GitHub
parent d2546e616d
commit f6f9a6b349
12 changed files with 172 additions and 20 deletions
+34 -14
View File
@@ -4,6 +4,7 @@ DEPS_DIR=$(BUILD_DIR)/deps
INT_DIR=$(BUILD_DIR)/install
INSTALL_DIR=$(shell pwd)
GENERATE_STUBS=$(shell expr `php --version | head -1 | cut -f 2 -d' '` \>= 7.1)
HAS_FFI=$(shell php -m | grep FFI | wc -l | xargs)
CMAKE = cmake3
ifeq (, $(shell which cmake3))
@@ -15,13 +16,8 @@ CMAKE_BUILD = $(CMAKE) --build
CMAKE_BUILD_TYPE ?= RelWithDebInfo
CMAKE_TARGET = --config $(CMAKE_BUILD_TYPE) --target install
# configure for shared aws-crt-ffi.so
$(BUILD_DIR)/aws-crt-ffi-shared/CMakeCache.txt:
$(CMAKE_CONFIGURE) -Hcrt/aws-crt-ffi -Bbuild/aws-crt-ffi-shared -DBUILD_SHARED_LIBS=ON
# build shared libaws-crt-ffi.so
$(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.so: $(BUILD_DIR)/aws-crt-ffi-shared/CMakeCache.txt
$(CMAKE_BUILD) build/aws-crt-ffi-shared $(CMAKE_TARGET)
all: extension ffi
.PHONY: all extension ffi
# configure for static aws-crt-ffi.a
$(BUILD_DIR)/aws-crt-ffi-static/CMakeCache.txt:
@@ -32,7 +28,7 @@ $(BUILD_DIR)/aws-crt-ffi-static/libaws-crt-ffi.a: $(BUILD_DIR)/aws-crt-ffi-stati
$(CMAKE_BUILD) build/aws-crt-ffi-static $(CMAKE_TARGET)
# PHP extension target
awscrt: ext/awscrt.lo
extension: ext/awscrt.lo
# Force the crt object target to depend on the CRT static library
ext/awscrt.lo: ext/awscrt.c
@@ -56,13 +52,37 @@ ext/api.h : src/api.h
ext/php_aws_crt.h: ext/awscrt_arginfo.h ext/api.h
# FFI target
ffi: src/libaws-crt-ffi.so
ffi: src/api.h src/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME)
# configure for shared aws-crt-ffi.so
$(BUILD_DIR)/aws-crt-ffi-shared/CMakeCache.txt:
ifeq ($(HAS_FFI),1)
$(CMAKE_CONFIGURE) -Hcrt/aws-crt-ffi -Bbuild/aws-crt-ffi-shared -DBUILD_SHARED_LIBS=ON
endif
# build shared libaws-crt-ffi.so
$(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME): $(BUILD_DIR)/aws-crt-ffi-shared/CMakeCache.txt
ifeq ($(HAS_FFI),1)
$(CMAKE_BUILD) build/aws-crt-ffi-shared $(CMAKE_TARGET)
endif
# copy the lib into the src folder
modules/libaws-crt-ffi.so: $(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.so src/api.h
cp -v $(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.so modules/libaws-crt-ffi.so
src/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME): $(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME) src/api.h
ifeq ($(HAS_FFI),1)
cp -v $(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME) src/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME)
endif
vendor/bin/phpunit:
composer update
test-ffi: vendor/bin/phpunit ffi
ifeq ($(HAS_FFI),1)
AWS_CRT_PHP_FFI=1 composer run test-ffi
endif
test-extension: vendor/bin/phpunit extension
AWS_CRT_PHP_EXTENSION=1 composer run test-extension
# Use PHPUnit to run tests
test: ext/api.h ext/awscrt_arginfo.h ext/awscrt.lo
composer update
composer run test
test: test-ffi test-extension