From 9cc343f17508f1d15ae5d57ed5abce4aed6ee2bb Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Tue, 25 Oct 2022 21:21:58 +0000 Subject: [PATCH 01/16] add bazel rule for generating package.xml with src/doc filegoups --- BUILD.bazel | 7 + php/ext/google/protobuf/BUILD.bazel | 76 + php/ext/google/protobuf/package.xml | 1453 ------------------ php/ext/google/protobuf/template_package.xml | 42 + 4 files changed, 125 insertions(+), 1453 deletions(-) create mode 100644 php/ext/google/protobuf/BUILD.bazel delete mode 100644 php/ext/google/protobuf/package.xml create mode 100644 php/ext/google/protobuf/template_package.xml diff --git a/BUILD.bazel b/BUILD.bazel index b980d990e8..6db748d5dd 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -578,3 +578,10 @@ pkg_files( ], visibility = ["//pkg:__pkg__"], ) + +# Version JSON file for release +filegroup( + name = "version_json", + srcs = ["version.json"], + visibility=["//visibility:public"], +) \ No newline at end of file diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel new file mode 100644 index 0000000000..b6b3fe712a --- /dev/null +++ b/php/ext/google/protobuf/BUILD.bazel @@ -0,0 +1,76 @@ + +# Protobuf PHP extension (PECL) + +filegroup( + name = "template_package_xml", + srcs = ["template_package.xml"], +) + +filegroup( + name = "src_files", + srcs = glob( + [ + "**/*.m4", + "**/*.c", + "**/*.h", + "**/*.inc" + ], + exclude = [ + "tests/**", + ] + ), +) + +filegroup( + name = "doc_files", + srcs = glob([ + "**/LICENSE", + ]) +) + +genrule( + name = "pecl_dist", + srcs = [ + ":src_files", + ":doc_files", + ":template_package_xml", + "//:version_json", + ], + outs = ["package.xml"], + cmd = """ + DATE=$$(date +%Y-%m-%d) + TIME=$$(date +%H:%M:%S) + + php_version_json=$$(cat $(location //:version_json) | python -c "import json, sys; versions=json.load(sys.stdin); print(versions.popitem()[1]['languages']['php'])") + php_version_array=($${php_version_json//-rc/ }) + api_version=$${php_version_array[0]} + if [ $${#php_version_array[@]} -eq 2 ]; then + rc=$${php_version_array[1]} + release_version=$${api_version}RC$${rc} + stability='beta' + else + release_version=$${api_version} + stability='stable' + fi + + FILE='\\n' + files="\\n" + for file in $$(find -L $(locations :src_files) -type f); do + name=$$(echo $$file | sed -e 's|php/ext/google/protobuf/||') + files+=' '$$(echo $$FILE | sed -e "s;NAME;$${name};" | sed -e "s;ROLE;src;") + done + for file in $$(find -L $(locations :doc_files) -type f); do + name=$$(echo $$file | sed -e 's|php/ext/google/protobuf/||') + files+=' '$$(echo $$FILE | sed -e "s;NAME;$${name};" | sed -e "s;ROLE;doc;") + done + + cat $(location :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};" | + sed -e "s;TEMPLATE_FILES;$${files};" + > "$@" + """ +) \ 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 462b405bd5..0000000000 --- a/php/ext/google/protobuf/package.xml +++ /dev/null @@ -1,1453 +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-13 - - - 3.21.8 - 3.21.8 - - - 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 - - - - - diff --git a/php/ext/google/protobuf/template_package.xml b/php/ext/google/protobuf/template_package.xml new file mode 100644 index 0000000000..7fb34146a3 --- /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 + + From 2a2d592242c284dc8634f3c6759cf81478bfecb3 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Thu, 27 Oct 2022 16:14:59 +0000 Subject: [PATCH 02/16] move to separate bash script, cleanups, filegroup fixes --- BUILD.bazel | 2 +- php/ext/google/protobuf/BUILD.bazel | 90 +++++++------------ .../google/protobuf/generate_package_xml.sh | 42 +++++++++ 3 files changed, 77 insertions(+), 57 deletions(-) create mode 100755 php/ext/google/protobuf/generate_package_xml.sh diff --git a/BUILD.bazel b/BUILD.bazel index 6db748d5dd..dbf1f10679 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -584,4 +584,4 @@ filegroup( name = "version_json", srcs = ["version.json"], visibility=["//visibility:public"], -) \ No newline at end of file +) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel index b6b3fe712a..5c638cb243 100644 --- a/php/ext/google/protobuf/BUILD.bazel +++ b/php/ext/google/protobuf/BUILD.bazel @@ -1,76 +1,54 @@ # Protobuf PHP extension (PECL) +load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix") filegroup( name = "template_package_xml", srcs = ["template_package.xml"], ) -filegroup( - name = "src_files", - srcs = glob( - [ - "**/*.m4", - "**/*.c", - "**/*.h", - "**/*.inc" - ], - exclude = [ - "tests/**", - ] - ), +pkg_files( + name = "utf8_range_files", + srcs = [ + "@utf8_range//:utf8_range_srcs", + "@utf8_range//:LICENSE", + ], ) -filegroup( - name = "doc_files", +pkg_files( + name = "protobuf_files", srcs = glob([ - "**/LICENSE", - ]) + "*.h", + "*.c", + ]) + [ + "//:LICENSE", + "config.m4", + "wkt.inc", + ], +) + +pkg_filegroup( + name = "release_files", + srcs = [ + ":protobuf_files", + ":utf8_range_files", + ], ) genrule( name = "pecl_dist", srcs = [ - ":src_files", - ":doc_files", + ":release_files", ":template_package_xml", "//:version_json", ], outs = ["package.xml"], - cmd = """ - DATE=$$(date +%Y-%m-%d) - TIME=$$(date +%H:%M:%S) - - php_version_json=$$(cat $(location //:version_json) | python -c "import json, sys; versions=json.load(sys.stdin); print(versions.popitem()[1]['languages']['php'])") - php_version_array=($${php_version_json//-rc/ }) - api_version=$${php_version_array[0]} - if [ $${#php_version_array[@]} -eq 2 ]; then - rc=$${php_version_array[1]} - release_version=$${api_version}RC$${rc} - stability='beta' - else - release_version=$${api_version} - stability='stable' - fi - - FILE='\\n' - files="\\n" - for file in $$(find -L $(locations :src_files) -type f); do - name=$$(echo $$file | sed -e 's|php/ext/google/protobuf/||') - files+=' '$$(echo $$FILE | sed -e "s;NAME;$${name};" | sed -e "s;ROLE;src;") - done - for file in $$(find -L $(locations :doc_files) -type f); do - name=$$(echo $$file | sed -e 's|php/ext/google/protobuf/||') - files+=' '$$(echo $$FILE | sed -e "s;NAME;$${name};" | sed -e "s;ROLE;doc;") - done - - cat $(location :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};" | - sed -e "s;TEMPLATE_FILES;$${files};" - > "$@" - """ -) \ No newline at end of file + cmd = " ".join([ + "$(location :generate_package_xml.sh)", + "$(location :template_package_xml)", + "$(location //:version_json)", + "$$(echo $(locations :release_files) | sed -e 's; ;,;g')", + "$(location package.xml)" + ]), + tools = ["generate_package_xml.sh"], +) 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..886e1cc76a --- /dev/null +++ b/php/ext/google/protobuf/generate_package_xml.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +template_package_xml=$1 +version_json=$2 +release_files=$3 +out=$4 + +date=$(date +%Y-%m-%d) +time=$(date +%H:%M:%S) + +php_version_json=$( + cat $version_json | + python -c "import json, sys; v=json.load(sys.stdin); print(v.popitem()[1]['languages']['php'])") +php_version_array=(${php_version_json//-rc/ }) +api_version=${php_version_array[0]} +if [ ${#php_version_array[@]} -eq 2 ]; then + rc=${php_version_array[1]} + release_version=${api_version}RC${rc} + stability='beta' +else + release_version=${api_version} + stability='stable' +fi + +files="\\n" +for file in ${release_files//,/ }; do + name=$(echo $file | sed -e 's;php/ext/google/protobuf/;;') + if [[ $name =~ LICENSE$ ]]; then + role='doc' + else + role='src' + fi + files+=" \\n" +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 From ebc3f4f0dd8a35c945333ab7e13e73ac7f7f422f Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Thu, 27 Oct 2022 17:29:37 +0000 Subject: [PATCH 03/16] rename target and read php version from bzl --- php/ext/google/protobuf/BUILD.bazel | 6 +++--- php/ext/google/protobuf/generate_package_xml.sh | 9 ++------- protobuf_version.bzl | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel index 5c638cb243..59180678f9 100644 --- a/php/ext/google/protobuf/BUILD.bazel +++ b/php/ext/google/protobuf/BUILD.bazel @@ -1,6 +1,7 @@ # Protobuf PHP extension (PECL) load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix") +load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION") filegroup( name = "template_package_xml", @@ -36,17 +37,16 @@ pkg_filegroup( ) genrule( - name = "pecl_dist", + name = "generate_package_xml", srcs = [ ":release_files", ":template_package_xml", - "//:version_json", ], outs = ["package.xml"], cmd = " ".join([ "$(location :generate_package_xml.sh)", "$(location :template_package_xml)", - "$(location //:version_json)", + PROTOBUF_PHP_VERSION, "$$(echo $(locations :release_files) | sed -e 's; ;,;g')", "$(location package.xml)" ]), diff --git a/php/ext/google/protobuf/generate_package_xml.sh b/php/ext/google/protobuf/generate_package_xml.sh index 886e1cc76a..e74d6e6770 100755 --- a/php/ext/google/protobuf/generate_package_xml.sh +++ b/php/ext/google/protobuf/generate_package_xml.sh @@ -1,24 +1,19 @@ #!/bin/bash template_package_xml=$1 -version_json=$2 +release_version=$2 release_files=$3 out=$4 date=$(date +%Y-%m-%d) time=$(date +%H:%M:%S) -php_version_json=$( - cat $version_json | - python -c "import json, sys; v=json.load(sys.stdin); print(v.popitem()[1]['languages']['php'])") -php_version_array=(${php_version_json//-rc/ }) +php_version_array=(${release_version//RC/ }) api_version=${php_version_array[0]} if [ ${#php_version_array[@]} -eq 2 ]; then rc=${php_version_array[1]} - release_version=${api_version}RC${rc} stability='beta' else - release_version=${api_version} stability='stable' fi diff --git a/protobuf_version.bzl b/protobuf_version.bzl index 4c44f3da5d..6b8466781f 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" \ No newline at end of file From ccee798c7d5a57dbee1ff428df07d7b8dbc2410e Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Thu, 27 Oct 2022 18:26:02 +0000 Subject: [PATCH 04/16] fix kokoro tests (remaining refs to package.xml --- .github/workflows/php-ext.yml | 4 ++++ php/BUILD.bazel | 6 +----- php/ext/google/protobuf/BUILD.bazel | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index f24f6bf62b..74cd69cced 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -28,6 +28,10 @@ jobs: 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: Generate package.xml + run: | + bazel build $GITHUB_WORKSPACE/php/ext/google/protobuf:generate_package_xml + cp $GITHUB_WORKSPACE/bazel-bin/php/ext/google/protobuf/package.xml $GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml - name: Create package run: | cd /tmp diff --git a/php/BUILD.bazel b/php/BUILD.bazel index ac33702ab7..948541cb00 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -14,15 +14,11 @@ filegroup( "//php:__pkg__", ], srcs = glob([ - "ext/google/protobuf/*.h", - "ext/google/protobuf/*.c", "src/GPBMetadata/Google/Protobuf/**/*.php", "src/Google/Protobuf/**/*.php", ]) + [ "composer.json", - "ext/google/protobuf/wkt.inc", - "ext/google/protobuf/config.m4", - "ext/google/protobuf/package.xml", + "//php/ext/google/protobuf:source_files", ], ) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel index 59180678f9..ca37abce22 100644 --- a/php/ext/google/protobuf/BUILD.bazel +++ b/php/ext/google/protobuf/BUILD.bazel @@ -17,12 +17,12 @@ pkg_files( ) pkg_files( - name = "protobuf_files", + name = "source_files", srcs = glob([ "*.h", "*.c", ]) + [ - "//:LICENSE", + "LICENSE", "config.m4", "wkt.inc", ], @@ -31,7 +31,7 @@ pkg_files( pkg_filegroup( name = "release_files", srcs = [ - ":protobuf_files", + ":source_files", ":utf8_range_files", ], ) From dd244628c2dc3d8678d79983b5b0e226e7c1e737 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Thu, 27 Oct 2022 18:57:04 +0000 Subject: [PATCH 05/16] install bazel for php-ext github workflow --- .github/workflows/php-ext.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index 74cd69cced..6128c2b4af 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -15,6 +15,9 @@ jobs: - php:7.4-cli - php:8.1-cli steps: + - name: Install bazel + run: | + sudo apt update && sudo apt install bazel - name: Install git run: | apt-get update -q From 74b3c198b8693ee49589e0100645a2b35e5d6a18 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Thu, 27 Oct 2022 21:39:44 +0000 Subject: [PATCH 06/16] update package.xml to match file structure of pkg_tar --- php/BUILD.bazel | 16 +++++++++++++ php/ext/google/protobuf/BUILD.bazel | 24 +++++++++++++++---- .../google/protobuf/generate_package_xml.sh | 4 +++- version.json | 20 ++++++++-------- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/php/BUILD.bazel b/php/BUILD.bazel index 948541cb00..c68abe4ab5 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -3,9 +3,11 @@ # 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("@upb//cmake:build_defs.bzl", "staleness_test") load("//build_defs:internal_shell.bzl", "inline_sh_binary") load("//conformance:defs.bzl", "conformance_test") +load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION") filegroup( name = "source_files", @@ -133,3 +135,17 @@ pkg_files( strip_prefix = strip_prefix.from_pkg(""), visibility = ["//pkg:__pkg__"], ) + +################################################################################ +# PECL .tgz Release +################################################################################ + +pkg_tar( + name = "release", + extension = "tgz", + srcs = [ + "//php/ext/google/protobuf:release_files", + "//php/ext/google/protobuf:generate_package_xml", + ], + out = "protobuf-%s" % PROTOBUF_PHP_VERSION, +) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel index ca37abce22..1b0bc704c3 100644 --- a/php/ext/google/protobuf/BUILD.bazel +++ b/php/ext/google/protobuf/BUILD.bazel @@ -1,7 +1,10 @@ # Protobuf PHP extension (PECL) -load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix") +load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup") load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION") +load("@rules_pkg//:pkg.bzl", "pkg_tar") + +package(default_visibility = ["//php:__subpackages__"]) filegroup( name = "template_package_xml", @@ -14,6 +17,7 @@ pkg_files( "@utf8_range//:utf8_range_srcs", "@utf8_range//:LICENSE", ], + prefix = "third_party/utf8_range", ) pkg_files( @@ -22,7 +26,7 @@ pkg_files( "*.h", "*.c", ]) + [ - "LICENSE", + "//:LICENSE", "config.m4", "wkt.inc", ], @@ -34,12 +38,24 @@ pkg_filegroup( ":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 = [ + ":release_files", + ], + out = "release_without_package", ) +# Generate PECL package.xml genrule( name = "generate_package_xml", srcs = [ - ":release_files", + ":release_without_package", ":template_package_xml", ], outs = ["package.xml"], @@ -47,7 +63,7 @@ genrule( "$(location :generate_package_xml.sh)", "$(location :template_package_xml)", PROTOBUF_PHP_VERSION, - "$$(echo $(locations :release_files) | sed -e 's; ;,;g')", + "$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')", "$(location package.xml)" ]), tools = ["generate_package_xml.sh"], diff --git a/php/ext/google/protobuf/generate_package_xml.sh b/php/ext/google/protobuf/generate_package_xml.sh index e74d6e6770..dea2d90bba 100755 --- a/php/ext/google/protobuf/generate_package_xml.sh +++ b/php/ext/google/protobuf/generate_package_xml.sh @@ -19,13 +19,15 @@ fi files="\\n" for file in ${release_files//,/ }; do - name=$(echo $file | sed -e 's;php/ext/google/protobuf/;;') + 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 | diff --git a/version.json b/version.json index 4244127810..b2c371f4ec 100644 --- a/version.json +++ b/version.json @@ -1,17 +1,17 @@ { - "main": { - "protoc_version": "22-dev", + "22.x": { + "protoc_version": "22.0-rc1", "lts": false, "date": "2022-07-21", "languages": { - "cpp": "3.22-dev", - "csharp": "3.22-dev", - "java": "3.22-dev", - "javascript": "3.22-dev", - "objectivec": "3.22-dev", - "php": "3.22-dev", - "python": "4.22-dev", - "ruby": "3.22-dev" + "cpp": "3.22.0-rc1", + "csharp": "3.22.0-rc1", + "java": "3.22.0-rc1", + "javascript": "3.22.0-rc1", + "objectivec": "3.22.0-rc1", + "php": "3.22.0-rc1", + "python": "4.22.0-rc1", + "ruby": "3.22.0-rc1" } } } From 9595e3e5fe8a29127901d0816292cb53c2c884e1 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 15:17:15 +0000 Subject: [PATCH 07/16] Update php-ext github workflow --- .github/workflows/php-ext.yml | 19 +++++-------------- php/BUILD.bazel | 2 +- php/ext/google/protobuf/BUILD.bazel | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index 6128c2b4af..0d8c75a9fc 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Install bazel run: | - sudo apt update && sudo apt install bazel + apt-get install bazel - name: Install git run: | apt-get update -q @@ -26,24 +26,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: Generate package.xml - run: | - bazel build $GITHUB_WORKSPACE/php/ext/google/protobuf:generate_package_xml - cp $GITHUB_WORKSPACE/bazel-bin/php/ext/google/protobuf/package.xml $GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml - name: Create package run: | - cd /tmp - rm -rf protobuf-*.tgz - pecl package "$GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml" + rm -rf bazel-bin/php/protobuf-*.tgz + cd $GITHUB_WORKSPACE + bazel build php:release - name: Compile extension run: | cd /tmp - MAKE="make -j$(nproc)" pecl install protobuf-*.tgz + MAKE="make -j$(nproc)" pecl install bazel-bin/php/protobuf-*.tgz - name: Enable extension run: docker-php-ext-enable protobuf - name: Inspect extension diff --git a/php/BUILD.bazel b/php/BUILD.bazel index c68abe4ab5..585fa547b3 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -147,5 +147,5 @@ pkg_tar( "//php/ext/google/protobuf:release_files", "//php/ext/google/protobuf:generate_package_xml", ], - out = "protobuf-%s" % PROTOBUF_PHP_VERSION, + out = "protobuf-%s.tgz" % PROTOBUF_PHP_VERSION, ) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel index 1b0bc704c3..9b1d892aa8 100644 --- a/php/ext/google/protobuf/BUILD.bazel +++ b/php/ext/google/protobuf/BUILD.bazel @@ -48,7 +48,7 @@ pkg_tar( srcs = [ ":release_files", ], - out = "release_without_package", + out = "release_without_package.tgz", ) # Generate PECL package.xml From 51b812dd28461ee6cd1f5de98018fdbb9c515819 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 15:36:13 +0000 Subject: [PATCH 08/16] apt update before apt-get install bazel --- .github/workflows/php-ext.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index 0d8c75a9fc..d855277d09 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -17,10 +17,10 @@ jobs: steps: - name: Install bazel run: | - apt-get install bazel + apt-get update -q + apt-get install -qy bazel - name: Install git run: | - apt-get update -q apt-get install -qy --no-install-recommends git - name: Checkout uses: actions/checkout@v3 From 70c4bdc7447741ef20b90a7621f2bfb11a366273 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:26:09 +0000 Subject: [PATCH 09/16] install bazel using wget --- .github/workflows/php-ext.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index d855277d09..a492b43b0a 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -17,10 +17,12 @@ jobs: steps: - name: Install bazel run: | - apt-get update -q - apt-get install -qy bazel + 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 apt-get install -qy --no-install-recommends git - name: Checkout uses: actions/checkout@v3 @@ -28,9 +30,9 @@ jobs: submodules: recursive - name: Create package run: | - rm -rf bazel-bin/php/protobuf-*.tgz cd $GITHUB_WORKSPACE - bazel build php:release + rm -rf bazel-bin/php/protobuf-*.tgz + $HOME/bin/bazel build php:release - name: Compile extension run: | cd /tmp From caf644d3954a9c81703bb8b3493d8a8ce8b83ec6 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:30:26 +0000 Subject: [PATCH 10/16] install wget --- .github/workflows/php-ext.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index a492b43b0a..fb52067ae3 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -17,12 +17,13 @@ jobs: steps: - name: Install bazel run: | + apt-get update -q + 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 apt-get install -qy --no-install-recommends git - name: Checkout uses: actions/checkout@v3 From bae850fd1154ba7dd7f58a9a71dbbf879e8df3b0 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:35:38 +0000 Subject: [PATCH 11/16] install python3 --- .github/workflows/php-ext.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index fb52067ae3..6ef7060c16 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -15,9 +15,12 @@ jobs: - php:7.4-cli - php:8.1-cli steps: - - name: Install bazel + - name: Install python3 run: | apt-get update -q + apt-get install 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 From 78352b90bfc3cce87e29ef32589febb8c7a4b8ac Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:36:52 +0000 Subject: [PATCH 12/16] add -qy to python3 install --- .github/workflows/php-ext.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index 6ef7060c16..cd361fe903 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -18,7 +18,7 @@ jobs: - name: Install python3 run: | apt-get update -q - apt-get install python3 + apt-get install -qy python3 - name: Install bazel run: | apt-get install -qy wget From 1bf0ac8089afcb4791654bdd4426ec39f98eeb82 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:42:01 +0000 Subject: [PATCH 13/16] fix tgz dir for pecl install --- .github/workflows/php-ext.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-ext.yml b/.github/workflows/php-ext.yml index cd361fe903..17b6adf9d5 100644 --- a/.github/workflows/php-ext.yml +++ b/.github/workflows/php-ext.yml @@ -40,7 +40,7 @@ jobs: - name: Compile extension run: | cd /tmp - MAKE="make -j$(nproc)" pecl install bazel-bin/php/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 From 89035d5f1757d6164d69c53dbbdc2914a01e4f36 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:50:55 +0000 Subject: [PATCH 14/16] revert version.json from testing --- version.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/version.json b/version.json index b2c371f4ec..4244127810 100644 --- a/version.json +++ b/version.json @@ -1,17 +1,17 @@ { - "22.x": { - "protoc_version": "22.0-rc1", + "main": { + "protoc_version": "22-dev", "lts": false, "date": "2022-07-21", "languages": { - "cpp": "3.22.0-rc1", - "csharp": "3.22.0-rc1", - "java": "3.22.0-rc1", - "javascript": "3.22.0-rc1", - "objectivec": "3.22.0-rc1", - "php": "3.22.0-rc1", - "python": "4.22.0-rc1", - "ruby": "3.22.0-rc1" + "cpp": "3.22-dev", + "csharp": "3.22-dev", + "java": "3.22-dev", + "javascript": "3.22-dev", + "objectivec": "3.22-dev", + "php": "3.22-dev", + "python": "4.22-dev", + "ruby": "3.22-dev" } } } From 33e9928e69f07243cdd6d9ba9ec08b5714341e4f Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Fri, 28 Oct 2022 20:55:20 +0000 Subject: [PATCH 15/16] cleanups, formatting --- BUILD.bazel | 7 ------- php/ext/google/protobuf/BUILD.bazel | 9 ++------- protobuf_version.bzl | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index dbf1f10679..b980d990e8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -578,10 +578,3 @@ pkg_files( ], visibility = ["//pkg:__pkg__"], ) - -# Version JSON file for release -filegroup( - name = "version_json", - srcs = ["version.json"], - visibility=["//visibility:public"], -) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel index 9b1d892aa8..2b5eb9a4f6 100644 --- a/php/ext/google/protobuf/BUILD.bazel +++ b/php/ext/google/protobuf/BUILD.bazel @@ -6,11 +6,6 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar") package(default_visibility = ["//php:__subpackages__"]) -filegroup( - name = "template_package_xml", - srcs = ["template_package.xml"], -) - pkg_files( name = "utf8_range_files", srcs = [ @@ -56,12 +51,12 @@ genrule( name = "generate_package_xml", srcs = [ ":release_without_package", - ":template_package_xml", + "template_package.xml", ], outs = ["package.xml"], cmd = " ".join([ "$(location :generate_package_xml.sh)", - "$(location :template_package_xml)", + "$(location template_package.xml)", PROTOBUF_PHP_VERSION, "$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')", "$(location package.xml)" diff --git a/protobuf_version.bzl b/protobuf_version.bzl index 6b8466781f..3777e23d8a 100644 --- a/protobuf_version.bzl +++ b/protobuf_version.bzl @@ -1,4 +1,4 @@ PROTOC_VERSION = "21.9" PROTOBUF_JAVA_VERSION = "3.21.9" PROTOBUF_PYTHON_VERSION = "4.21.9" -PROTOBUF_PHP_VERSION = "3.21.9" \ No newline at end of file +PROTOBUF_PHP_VERSION = "3.21.9" From 71a069e74ce243d4c1514684fd287dcf9b6a0e4d Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Mon, 31 Oct 2022 16:18:48 +0000 Subject: [PATCH 16/16] move targets from php/ext/google/protobuf to php packages since this breaks dist_files --- php/BUILD.bazel | 66 +++++++++++++++++++++++++++-- php/ext/google/protobuf/BUILD.bazel | 65 ---------------------------- 2 files changed, 62 insertions(+), 69 deletions(-) delete mode 100644 php/ext/google/protobuf/BUILD.bazel diff --git a/php/BUILD.bazel b/php/BUILD.bazel index 585fa547b3..aded29afe4 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -2,7 +2,7 @@ # # See also code generation logic under /src/google/protobuf/compiler/php. -load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") +load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix") load("@rules_pkg//:pkg.bzl", "pkg_tar") load("@upb//cmake:build_defs.bzl", "staleness_test") load("//build_defs:internal_shell.bzl", "inline_sh_binary") @@ -20,7 +20,7 @@ filegroup( "src/Google/Protobuf/**/*.php", ]) + [ "composer.json", - "//php/ext/google/protobuf:source_files", + ":php_ext_source_files", ], ) @@ -140,12 +140,70 @@ pkg_files( # 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 = [ + "@utf8_range//:utf8_range_srcs", + "@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 = [ - "//php/ext/google/protobuf:release_files", - "//php/ext/google/protobuf:generate_package_xml", + ":pecl_release_files", + ":generate_package_xml", ], out = "protobuf-%s.tgz" % PROTOBUF_PHP_VERSION, ) diff --git a/php/ext/google/protobuf/BUILD.bazel b/php/ext/google/protobuf/BUILD.bazel deleted file mode 100644 index 2b5eb9a4f6..0000000000 --- a/php/ext/google/protobuf/BUILD.bazel +++ /dev/null @@ -1,65 +0,0 @@ - -# Protobuf PHP extension (PECL) -load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup") -load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION") -load("@rules_pkg//:pkg.bzl", "pkg_tar") - -package(default_visibility = ["//php:__subpackages__"]) - -pkg_files( - name = "utf8_range_files", - srcs = [ - "@utf8_range//:utf8_range_srcs", - "@utf8_range//:LICENSE", - ], - prefix = "third_party/utf8_range", -) - -pkg_files( - name = "source_files", - srcs = glob([ - "*.h", - "*.c", - ]) + [ - "//:LICENSE", - "config.m4", - "wkt.inc", - ], -) - -pkg_filegroup( - name = "release_files", - srcs = [ - ":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 = [ - ":release_files", - ], - out = "release_without_package.tgz", -) - -# Generate PECL package.xml -genrule( - name = "generate_package_xml", - srcs = [ - ":release_without_package", - "template_package.xml", - ], - outs = ["package.xml"], - cmd = " ".join([ - "$(location :generate_package_xml.sh)", - "$(location template_package.xml)", - PROTOBUF_PHP_VERSION, - "$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')", - "$(location package.xml)" - ]), - tools = ["generate_package_xml.sh"], -)