Skip to content

Commit

Permalink
php: simplify installation
Browse files Browse the repository at this point in the history
  • Loading branch information
stanley-cheung committed Feb 24, 2016
1 parent c95bfef commit 5adb71f
Show file tree
Hide file tree
Showing 14 changed files with 1,970 additions and 3 deletions.
28 changes: 28 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,34 @@ node_modules:
- src/node/ext/server.cc
- src/node/ext/server_credentials.cc
- src/node/ext/timeval.cc
php_config_m4:
deps:
- grpc
- gpr
- boringssl
- z
headers:
- src/php/ext/grpc/byte_buffer.h
- src/php/ext/grpc/call.h
- src/php/ext/grpc/call_credentials.h
- src/php/ext/grpc/channel.h
- src/php/ext/grpc/channel_credentials.h
- src/php/ext/grpc/completion_queue.h
- src/php/ext/grpc/php_grpc.h
- src/php/ext/grpc/server.h
- src/php/ext/grpc/server_credentials.h
- src/php/ext/grpc/timeval.h
src:
- src/php/ext/grpc/byte_buffer.c
- src/php/ext/grpc/call.c
- src/php/ext/grpc/call_credentials.c
- src/php/ext/grpc/channel.c
- src/php/ext/grpc/channel_credentials.c
- src/php/ext/grpc/completion_queue.c
- src/php/ext/grpc/php_grpc.c
- src/php/ext/grpc/server.c
- src/php/ext/grpc/server_credentials.c
- src/php/ext/grpc/timeval.c
python_dependencies:
deps:
- grpc
Expand Down
533 changes: 533 additions & 0 deletions config.m4

Large diffs are not rendered by default.

984 changes: 984 additions & 0 deletions package.xml

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions templates/config.m4.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%YAML 1.2
--- |
PHP_ARG_ENABLE(grpc, whether to enable grpc support,
[ --enable-grpc Enable grpc support])

if test "$PHP_GRPC" != "no"; then
dnl Write more examples of tests here...

dnl # --with-grpc -> add include path
PHP_ADD_INCLUDE(../../grpc/include)
PHP_ADD_INCLUDE(../../grpc/src/php/ext/grpc)
PHP_ADD_INCLUDE(../../grpc/third_party/boringssl/include)

PHP_ADD_LIBRARY(pthread)

PHP_NEW_EXTENSION(grpc,
% for source in php_config_m4.src:
${source} ${"\\"}
% endfor
% for lib in libs:
% if lib.name in php_config_m4.get('deps', []):
% for source in lib.src:
${source} ${"\\"}
% endfor
% endif
% endfor
, $ext_shared, , -Wall -Werror -std=c11 ${"\\"}
-fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"}
-D_HAS_EXCEPTIONS=0 -DNOMINMAX)
fi
159 changes: 159 additions & 0 deletions templates/package.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
%YAML 1.2
--- |
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.5" version="2.0" xmlns="http:https://pear.php.net/dtd/package-2.0" xmlns:tasks="http:https://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:https://pear.php.net/dtd/tasks-1.0 http:https://pear.php.net/dtd/tasks-1.0.xsd http:https://pear.php.net/dtd/package-2.0 http:https://pear.php.net/dtd/package-2.0.xsd">
<name>grpc</name>
<channel>pecl.php.net</channel>
<summary>A high performance, open source, general RPC framework that puts mobile and HTTP/2 first.</summary>
<description>Remote Procedure Calls (RPCs) provide a useful abstraction for building distributed applications and services. The libraries in this repository provide a concrete implementation of the gRPC protocol, layered over HTTP/2. These libraries enable communication between clients and servers using any combination of the supported languages.</description>
<lead>
<name>Stanley Cheung</name>
<user>stanleycheung</user>
<email>[email protected]</email>
<active>yes</active>
</lead>
<%! from time import strftime %><date>${"%Y-%m-%d" | strftime}</date>
<time>16:06:07</time>
<version>
<release>0.8.0</release>
<api>0.8.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license>BSD</license>
<notes>
- Simplify gRPC PHP installation #4517
</notes>
<contents>
<dir baseinstalldir="/" name="/">
<file baseinstalldir="/" name="config.m4" role="src" />
<file baseinstalldir="/" name="src/php/ext/grpc/CREDITS" role="src" />
<file baseinstalldir="/" name="src/php/ext/grpc/LICENSE" role="src" />
<file baseinstalldir="/" name="src/php/ext/grpc/README.md" role="src" />
% for source in php_config_m4.src + php_config_m4.headers:
<file baseinstalldir="/" name="${source}" role="src" />
% endfor
% for lib in libs:
% if lib.name in php_config_m4.get('deps', []):
% for source in lib.get('public_headers', []) + lib.headers + lib.src:
<file baseinstalldir="/" name="${source}" role="src" />
% endfor
% endif
% endfor
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.5.0</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>grpc</providesextension>
<extsrcrelease />
<changelog>
<release>
<version>
<release>0.5.0</release>
<api>0.5.0</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
<date>2015-06-16</date>
<license>BSD</license>
<notes>
First alpha release
</notes>
</release>
<release>
<version>
<release>0.5.1</release>
<api>0.5.1</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
<date>2015-07-09</date>
<license>BSD</license>
<notes>
Update to wrap gRPC C Core version 0.10.0
</notes>
</release>
<release>
<version>
<release>0.6.0</release>
<api>0.6.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2015-09-24</date>
<license>BSD</license>
<notes>
- support per message compression disable
- expose per-call host override option
- expose connectivity API
- expose channel target and call peer
- add user-agent
- update to wrap gRPC C core library beta version 0.11.0
</notes>
</release>
<release>
<version>
<release>0.6.1</release>
<api>0.6.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2015-10-21</date>
<license>BSD</license>
<notes>
- fixed undefined constant fatal error when run with apache/nginx #2275
</notes>
</release>
<release>
<version>
<release>0.7.0</release>
<api>0.7.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2016-01-13</date>
<license>BSD</license>
<notes>
- Breaking change to Credentials class (removed) #3765
- Replaced by ChannelCredentials and CallCredentials class #3765
- New plugin based metadata auth API #4394
- Explicit ChannelCredentials::createInsecure() call
</notes>
</release>
<release>
<version>
<release>0.8.0</release>
<api>0.8.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>${"%Y-%m-%d" | strftime}</date>
<license>BSD</license>
<notes>
- Simplify gRPC PHP installation #4517
</notes>
</release>
</changelog>
</package>
13 changes: 13 additions & 0 deletions test/distrib/php/distribtest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$channel = new Grpc\Channel('localhost:1000', [
'credentials' => Grpc\ChannelCredentials::createInsecure()
]);

$deadline = Grpc\Timeval::infFuture();
$call = new Grpc\Call($channel,
'dummy_method',
$deadline);

$call->cancel();
$channel->close();
39 changes: 39 additions & 0 deletions test/distrib/php/run_distrib_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

set -ex

cd $(dirname $0)

cp -r $EXTERNAL_GIT_ROOT/input_artifacts/grpc-php.tgz .

pecl install grpc-php.tgz

php -d extension=grpc.so -d max_execution_time=300 distribtest.php
32 changes: 32 additions & 0 deletions tools/dockerfile/distribtest/php_jessie_x64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FROM debian:jessie

RUN apt-get update && apt-get install -y php5 php5-dev php-pear phpunit
7 changes: 7 additions & 0 deletions tools/dockerfile/grpc_artifact_linux_x64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"


##################
# PHP dependencies

RUN apt-get update && apt-get install -y \
php5 php5-dev php-pear phpunit

RUN mkdir /var/local/jenkins

# Define the default command.
Expand Down
21 changes: 20 additions & 1 deletion tools/run_tests/artifact_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,23 @@ def build_jobspec(self):
['tools/run_tests/build_artifact_node.sh',
self.gyp_arch])

class PHPExtArtifact:
"""Builds PHP native extension"""

def __init__(self, platform, arch):
self.name = 'php_ext_{0}_{1}'.format(platform, arch)
self.platform = platform
self.arch = arch
self.labels = ['artifact', 'php', platform, arch]

def pre_build_jobspecs(self):
return []

def build_jobspec(self):
return create_docker_jobspec(
self.name,
'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch),
'tools/run_tests/build_artifact_php.sh')

class ProtocArtifact:
"""Builds protoc and protoc-plugin artifacts"""
Expand Down Expand Up @@ -299,4 +316,6 @@ def targets():
PythonArtifact('windows', 'x64'),
RubyArtifact('linux', 'x86'),
RubyArtifact('linux', 'x64'),
RubyArtifact('macos', 'x64')])
RubyArtifact('macos', 'x64'),
PHPExtArtifact('linux', 'x64'),
PHPExtArtifact('macos', 'x64')])
40 changes: 40 additions & 0 deletions tools/run_tests/build_artifact_php.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# Copyright 2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PHP_TARGET_ARCH=$1
set -ex

cd $(dirname $0)/../..

mkdir -p artifacts

pear package

cp -r grpc-*.tgz artifacts/grpc-php.tgz
Loading

0 comments on commit 5adb71f

Please sign in to comment.