add bazel rule for generating package.xml with src/doc filegoups

pull/10830/head
Sandy Zhang 2 years ago
parent fcd3b9a85e
commit 9cc343f175
  1. 7
      BUILD.bazel
  2. 76
      php/ext/google/protobuf/BUILD.bazel
  3. 1453
      php/ext/google/protobuf/package.xml
  4. 42
      php/ext/google/protobuf/template_package.xml

@ -578,3 +578,10 @@ pkg_files(
],
visibility = ["//pkg:__pkg__"],
)
# Version JSON file for release
filegroup(
name = "version_json",
srcs = ["version.json"],
visibility=["//visibility:public"],
)

@ -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='<file baseinstalldir=\"/\" name=\"NAME\" role=\"ROLE\"/>\\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};"
> "$@"
"""
)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.5" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>protobuf</name>
<channel>pecl.php.net</channel>
<summary>Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.</summary>
<description>https://developers.google.com/protocol-buffers/</description>
<lead>
<name>Protobuf Team</name>
<user>protobufpackages</user>
<email>protobuf-packages@google.com</email>
<active>yes</active>
</lead>
<date>TEMPLATE_DATE</date>
<time>TEMPLATE_TIME</time>
<version>
<release>TEMPLATE_PHP_RELEASE</release>
<api>TEMPLATE_PHP_API</api>
</version>
<stability>
<release>TEMPLATE_PHP_STABILITY</release>
<api>TEMPLATE_PHP_STABILITY</api>
</stability>
<license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
<notes>
* See github.com/protocolbuffers/protobuf/releases for release notes.
</notes>
<contents>
<dir baseinstalldir="/" name="/">TEMPLATE_FILES</dir>
</contents>
<dependencies>
<required>
<php>
<min>7.0.0</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>protobuf</providesextension>
<extsrcrelease/>
</package>
Loading…
Cancel
Save