summaryrefslogtreecommitdiff
path: root/wrappers/php
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2021-12-17 16:39:51 +0100
committerStevenWdV <stevenwdv@gmail.com>2021-12-17 16:39:51 +0100
commita79995670baf0ae755cbbe78c5d77fc49575d342 (patch)
tree4c98d0962b9ef02b652c418f217f0d365c3139f9 /wrappers/php
parenta47513aeeb728b6316ba6765afdd7e5adbf4f2e3 (diff)
Fix PHP wrapper on Unix, extract common platform detection logic
Diffstat (limited to 'wrappers/php')
-rw-r--r--wrappers/php/Makefile11
-rw-r--r--wrappers/php/src/Impl/GoSlice.php4
2 files changed, 4 insertions, 11 deletions
diff --git a/wrappers/php/Makefile b/wrappers/php/Makefile
index bab4305..06c49f1 100644
--- a/wrappers/php/Makefile
+++ b/wrappers/php/Makefile
@@ -1,16 +1,9 @@
.PHONY: install-header test install-dev-dependencies clean
ifneq (clean,$(MAKECMDGOALS))
-GOOS != go env GOHOSTOS
-GOARCH != go env GOHOSTARCH
+include ../../exports/platform.mk
export PATH := $(abspath vendor/bin):$(PATH)
-
-ifeq (Windows_NT,$(OS))
-export PATH := $(abspath ../../exports/$(GOOS)/$(GOARCH)):$(PATH)
-else
-export LD_LIBRARY_PATH := $(abspath ../../exports/$(GOOS)/$(GOARCH)):$(LD_LIBRARY_PATH)
-endif
endif
install-header:
@@ -21,7 +14,7 @@ install-header:
-e 's/__SIZE_TYPE__/size_t/g' \
-e 's/[^\n]*_Complex[^\n]*//g' \
-e 's/#ifdef __cplusplus[^#]*#endif//g' \
- -e 's/^/#define FFI_LIB "eduvpn_verify"\n\n/' \
+ -e 's/^/#define FFI_LIB "$(LIB_PREFIX)eduvpn_verify$(LIB_SUFFIX)"\n\n/' \
"../../exports/$(GOOS)/$(GOARCH)/eduvpn_verify.h" > src/headers/eduvpn_verify_php.h
test: install-header install-dev-dependencies
diff --git a/wrappers/php/src/Impl/GoSlice.php b/wrappers/php/src/Impl/GoSlice.php
index 441b460..b285cfd 100644
--- a/wrappers/php/src/Impl/GoSlice.php
+++ b/wrappers/php/src/Impl/GoSlice.php
@@ -18,12 +18,12 @@ class GoSlice
{
$len = strlen($data);
$cData = FFI::new(FFI::arrayType(FFI::type('char'), [$len]), false);
- if (!$cData) throw new RuntimeException('error allocating buffer');
+ if ($cData === null) throw new RuntimeException('error allocating buffer');
$this->cData = $cData;
FFI::memcpy($cData, $data, $len);
$slice = $ffi->new('GoSlice');
- if (!$slice) throw new RuntimeException('error allocating buffer');
+ if ($slice === null) throw new RuntimeException('error allocating buffer');
$this->slice = $slice;
$slice->data = FFI::addr($cData); // $cData must not be destroyed while $slice is in use
$slice->cap = $slice->len = $len;