mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-17 17:47:12 +00:00
Windows build (#29)
* Added build instruction updates for Windows to README * Added composer to requirements
This commit is contained in:
@@ -194,6 +194,8 @@ config.nice
|
||||
*.la
|
||||
Makefile*
|
||||
!Makefile.am
|
||||
!Makefile.frag
|
||||
!Makefile.frag.w32
|
||||
/vendor/
|
||||
.idea/
|
||||
.DS_Store
|
||||
|
||||
+10
-14
@@ -1,8 +1,5 @@
|
||||
|
||||
BUILD_DIR=$(shell pwd)/build
|
||||
DEPS_DIR=$(BUILD_DIR)/deps
|
||||
INT_DIR=$(BUILD_DIR)/install
|
||||
INSTALL_DIR=$(shell pwd)
|
||||
INT_DIR=build/install
|
||||
GENERATE_STUBS=$(shell expr `php --version | head -1 | cut -f 2 -d' '` \>= 7.1)
|
||||
HAS_FFI=$(shell php -m | grep FFI | wc -l | xargs)
|
||||
|
||||
@@ -11,7 +8,7 @@ ifeq (, $(shell which cmake3))
|
||||
CMAKE = cmake
|
||||
endif
|
||||
|
||||
CMAKE_CONFIGURE = $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(INT_DIR) -DCMAKE_PREFIX_PATH=$(INT_DIR) -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
|
||||
CMAKE_CONFIGURE = $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(INT_DIR) -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
|
||||
CMAKE_BUILD = $(CMAKE) --build
|
||||
CMAKE_BUILD_TYPE ?= RelWithDebInfo
|
||||
CMAKE_TARGET = --config $(CMAKE_BUILD_TYPE) --target install
|
||||
@@ -20,11 +17,11 @@ all: extension ffi
|
||||
.PHONY: all extension ffi
|
||||
|
||||
# configure for static aws-crt-ffi.a
|
||||
$(BUILD_DIR)/aws-crt-ffi-static/CMakeCache.txt:
|
||||
build/aws-crt-ffi-static/CMakeCache.txt:
|
||||
$(CMAKE_CONFIGURE) -Hcrt/aws-crt-ffi -Bbuild/aws-crt-ffi-static -DBUILD_SHARED_LIBS=OFF
|
||||
|
||||
# build static libaws-crt-ffi.a
|
||||
$(BUILD_DIR)/aws-crt-ffi-static/libaws-crt-ffi.a: $(BUILD_DIR)/aws-crt-ffi-static/CMakeCache.txt
|
||||
build/aws-crt-ffi-static/libaws-crt-ffi.a: build/aws-crt-ffi-static/CMakeCache.txt
|
||||
$(CMAKE_BUILD) build/aws-crt-ffi-static $(CMAKE_TARGET)
|
||||
|
||||
# PHP extension target
|
||||
@@ -33,7 +30,7 @@ extension: ext/awscrt.lo
|
||||
# Force the crt object target to depend on the CRT static library
|
||||
ext/awscrt.lo: ext/awscrt.c
|
||||
|
||||
ext/awscrt.c: $(BUILD_DIR)/aws-crt-ffi-static/libaws-crt-ffi.a ext/api.h ext/awscrt_arginfo.h
|
||||
ext/awscrt.c: build/aws-crt-ffi-static/libaws-crt-ffi.a ext/api.h ext/awscrt_arginfo.h
|
||||
|
||||
ext/awscrt_arginfo.h: ext/awscrt.stub.php gen_stub.php
|
||||
ifeq ($(GENERATE_STUBS),1)
|
||||
@@ -43,7 +40,7 @@ endif
|
||||
|
||||
# transform/install api.h from FFI lib
|
||||
src/api.h: crt/aws-crt-ffi/src/api.h
|
||||
cat crt/aws-crt-ffi/src/api.h | grep -v AWS_EXTERN_C | sed -e 's/AWS_CRT_API //' | grep -ve '^#' > src/api.h
|
||||
php gen_api.php crt/aws-crt-ffi/src/api.h > src/api.h
|
||||
|
||||
# install api.h to ext/ as well
|
||||
ext/api.h : src/api.h
|
||||
@@ -55,21 +52,21 @@ ext/php_aws_crt.h: ext/awscrt_arginfo.h ext/api.h
|
||||
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:
|
||||
build/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
|
||||
build/aws-crt-ffi-shared/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME): build/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
|
||||
src/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME): $(BUILD_DIR)/aws-crt-ffi-shared/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME) src/api.h
|
||||
src/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME): build/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)
|
||||
cp -v build/aws-crt-ffi-shared/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME) src/libaws-crt-ffi.$(SHLIB_SUFFIX_NAME)
|
||||
endif
|
||||
|
||||
vendor/bin/phpunit:
|
||||
@@ -85,4 +82,3 @@ test-extension: vendor/bin/phpunit extension
|
||||
|
||||
# Use PHPUnit to run tests
|
||||
test: test-ffi test-extension
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
CMAKE=cmake.exe
|
||||
COMPOSER_PHAR=C:\ProgramData\ComposerSetup\bin\composer.phar
|
||||
PHP_BINARY=$(PHP_PREFIX)\php.exe
|
||||
|
||||
CMAKE_CONFIGURE = $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(AWSCRT_DIR)\build\install -DCMAKE_PREFIX_PATH=$(AWSCRT_DIR)\build\install -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
|
||||
CMAKE_BUILD = $(CMAKE) --build
|
||||
CMAKE_BUILD_TYPE = Release
|
||||
CMAKE_TARGET = --config $(CMAKE_BUILD_TYPE) --target install
|
||||
|
||||
# configure for static aws-crt-ffi.lib
|
||||
$(AWSCRT_DIR)\build\CMakeCache.txt:
|
||||
$(CMAKE_CONFIGURE) -H$(AWSCRT_DIR)\crt\aws-crt-ffi -B$(AWSCRT_DIR)\build -DBUILD_SHARED_LIBS=OFF
|
||||
|
||||
# build static libaws-crt-ffi.lib
|
||||
$(AWSCRT_DIR)\build\libaws-crt-ffi.lib: $(AWSCRT_DIR)\build\CMakeCache.txt
|
||||
$(CMAKE_BUILD) $(AWSCRT_DIR)\build $(CMAKE_TARGET)
|
||||
|
||||
# Force the awscrt extension DLL target to depend on the extension src
|
||||
$(BUILD_DIR)\php_awscrt.dll: $(AWSCRT_DIR)\ext\awscrt.c
|
||||
|
||||
$(AWSCRT_DIR)\ext\awscrt.c: $(AWSCRT_DIR)\build\libaws-crt-ffi.lib $(AWSCRT_DIR)\ext\api.h $(AWSCRT_DIR)\ext\awscrt_arginfo.h
|
||||
|
||||
# transform\install api.h from FFI lib
|
||||
$(AWSCRT_DIR)\src\api.h: $(AWSCRT_DIR)\crt\aws-crt-ffi\src\api.h
|
||||
php $(AWSCRT_DIR)\gen_api.php $(AWSCRT_DIR)\crt\aws-crt-ffi\src\api.h > $(AWSCRT_DIR)\src\api.h
|
||||
|
||||
# install api.h to ext/ as well
|
||||
$(AWSCRT_DIR)\ext\api.h : $(AWSCRT_DIR)\src\api.h
|
||||
copy $(AWSCRT_DIR)\src\api.h $(AWSCRT_DIR)\ext\api.h
|
||||
|
||||
# Use PHPUnit to run tests
|
||||
test-awscrt: install $(AWSCRT_DIR)\src\api.h $(BUILD_DIR)\php_awscrt.dll
|
||||
$(PHP_BINARY) -c $(AWSCRT_DIR)\php-win.ini $(COMPOSER_PHAR) --working-dir=$(AWSCRT_DIR) update
|
||||
$(PHP_BINARY) -c $(AWSCRT_DIR)\php-win.ini $(COMPOSER_PHAR) --working-dir=$(AWSCRT_DIR) run test-win
|
||||
@@ -1,9 +1,10 @@
|
||||
# AWS Common Runtime PHP bindings
|
||||
|
||||
## Requirements
|
||||
* PHP 5.6+
|
||||
* PHP 5.5+ on UNIX platforms, 7.2+ on Windows
|
||||
* CMake 3.x
|
||||
* GCC 4.4+, clang 3.8+
|
||||
* GCC 4.4+, clang 3.8+ on UNIX, Visual Studio 2017 build tools on Windows
|
||||
* Tests require [Composer](https://getcomposer.org)
|
||||
|
||||
## Building on UNIX
|
||||
```sh
|
||||
@@ -14,6 +15,42 @@ $ ./configure
|
||||
$ make && make test
|
||||
```
|
||||
|
||||
## Building on Windows
|
||||
* First, ensure that you are able to build PHP on windows via the PHP SDK (this example assumes installation of the SDK to C:\php-sdk and that you've checked out the PHP source to php-src within the build directory). The following resources are helpful to get PHP building on windows:
|
||||
* https://github.com/microsoft/php-sdk-binary-tools
|
||||
* https://medium.com/@erinus/how-to-build-php-on-windows-a7ad0a87862a
|
||||
* https://medium.com/@erinus/how-to-build-php-extension-on-windows-d1667290f809
|
||||
|
||||
```bat
|
||||
""" From VS2017 Command Prompt
|
||||
> C:\php-sdk\phpsdk-vc15-x64.bat
|
||||
|
||||
C:\php-sdk\
|
||||
$ phpsdk_buildtree php-<version>
|
||||
|
||||
C:\php-sdk\php-<version>\vc15\x64\
|
||||
$ git clone https://github.com/php/php-src.git && cd php-src
|
||||
|
||||
""" This only has to be done once, the first time you set this all up
|
||||
C:\php-sdk\php-<version>\vc15\x64\php-src
|
||||
$ phpsdk_deps --update --branch <php-major.minor-version>
|
||||
|
||||
C:\php-sdk\php-<version>\vc15\x64\php-src
|
||||
$ git clone --recursive https://github.com/awslabs/aws-crt-php.git ..\pecl\awscrt
|
||||
|
||||
C:\php-sdk\php-<version>\vc15\x64\php-src
|
||||
$ buildconf
|
||||
|
||||
C:\php-sdk\php-<version>\vc15\x64\php-src
|
||||
$ configure --enable-cli --with-openssl --enable-awscrt=shared
|
||||
|
||||
C:\php-sdk\php-<version>\vc15\x64\php-src
|
||||
$ nmake
|
||||
|
||||
C:\php-sdk\php-<version>\vc15\x64\php-src
|
||||
$ nmake test-awscrt
|
||||
```
|
||||
|
||||
## Security
|
||||
|
||||
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
|
||||
@@ -21,4 +58,3 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
|
||||
## License
|
||||
|
||||
This project is licensed under the Apache-2.0 License.
|
||||
|
||||
|
||||
+4
-3
@@ -29,9 +29,10 @@
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "@php -d extension=modules/awscrt.so vendor/bin/phpunit tests",
|
||||
"test-extension": "@php -d extension=modules/awscrt.so vendor/bin/phpunit tests",
|
||||
"test-ffi": "@php vendor/bin/phpunit tests"
|
||||
"test": "./run_tests",
|
||||
"test-extension": "@test",
|
||||
"test-ffi": "@php vendor/bin/phpunit tests",
|
||||
"test-win": "run_tests"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_ENABLE("awscrt", "Include AWS Common Runtime support", "yes");
|
||||
|
||||
if (PHP_AWSCRT != "no") {
|
||||
ADD_MAKEFILE_FRAGMENT();
|
||||
DEFINE('CFLAGS_AWSCRT', '/I ' + configure_module_dirname + '\\build\\install\\include');
|
||||
DEFINE('LIBS_AWSCRT', '/LIBPATH:' + configure_module_dirname + '\\build\\install\\lib ' +
|
||||
'aws-crt-ffi.lib aws-c-auth.lib aws-c-http.lib aws-c-io.lib aws-c-cal.lib aws-c-compression.lib aws-c-common.lib ' +
|
||||
'ncrypt.lib Secur32.lib Crypt32.lib Shlwapi.lib');
|
||||
DEFINE('AWSCRT_DIR', configure_module_dirname);
|
||||
EXTENSION("awscrt", "ext\\awscrt.c", PHP_AWSCRT_SHARED);
|
||||
}
|
||||
+1
-1
Submodule crt/aws-crt-ffi updated: 61f7a7adcc...14b72a2fda
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$source = "php://stdin";
|
||||
if (isset($argv[1])) {
|
||||
$source = $argv[1];
|
||||
}
|
||||
|
||||
$input_lines = file($source);
|
||||
foreach ($input_lines as $line) {
|
||||
// Strip AWS_EXTERN_C_BEGIN/END
|
||||
if (preg_match('/AWS_EXTERN_C/', $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Strip macros/includes
|
||||
if (preg_match('/^#/', $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Strip visibility attributes
|
||||
$line = str_replace('AWS_CRT_API ', '', $line);
|
||||
|
||||
echo($line);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
extension=php_awscrt.dll
|
||||
extension=php_openssl.dll
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
$PHP_BINARY -c php.ini vendor/bin/phpunit tests
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
@echo on
|
||||
|
||||
%PHP_BINARY% -c php-win.ini vendor/bin/phpunit tests
|
||||
@@ -1,2 +0,0 @@
|
||||
ffi.enable=preload
|
||||
opcache.preload=preload.php
|
||||
Reference in New Issue
Block a user