From 5eb675460ea7908245fc97f4a9622e6115d7d601 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 21 Feb 2017 11:05:37 +0100 Subject: [PATCH] build: generate package.xml --- package.xml | 202 ++++++++++++++++++++++++++---------- scripts/gen_package_xml.php | 52 ++++++++++ 2 files changed, 197 insertions(+), 57 deletions(-) create mode 100644 scripts/gen_package_xml.php diff --git a/package.xml b/package.xml index 962c62a..16482e8 100644 --- a/package.xml +++ b/package.xml @@ -1,12 +1,5 @@ - - + + psi pecl.php.net PHP System Interface / POSIX Standard Interface @@ -54,102 +47,197 @@ and system interfaces of POSIX.1-2008 (http://pubs.opengroup.org/onlinepubs/9699 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -166,5 +254,5 @@ and system interfaces of POSIX.1-2008 (http://pubs.opengroup.org/onlinepubs/9699 psi - + diff --git a/scripts/gen_package_xml.php b/scripts/gen_package_xml.php new file mode 100644 index 0000000..d2bc1d2 --- /dev/null +++ b/scripts/gen_package_xml.php @@ -0,0 +1,52 @@ +ownerDocument; + foreach (glob("$dir/$mask", GLOB_BRACE) as $file) { + $fileNode = $doc->createElement("file"); + $fileNode->setAttribute("role", $role); + $fileNode->setAttribute("name", basename($file)); + + $node->appendChild($doc->createTextNode($indent)); + $node->appendChild($fileNode); + $node->appendChild($doc->createTextNode("\n")); + } + foreach (glob("$dir/*", GLOB_ONLYDIR) as $dir) { + $dirNode = $doc->createElement("dir"); + $dirNode->setAttribute("name", basename($dir)); + $dirNode->appendChild($doc->createTextNode("\n")); + + add($dir, $mask, $role, $dirNode, "$indent "); + + $dirNode->appendChild($doc->createTextNode($indent)); + + $node->appendChild($doc->createTextNode($indent)); + $node->appendChild($dirNode); + $node->appendChild($doc->createTextNode("\n")); + } +} + +$doc = new DOMDocument; +$doc->load(__DIR__."/../package.xml"); + +$src = $doc->createElement("dir"); +$src->setAttribute("name", "src"); +$src->appendChild($doc->createTextNode("\n")); +add(__DIR__."/../src", "*.{c,h,y,re,inc}", "src", $src); +$src->appendChild($doc->createTextNode(" ")); + +$tests = $doc->createElement("dir"); +$tests->setAttribute("name", "tests"); +$tests->appendChild($doc->createTextNode("\n")); +add(__DIR__."/../tests", "*.{phpt,inc,psi}", "test", $tests); +$tests->appendChild($doc->createTextNode(" ")); + +$xpath = new DOMXpath($doc); +$xpath->registerNamespace("p", "http://pear.php.net/dtd/package-2.0"); +$root = $xpath->query("/p:package/p:contents/p:dir[@name='/']")->item(0); +$root->replaceChild($src, + $xpath->query("/p:package/p:contents/p:dir[@name='/']/p:dir[@name='src']")->item(0)); +$root->replaceChild($tests, + $xpath->query("/p:package/p:contents/p:dir[@name='/']/p:dir[@name='tests']")->item(0)); + +$doc->save(__DIR__."/../package.xml"); \ No newline at end of file -- 2.30.2