summaryrefslogtreecommitdiff
path: root/wrappers/php/Makefile
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2021-12-17 15:21:53 +0100
committerStevenWdV <stevenwdv@gmail.com>2021-12-17 15:24:59 +0100
commita47513aeeb728b6316ba6765afdd7e5adbf4f2e3 (patch)
tree2ebb3a6936af606b0276f67d4cebb446d60cc610 /wrappers/php/Makefile
parenta4d394a8794a254a102b8fa3bf311d4c59f9e9b5 (diff)
Add PHP wrapper, use header for right platform for PHP & Swift, simplify Swift Windows fix
Diffstat (limited to 'wrappers/php/Makefile')
-rw-r--r--wrappers/php/Makefile41
1 files changed, 41 insertions, 0 deletions
diff --git a/wrappers/php/Makefile b/wrappers/php/Makefile
new file mode 100644
index 0000000..bab4305
--- /dev/null
+++ b/wrappers/php/Makefile
@@ -0,0 +1,41 @@
+.PHONY: install-header test install-dev-dependencies clean
+
+ifneq (clean,$(MAKECMDGOALS))
+GOOS != go env GOHOSTOS
+GOARCH != go env GOHOSTARCH
+
+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:
+ $(MAKE) -C ../../exports
+ mkdir -p src/headers
+ sed --null-data \
+ -e 's/DO NOT EDIT/Modified for PHP/' \
+ -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/' \
+ "../../exports/$(GOOS)/$(GOARCH)/eduvpn_verify.h" > src/headers/eduvpn_verify_php.h
+
+test: install-header install-dev-dependencies
+ phpunit
+
+install-dev-dependencies:
+ if command -v composer; then \
+ composer install && composer check-platform-reqs; \
+ elif command -v composer.phar; then \
+ composer.phar install && composer.phar check-platform-reqs; \
+ else \
+ ./composer.phar install && ./composer.phar check-platform-reqs || \
+ ./composer install && ./composer check-platform-reqs; \
+ fi
+
+clean:
+ rm -rf vendor/ .phpunit* src/headers/*.h