diff options
| author | StevenWdV <stevenwdv@gmail.com> | 2022-02-04 01:18:12 +0100 |
|---|---|---|
| committer | StevenWdV <stevenwdv@gmail.com> | 2022-02-04 01:18:12 +0100 |
| commit | b60ecf2fe5ddfe506e02093286b3931873187e91 (patch) | |
| tree | b3804b1b95e70e96dec98cb0c2b571e0b895ebdd /wrappers | |
| parent | bb85487e40b47d701e64085e7574cb477a431f1e (diff) | |
More Makefile cleanup, support building in folder with spaces
Diffstat (limited to 'wrappers')
| -rw-r--r-- | wrappers/csharp/Makefile | 11 | ||||
| -rw-r--r-- | wrappers/csharp/README.md | 4 | ||||
| -rw-r--r-- | wrappers/java/Makefile | 9 | ||||
| -rw-r--r-- | wrappers/java/README.md | 3 | ||||
| -rw-r--r-- | wrappers/php/Makefile | 38 | ||||
| -rw-r--r-- | wrappers/php/README.md | 2 | ||||
| -rw-r--r-- | wrappers/python/Makefile | 15 | ||||
| -rw-r--r-- | wrappers/python/README.md | 2 | ||||
| -rw-r--r-- | wrappers/swift/Makefile | 21 | ||||
| -rw-r--r-- | wrappers/swift/README.md | 7 |
10 files changed, 39 insertions, 73 deletions
diff --git a/wrappers/csharp/Makefile b/wrappers/csharp/Makefile index 29f9682..e120c7a 100644 --- a/wrappers/csharp/Makefile +++ b/wrappers/csharp/Makefile @@ -1,8 +1,10 @@ .PHONY: build pack test clean EXPORTS_PATH ?= ../../exports +include $(EXPORTS_PATH)/common.mk + # Export, see EduVpnCommon.props -export EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib +export EXPORTS_LIB_PATH build: dotnet publish EduVpnCommon.csproj --configuration Release @@ -10,12 +12,7 @@ build: pack: dotnet pack EduVpnCommon.csproj --configuration Release -test: -ifneq ($(EXPORTS_PATH),) -ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),) - $(MAKE) -C "$(EXPORTS_PATH)" -endif -endif +test: .try_build_lib dotnet test clean: diff --git a/wrappers/csharp/README.md b/wrappers/csharp/README.md index 32d2330..553b123 100644 --- a/wrappers/csharp/README.md +++ b/wrappers/csharp/README.md @@ -22,8 +22,8 @@ Build as nupkg, including shared Go library for all platforms built in `exports/ make pack ``` -If you do not build this as part of the full repository, specify `EXPORTS_PATH="" EXPORTS_LIB_PATH="path/to/lib-folder"` -when calling make. +If you do not build this as part of the full repository, specify `EXPORTS_PATH="path/to/exports-folder"` +when calling make. This folder must contain `common.mk` and the `lib/` folder with built libraries. The wrapper targets .NET Standard 2.0, which means that it can be referenced by projects using either .NET Framework 4.6.1+, .NET Core 2.0+, or .NET 5+. diff --git a/wrappers/java/Makefile b/wrappers/java/Makefile index a63aef7..ebb8103 100644 --- a/wrappers/java/Makefile +++ b/wrappers/java/Makefile @@ -1,7 +1,7 @@ .PHONY: build pack test clean EXPORTS_PATH ?= ../../exports -EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib +include $(EXPORTS_PATH)/common.mk build: mvn --no-transfer-progress compile -DEXPORTS_LIB_PATH="$(EXPORTS_LIB_PATH)" @@ -9,12 +9,7 @@ build: pack: mvn --no-transfer-progress package -DEXPORTS_LIB_PATH="$(EXPORTS_LIB_PATH)" -test: -ifneq ($(EXPORTS_PATH),) -ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),) - $(MAKE) -C "$(EXPORTS_PATH)" -endif -endif +test: .try_build_lib mvn --no-transfer-progress test -DEXPORTS_LIB_PATH="$(EXPORTS_LIB_PATH)" clean: diff --git a/wrappers/java/README.md b/wrappers/java/README.md index b72d90e..e19075b 100644 --- a/wrappers/java/README.md +++ b/wrappers/java/README.md @@ -24,6 +24,9 @@ make pack The JAR will include all versions of the library that are built in the `exports` folder. +If you do not build this as part of the full repository, specify `EXPORTS_PATH="path/to/exports-folder"` +when calling make. This folder must contain `common.mk` and the `lib/` folder with built libraries. + Test: ```shell diff --git a/wrappers/php/Makefile b/wrappers/php/Makefile index e0262e9..5384d92 100644 --- a/wrappers/php/Makefile +++ b/wrappers/php/Makefile @@ -1,31 +1,21 @@ .PHONY: install-header test install-dev-dependencies clean EXPORTS_PATH ?= ../../exports -EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib - -ifneq ($(MAKECMDGOALS),clean) -include $(EXPORTS_PATH)/platform.mk +include $(EXPORTS_PATH)/common.mk # Add phpunit to PATH export PATH := $(abspath vendor/bin):$(PATH) -endif ifeq ($(COPY_LIB),1) -COPY_LIB_DIR = lib +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: -ifneq ($(EXPORTS_PATH),) -ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),) - $(MAKE) -C "$(EXPORTS_PATH)" -endif -endif +install-header: .try_build_lib mkdir -p src/headers sed --null-data \ -e 's/DO NOT EDIT/Modified for PHP/' \ @@ -36,25 +26,25 @@ endif \ -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)" + "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_NAME).h" >src/headers/$(LIB_NAME)_php.h +ifneq ($(COPY_LIB_DIR),) + install "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_FILE)" -Dt "$(COPY_LIB_DIR)" endif test: install-header install-dev-dependencies phpunit +composers = composer composer.phar ./composer ./composer.phar +# Find first composer from list above, default to 'composer' +find_composer = $(firstword $(foreach bin,$(composers),$(if $(shell command -v $(bin)),$(bin),)) composer) +# Lazy variable: https://blog.jgc.org/2016/07/lazy-gnu-make-variables.html +COMPOSER ?= $(eval COMPOSER := $(find_composer))$(COMPOSER) + # 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; \ - 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 + $(COMPOSER) install + $(COMPOSER) check-platform-reqs clean: rm -rf vendor/ .phpunit* src/headers/*.h lib/* diff --git a/wrappers/php/README.md b/wrappers/php/README.md index b5cafa2..01e4d3e 100644 --- a/wrappers/php/README.md +++ b/wrappers/php/README.md @@ -32,4 +32,4 @@ When using this library, you will need to make sure that the linker can find the pass `COPY_LIB=1` to `make install-header` to copy the library over to this folder and load it via this relative path. If you do not build this as part of the full repository, specify `EXPORTS_PATH="path/to/exports-folder"` when calling -make. This folder must contain `platform.mk` and the `lib/` folder with built libraries and headers. +make. This folder must contain `common.mk` and the `lib/` folder with built libraries and headers. diff --git a/wrappers/python/Makefile b/wrappers/python/Makefile index ba4cf5f..f46f06d 100644 --- a/wrappers/python/Makefile +++ b/wrappers/python/Makefile @@ -1,11 +1,7 @@ .PHONY: pack test clean EXPORTS_PATH ?= ../../exports -EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib - -ifneq ($(MAKECMDGOALS),clean) -include $(EXPORTS_PATH)/platform.mk -endif +include $(EXPORTS_PATH)/common.mk ifdef PLAT_NAME SETUP_ARGS += --plat-name=$(PLAT_NAME) @@ -15,13 +11,8 @@ endif pack: ./setup.py bdist_wheel $(SETUP_ARGS) --exports-lib-path="$(EXPORTS_LIB_PATH)" -test: -ifneq ($(EXPORTS_PATH),) -ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),) - $(MAKE) -C "$(EXPORTS_PATH)" -endif -endif - install "$(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH)/$(LIB_FILE)" -Dt "eduvpncommon/lib" +test: .try_build_lib + install "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_FILE)" -Dt "eduvpncommon/lib" python3 -m unittest test_discovery rm eduvpncommon/lib/* diff --git a/wrappers/python/README.md b/wrappers/python/README.md index bce492e..6f0bec1 100644 --- a/wrappers/python/README.md +++ b/wrappers/python/README.md @@ -34,7 +34,7 @@ You could also reference the discovery module directly and copy the library for folder. If you do not build this as part of the full repository, specify `EXPORTS_PATH="path/to/exports-folder"` when calling -make. This folder must contain `platform.mk` and the `lib/` folder with built libraries. +make. This folder must contain `common.mk` and the `lib/` folder with built libraries. Test: diff --git a/wrappers/swift/Makefile b/wrappers/swift/Makefile index b46a177..6dca0ef 100644 --- a/wrappers/swift/Makefile +++ b/wrappers/swift/Makefile @@ -1,33 +1,22 @@ .PHONY: build test install-header clean EXPORTS_PATH ?= ../../exports -EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib - -ifneq ($(MAKECMDGOALS),clean) -include $(EXPORTS_PATH)/platform.mk - -LIB_DIR = $(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH) +include $(EXPORTS_PATH)/common.mk ifeq ($(OS),Windows_NT) SWIFT = ./swift.cmd else SWIFT = swift endif -endif build: install-header - $(SWIFT) build --configuration release -Xlinker -L"$(LIB_DIR)" + $(SWIFT) build --configuration release -Xlinker -L"$(EXPORTS_LIB_SUBFOLDER_PATH)" test: install-header - $(SWIFT) test --parallel -Xlinker -L"$(LIB_DIR)" + $(SWIFT) test --parallel -Xlinker -L"$(EXPORTS_LIB_SUBFOLDER_PATH)" -install-header: -ifneq ($(EXPORTS_PATH),) -ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),) - $(MAKE) -C "$(EXPORTS_PATH)" -endif -endif - install "$(LIB_DIR)/$(LIB_NAME).h" -Dt CEduVpnCommon/Sources/CEduVpnCommon/Headers # Copy header for modulemap +install-header: .try_build_lib + install "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_NAME).h" -Dt CEduVpnCommon/Sources/CEduVpnCommon/Headers # Copy header for modulemap clean: rm -rf .build/ CEduVpnCommon/Sources/CEduVpnCommon/Headers/*.h diff --git a/wrappers/swift/README.md b/wrappers/swift/README.md index f28b028..9b0fdfe 100644 --- a/wrappers/swift/README.md +++ b/wrappers/swift/README.md @@ -21,11 +21,12 @@ make GOOS=linux GOARCH=amd64 When using this library, you will need to make sure that the linker can find the shared Go library. -<small>On Windows, you will also need to generate a .lib import library for the .dll. You can +<details><summary>Windows</summary><small> +On Windows, you will also need to generate a .lib import library for the .dll. You can use `exports/generate_lib.ps1` for this, passing in the path to the DLL file. Execute this from a Visual Studio Developer shell before building the Swift project. Alternatively, you could use `objdump` and `llvm-dlltool`. You only need to update this if the list of -exported symbols changes.</small> +exported symbols changes.</small></details> If you just want to copy over the C header file to the right directory for the modulemap in `CEduVpnCommon`, run: @@ -34,7 +35,7 @@ make install-header ``` If you do not build this as part of the full repository, specify `EXPORTS_PATH="path/to/exports-folder"` when calling -make. This folder must contain `platform.mk` and the `lib/` folder with built libraries and headers. +make. This folder must contain `common.mk` and the `lib/` folder with built libraries and headers. Test: |
