diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index f24f6bf62b..4d3af3e69e 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -15,6 +15,16 @@ jobs: - php:7.4-cli - php:8.1-cli steps: + - name: Install python3 + run: | + apt-get update -q + apt-get install -qy python3 + - name: Install bazel + run: | + apt-get install -qy wget + mkdir $HOME/bin + wget -O $HOME/bin/bazel https://github.com/bazelbuild/bazel/releases/download/5.3.2/bazel-5.3.2-linux-x86_64 + chmod a+x $HOME/bin/bazel - name: Install git run: | apt-get update -q @@ -23,20 +33,15 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive - - name: Prepare source code - run: | - rm -rf "$GITHUB_WORKSPACE/php/ext/google/protobuf/third_party" - cp -r "$GITHUB_WORKSPACE/third_party" "$GITHUB_WORKSPACE/php/ext/google/protobuf" - cp "$GITHUB_WORKSPACE/LICENSE" "$GITHUB_WORKSPACE/php/ext/google/protobuf" - name: Create package run: | - cd /tmp - rm -rf protobuf-*.tgz - pecl package "$GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml" + cd $GITHUB_WORKSPACE + rm -rf bazel-bin/php/protobuf-*.tgz + $HOME/bin/bazel build php:release - name: Compile extension run: | cd /tmp - MAKE="make -j$(nproc)" pecl install protobuf-*.tgz + MAKE="make -j$(nproc)" pecl install $GITHUB_WORKSPACE/bazel-bin/php/protobuf-*.tgz - name: Enable extension run: docker-php-ext-enable protobuf - name: Inspect extension diff --git a/Makefile.am b/Makefile.am index 4c7c7111d4..681cd8c21c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -809,18 +809,19 @@ php_EXTRA_DIST= \ php/ext/google/protobuf/convert.h \ php/ext/google/protobuf/def.c \ php/ext/google/protobuf/def.h \ + php/ext/google/protobuf/generate_package_xml.sh \ php/ext/google/protobuf/map.c \ php/ext/google/protobuf/map.h \ php/ext/google/protobuf/message.c \ php/ext/google/protobuf/message.h \ php/ext/google/protobuf/names.c \ php/ext/google/protobuf/names.h \ - php/ext/google/protobuf/package.xml \ php/ext/google/protobuf/php-upb.c \ php/ext/google/protobuf/php-upb.h \ php/ext/google/protobuf/php_protobuf.h \ php/ext/google/protobuf/protobuf.c \ php/ext/google/protobuf/protobuf.h \ + php/ext/google/protobuf/template_package.xml \ php/ext/google/protobuf/wkt.inc \ php/ext/google/protobuf/tests/unnecessary_zval.phpt \ php/generate_descriptor_protos.sh \ diff --git a/php/BUILD.bazel b/php/BUILD.bazel index dfb0976fca..7fededadb7 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -2,7 +2,9 @@ # # See also code generation logic under /src/google/protobuf/compiler/php. -load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") +load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix") +load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION") pkg_files( name = "dist_files", @@ -30,3 +32,76 @@ pkg_files( strip_prefix = strip_prefix.from_pkg(""), visibility = ["//pkg:__pkg__"], ) + +################################################################################ +# PECL .tgz Release +################################################################################ + +pkg_files( + name = "php_ext_source_files", + srcs = glob([ + "ext/google/protobuf/*.h", + "ext/google/protobuf/*.c", + ]) + [ + "//:LICENSE", + "ext/google/protobuf/config.m4", + "ext/google/protobuf/wkt.inc", + ], +) + +pkg_files( + name = "utf8_range_files", + srcs = [ + "//third_party/utf8_range:utf8_range_srcs", + "//third_party/utf8_range:LICENSE", + + ], + prefix = "third_party/utf8_range", +) + +pkg_filegroup( + name = "pecl_release_files", + srcs = [ + ":php_ext_source_files", + ":utf8_range_files", + ], + prefix = "protobuf-%s" % PROTOBUF_PHP_VERSION, +) + +# PECL .tgz without package.xml +pkg_tar( + name = "release_without_package", + extension = "tgz", + srcs = [ + ":pecl_release_files", + ], + out = "release_without_package.tgz", +) + +# Generate PECL package.xml +genrule( + name = "generate_package_xml", + srcs = [ + ":release_without_package", + "ext/google/protobuf/template_package.xml", + ], + outs = ["package.xml"], + cmd = " ".join([ + "$(location ext/google/protobuf/generate_package_xml.sh)", + "$(location ext/google/protobuf/template_package.xml)", + PROTOBUF_PHP_VERSION, + "$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')", + "$(location package.xml)" + ]), + tools = ["ext/google/protobuf/generate_package_xml.sh"], +) + +pkg_tar( + name = "release", + extension = "tgz", + srcs = [ + ":pecl_release_files", + ":generate_package_xml", + ], + out = "protobuf-%s.tgz" % PROTOBUF_PHP_VERSION, +) \ No newline at end of file diff --git a/php/ext/google/protobuf/generate_package_xml.sh b/php/ext/google/protobuf/generate_package_xml.sh new file mode 100755 index 0000000000..32287850d0 --- /dev/null +++ b/php/ext/google/protobuf/generate_package_xml.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +template_package_xml=$1 +release_version=$2 +release_files=$3 +out=$4 + +date=$(date +%Y-%m-%d) +time=$(date +%H:%M:%S) + +php_version_array=(${release_version//RC/ }) +api_version=${php_version_array[0]} +if [ ${#php_version_array[@]} -eq 2 ]; then + rc=${php_version_array[1]} + stability='beta' +else + stability='stable' +fi + +files="\\n" +for file in ${release_files//,/ }; do + name=$(echo $file | grep .*[^/]\$ | sed -e "s;protobuf-${release_version}/;;") + if [ ! -z $name ]; then + if [[ $name =~ LICENSE$ ]]; then + role='doc' + else + role='src' + fi + files+=" \\n" + fi +done + +cat $template_package_xml | +sed -e "s;TEMPLATE_DATE;${date};" | +sed -e "s;TEMPLATE_TIME;${time};" | +sed -e "s;TEMPLATE_PHP_RELEASE;${release_version};" | +sed -e "s;TEMPLATE_PHP_API;${api_version};" | +sed -e "s;TEMPLATE_PHP_STABILITY;${stability};g" | +sed -e "s;TEMPLATE_FILES;${files};" > $out \ No newline at end of file diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml deleted file mode 100644 index d8bd2b13f3..0000000000 --- a/php/ext/google/protobuf/package.xml +++ /dev/null @@ -1,1467 +0,0 @@ - - - protobuf - pecl.php.net - Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. - https://developers.google.com/protocol-buffers/ - - Protobuf Team - protobufpackages - protobuf-packages@google.com - yes - - 2022-10-26 - - - 3.21.9 - 3.21.9 - - - stable - stable - - BSD-3-Clause - - * See github.com/protocolbuffers/protobuf/releases for release notes. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7.0.0 - - - 1.4.0 - - - - protobuf - - - - - 3.1.0a1 - 3.1.0a1 - - - alpha - alpha - - 2016-09-23 - - BSD-3-Clause - -First alpha release - - - - - 3.2.0a1 - 3.2.0a1 - - - alpha - alpha - - 2017-01-13 - - BSD-3-Clause - -Second alpha release. - - - - - 3.3.0 - 3.3.0 - - - stable - stable - - 2017-04-28 - - BSD-3-Clause - -GA release. - - - - - 3.3.1 - 3.3.0 - - - stable - stable - - 2017-05-08 - - BSD-3-Clause - -GA release. - - - - - 3.3.2 - 3.3.0 - - - stable - stable - - 2017-06-21 - - BSD-3-Clause - -GA release. - - - - - 3.4.0 - 3.4.0 - - - stable - stable - - 2017-08-16 - - BSD-3-Clause - -GA release. - - - - - 3.4.1 - 3.4.1 - - - stable - stable - - 2017-09-14 - - BSD-3-Clause - -GA release. - - - - - 3.5.0 - 3.5.0 - - - stable - stable - - 2017-11-15 - - BSD-3-Clause - -GA release. - - - - - 3.5.0.1 - 3.5.0.1 - - - stable - stable - - 2017-12-06 - - BSD-3-Clause - -GA release. - - - - - 3.5.1 - 3.5.1 - - - stable - stable - - 2017-12-11 - - BSD-3-Clause - -GA release. - - - - - 3.5.2 - 3.5.2 - - - stable - stable - - 2018-03-06 - - BSD-3-Clause - -G A release. - - - - - 3.6.0 - 3.6.0 - - - stable - stable - - 2018-06-06 - - BSD-3-Clause - -G A release. - - - - - 3.6.1 - 3.6.1 - - - stable - stable - - 2018-08-03 - - BSD-3-Clause - -G A release. - - - - - 3.7.0RC2 - 3.7.0 - - - stable - stable - - 2019-02-1 - - BSD-3-Clause - GA release. - - - - 3.7.0RC3 - 3.7.0 - - - beta - beta - - 2019-02-22 - - BSD-3-Clause - GA release. - - - - 3.7.0 - 3.7.0 - - - stable - stable - - 2019-02-28 - - BSD-3-Clause - GA release. - - - - 3.7.1 - 3.7.1 - - - stable - stable - - 2019-03-25 - - BSD-3-Clause - GA release. - - - - 3.8.0RC1 - 3.8.0 - - - beta - beta - - 2019-04-23 - - BSD-3-Clause - GA release. - - - - 3.8.0 - 3.8.0 - - - stable - stable - - 2019-05-21 - - BSD-3-Clause - GA release. - - - - 3.9.0RC1 - 3.9.0 - - - beta - beta - - 2019-06-17 - - BSD-3-Clause - GA release. - - - - 3.9.0 - 3.9.0 - - - stable - stable - - 2019-07-10 - - BSD-3-Clause - GA release. - - - - 3.9.1 - 3.9.1 - - - stable - stable - - 2019-08-02 - - BSD-3-Clause - GA release. - - - - 3.10.0RC1 - 3.10.0 - - - beta - beta - - 2019-09-04 - - BSD-3-Clause - GA release. - - - - 3.10.0RC1 - 3.10.0 - - - beta - beta - - 2019-09-05 - - BSD-3-Clause - GA release. - - - - 3.10.0 - 3.10.0 - - - stable - stable - - 2019-09-12 - - BSD-3-Clause - GA release. - - - - 3.11.0RC1 - 3.11.0 - - - beta - beta - - 2019-11-15 - - BSD-3-Clause - GA release. - - - - 3.11.0RC2 - 3.11.0 - - - beta - beta - - 2019-11-21 - - BSD-3-Clause - GA release. - - - - 3.11.0 - 3.11.0 - - - stable - stable - - 2019-11-25 - - BSD-3-Clause - GA release. - - - - 3.11.1 - 3.11.1 - - - stable - stable - - 2019-12-02 - - BSD-3-Clause - GA release. - - - - 3.11.2 - 3.11.2 - - - stable - stable - - 2019-12-10 - - BSD-3-Clause - GA release. - - - - 3.11.3 - 3.11.3 - - - stable - stable - - 2020-01-28 - - BSD-3-Clause - GA release. - - - - 3.11.4 - 3.11.4 - - - stable - stable - - 2020-02-12 - - BSD-3-Clause - GA release. - - - - 3.12.0RC1 - 3.12.0 - - - beta - beta - - 2020-04-30 - - BSD-3-Clause - GA release. - - - - 3.12.0RC2 - 3.12.0 - - - beta - beta - - 2020-05-12 - - BSD-3-Clause - GA release. - - - - 3.12.0 - 3.12.0 - - - stable - stable - - 2020-05-15 - - BSD-3-Clause - GA release. - - - - 3.12.1 - 3.12.1 - - - stable - stable - - 2020-05-20 - - BSD-3-Clause - GA release. - - - - 3.12.2 - 3.12.2 - - - stable - stable - - 2020-05-26 - - BSD-3-Clause - GA release. - - - - 3.12.3 - 3.12.3 - - - stable - stable - - 2020-06-01 - - BSD-3-Clause - GA release. - - - - 3.13.0RC1 - 3.13.0 - - - beta - beta - - 2020-08-05 - - BSD-3-Clause - GA release. - - - - 3.13.0RC2 - 3.13.0 - - - beta - beta - - 2020-08-05 - - BSD-3-Clause - GA release. - - - - 3.13.0RC3 - 3.13.0 - - - beta - beta - - 2020-08-12 - - BSD-3-Clause - GA release. - - - - 3.13.0 - 3.13.0 - - - stable - stable - - 2020-08-14 - - BSD-3-Clause - GA release. - - - - 3.13.0.1 - 3.13.0.1 - - - stable - stable - - 2020-10-08 - - BSD-3-Clause - GA release. - - - - 3.14.0RC1 - 3.14.0 - - - beta - beta - - 2020-11-05 - - BSD-3-Clause - - - - - - 3.14.0RC2 - 3.14.0 - - - beta - beta - - 2020-11-10 - - BSD-3-Clause - - - - - - 3.14.0RC3 - 3.14.0 - - - beta - beta - - 2020-11-11 - - BSD-3-Clause - - - - - - 3.14.0 - 3.14.0 - - - stable - stable - - 2020-11-12 - - BSD-3-Clause - - - - - - 3.15.0RC1 - 3.15.0 - - - beta - beta - - 2021-02-05 - - BSD-3-Clause - - - - - - 3.15.0RC2 - 3.15.0 - - - beta - beta - - 2021-02-17 - - BSD-3-Clause - - - - - - 3.15.0 - 3.15.0 - - - stable - stable - - 2021-02-18 - - BSD-3-Clause - - - - - - 3.15.1 - 3.15.1 - - - stable - stable - - 2021-02-19 - - BSD-3-Clause - - - - - - 3.15.2 - 3.15.2 - - - stable - stable - - 2021-02-23 - - BSD-3-Clause - - - - - - 3.15.3 - 3.15.3 - - - stable - stable - - 2021-02-24 - - BSD-3-Clause - - - - - - 3.15.4 - 3.15.4 - - - stable - stable - - 2021-03-02 - - BSD-3-Clause - - - - - - 3.15.5 - 3.15.5 - - - stable - stable - - 2021-03-04 - - BSD-3-Clause - - - - - - 3.15.6 - 3.15.6 - - - stable - stable - - 2021-03-10 - - BSD-3-Clause - - - - - - 3.15.7 - 3.15.7 - - - stable - stable - - 2021-04-02 - - BSD-3-Clause - - - - - - 3.16.0RC1 - 3.16.0 - - - beta - beta - - 2021-04-02 - - BSD-3-Clause - - - - - - 3.16.0RC2 - 3.16.0 - - - beta - beta - - 2021-05-03 - - BSD-3-Clause - - - - - - 3.16.0 - 3.16.0 - - - stable - stable - - 2021-05-05 - - BSD-3-Clause - - - - - - 3.17.0RC1 - 3.17.0 - - - beta - beta - - 2021-05-06 - - BSD-3-Clause - - - - - - 3.17.0RC2 - 3.17.0 - - - beta - beta - - 2021-05-07 - - BSD-3-Clause - - - - - - 3.17.0 - 3.17.0 - - - stable - stable - - 2021-05-11 - - BSD-3-Clause - - - - - - 3.17.1 - 3.17.1 - - - stable - stable - - 2021-05-19 - - BSD-3-Clause - - * Fixed PHP memory leaks and arginfo errors. (#8614) - * Fixed JSON parser to allow multiple values from the same oneof as long as - all but one are null. - - - - - 3.17.2 - 3.17.2 - - - stable - stable - - 2021-05-25 - - BSD-3-Clause - - - - - - 3.17.3 - 3.17.3 - - - stable - stable - - 2021-06-04 - - BSD-3-Clause - - - - - - 3.18.0RC1 - 3.18.0 - - - beta - beta - - 2021-08-18 - - BSD-3-Clause - - - - - - 3.18.0RC2 - 3.18.0 - - - beta - beta - - 2021-08-27 - - BSD-3-Clause - - - - - - 3.18.0 - 3.18.0 - - - stable - stable - - 2021-09-13 - - BSD-3-Clause - - - - - - 3.18.1 - 3.18.1 - - - stable - stable - - 2021-10-04 - - BSD-3-Clause - - - - - - 3.19.0RC1 - 3.19.0 - - - beta - beta - - 2021-10-15 - - BSD-3-Clause - - - - - - 3.19.0RC2 - 3.19.0 - - - beta - beta - - 2021-10-18 - - BSD-3-Clause - - - - - - 3.19.0 - 3.19.0 - - - stable - stable - - 2021-10-19 - - BSD-3-Clause - - - - - - 3.19.1 - 3.19.1 - - - stable - stable - - 2021-10-28 - - BSD-3-Clause - - - - - - 3.19.2 - 3.19.2 - - - stable - stable - - 2022-01-05 - - BSD-3-Clause - - - - - - 3.19.3 - 3.19.3 - - - stable - stable - - 2022-01-11 - - BSD-3-Clause - - - - - - 3.19.4 - 3.19.4 - - - stable - stable - - 2022-01-28 - - 3-Clause BSD License - - - - - - 3.20.0RC1 - 3.20.0 - - - beta - beta - - 2022-03-04 - - BSD-3-Clause - - - - - - 3.20.0RC2 - 3.20.0 - - - beta - beta - - 2022-03-15 - - BSD-3-Clause - - - - - - 3.20.0 - 3.20.0 - - - stable - stable - - 2022-03-25 - - BSD-3-Clause - - - - - - 3.20.1RC1 - 3.20.1 - - - beta - beta - - 2022-04-05 - - BSD-3-Clause - - - - - - 3.20.1 - 3.20.1 - - - stable - stable - - 2022-04-20 - - BSD-3-Clause - - - - - - 3.21.0RC1 - 3.21.0 - - - beta - beta - - 2022-05-10 - - BSD-3-Clause - - - - - - 3.21.0RC2 - 3.21.0 - - - beta - beta - - 2022-05-19 - - BSD-3-Clause - - - - - - 3.21.0 - 3.21.0 - - - stable - stable - - 2022-05-25 - - BSD-3-Clause - - - - - - 3.21.1 - 3.21.1 - - - stable - stable - - 2022-05-27 - - BSD-3-Clause - - - - - - 3.21.2 - 3.21.2 - - - stable - stable - - 2022-06-23 - - BSD-3-Clause - - - - - - 3.21.3 - 3.21.3 - - - stable - stable - - 2022-07-21 - - BSD-3-Clause - - - - - - 3.21.4 - 3.21.4 - - - stable - stable - - 2022-07-25 - - BSD-3-Clause - - - - - - 3.21.5 - 3.21.5 - - - stable - stable - - 2022-08-09 - - BSD-3-Clause - - - - - - 3.21.6 - 3.21.6 - - - stable - stable - - 2022-09-13 - - BSD-3-Clause - - - - - - 3.21.7 - 3.21.7 - - - stable - stable - - 2022-09-29 - - BSD-3-Clause - - - - - - 3.21.8 - 3.21.8 - - - stable - stable - - 2022-10-13 - - BSD-3-Clause - - - - - - 3.21.9 - 3.21.9 - - - stable - stable - - 2022-10-26 - - BSD-3-Clause - - - - - diff --git a/php/ext/google/protobuf/template_package.xml b/php/ext/google/protobuf/template_package.xml new file mode 100644 index 0000000000..c6d2619bb7 --- /dev/null +++ b/php/ext/google/protobuf/template_package.xml @@ -0,0 +1,42 @@ + + + protobuf + pecl.php.net + Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. + https://developers.google.com/protocol-buffers/ + + Protobuf Team + protobufpackages + protobuf-packages@google.com + yes + + TEMPLATE_DATE + + + TEMPLATE_PHP_RELEASE + TEMPLATE_PHP_API + + + TEMPLATE_PHP_STABILITY + TEMPLATE_PHP_STABILITY + + BSD-3-Clause + + * See github.com/protocolbuffers/protobuf/releases for release notes. + + + TEMPLATE_FILES + + + + + 7.0.0 + + + 1.4.0 + + + + protobuf + + \ No newline at end of file diff --git a/protobuf_version.bzl b/protobuf_version.bzl index 4c44f3da5d..3777e23d8a 100644 --- a/protobuf_version.bzl +++ b/protobuf_version.bzl @@ -1,3 +1,4 @@ PROTOC_VERSION = "21.9" PROTOBUF_JAVA_VERSION = "3.21.9" PROTOBUF_PYTHON_VERSION = "4.21.9" +PROTOBUF_PHP_VERSION = "3.21.9" diff --git a/third_party/utf8_range/BUILD.bazel b/third_party/utf8_range/BUILD.bazel index 4a8a82b502..899a93ac66 100644 --- a/third_party/utf8_range/BUILD.bazel +++ b/third_party/utf8_range/BUILD.bazel @@ -1,6 +1,22 @@ # Pulled from: https://github.com/cyb70289/utf8 +exports_files(["LICENSE"]) + +filegroup( + name = "utf8_range_srcs", + srcs = [ + "naive.c", + "range2-neon.c", + "range2-sse.c", + "utf8_range.h", + ], + visibility = [ + "@com_google_protobuf//:__subpackages__", + "@upb//:__subpackages__", + ], +) + cc_library( name = "utf8_range", hdrs = ["utf8_range.h"],