summaryrefslogtreecommitdiff
path: root/wrappers/php/Makefile
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2022-01-24 14:59:25 +0100
committerStevenWdV <stevenwdv@gmail.com>2022-01-24 16:24:57 +0100
commite544c6fa9e15e7277da79e2464243e90b2706b8c (patch)
treede6613747e0e34a799089d4677f9833a85748712 /wrappers/php/Makefile
parentaab2e4b966c82b67eb0e204060e5ea6cd4ea15cf (diff)
Cleanup
Added variables to Makefiles to specify custom exports/ directory; Split exception classes in Java & C#; Added more comments; Renamed library and Go package; Removed real (pure) tests; Added generate_lib.ps1 to generate import .lib for Windows (Swift); Moved built Go libraries to exports/lib/; Switch to hopefully faster Swift GitHub Action.
Diffstat (limited to 'wrappers/php/Makefile')
-rw-r--r--wrappers/php/Makefile38
1 files changed, 32 insertions, 6 deletions
diff --git a/wrappers/php/Makefile b/wrappers/php/Makefile
index 06c49f1..e0262e9 100644
--- a/wrappers/php/Makefile
+++ b/wrappers/php/Makefile
@@ -1,25 +1,51 @@
.PHONY: install-header test install-dev-dependencies clean
-ifneq (clean,$(MAKECMDGOALS))
-include ../../exports/platform.mk
+EXPORTS_PATH ?= ../../exports
+EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib
+ifneq ($(MAKECMDGOALS),clean)
+include $(EXPORTS_PATH)/platform.mk
+
+# Add phpunit to PATH
export PATH := $(abspath vendor/bin):$(PATH)
endif
+ifeq ($(COPY_LIB),1)
+COPY_LIB_DIR = lib
+endif
+
+ifneq ($(COPY_LIB_DIR),)
+COPY_LIB_DIR := $(COPY_LIB_DIR)/
+endif
+
+# Strip / replace elements confusing PHP's limited C parser: __SIZE_TYPE__, _Complex, extern "C"
+# Also add FFI_LIB library name, see https://www.php.net/manual/en/ffi.load
install-header:
- $(MAKE) -C ../../exports
+ifneq ($(EXPORTS_PATH),)
+ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),)
+ $(MAKE) -C "$(EXPORTS_PATH)"
+endif
+endif
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 "$(LIB_PREFIX)eduvpn_verify$(LIB_SUFFIX)"\n\n/' \
- "../../exports/$(GOOS)/$(GOARCH)/eduvpn_verify.h" > src/headers/eduvpn_verify_php.h
+ \
+ -e 's/^/#define FFI_LIB "$(subst /,\/,$(COPY_LIB_DIR))$(LIB_FILE)"\n\n/' \
+ \
+ "$(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH)/$(LIB_NAME).h" > src/headers/$(LIB_NAME)_php.h
+ifeq ($(COPY_LIB),1)
+ install "$(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH)/$(LIB_FILE)" -Dt "$(COPY_LIB_DIR)"
+endif
test: install-header install-dev-dependencies
phpunit
+# Try: composer, composer.phar, ./composer.phar, ./composer
+# check-platform-reqs is needed because of config.platform in composer.json, see https://getcomposer.org/doc/06-config.md#platform
install-dev-dependencies:
if command -v composer; then \
composer install && composer check-platform-reqs; \
@@ -31,4 +57,4 @@ install-dev-dependencies:
fi
clean:
- rm -rf vendor/ .phpunit* src/headers/*.h
+ rm -rf vendor/ .phpunit* src/headers/*.h lib/*