1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Add composer.json.in to ext/skeleton for PIE support (#19853)

* Add composer.json.in to ext/skeleton for PIE support

* Add --vendor param to ext_skel.php to provide vendor name for PIE packages
This commit is contained in:
James Titcumb
2025-09-23 13:57:33 +01:00
committed by GitHub
parent dcc4b0ff07
commit d9ca72f891
2 changed files with 36 additions and 4 deletions

View File

@@ -42,7 +42,7 @@ HOW TO USE IT
Very simple. First, change to the ext/ directory of the PHP sources. Then run
the following
php ext_skel.php --ext extension_name
php ext_skel.php --ext extension_name --vendor vendor_name
and everything you need will be placed in directory ext/extension_name.
@@ -90,11 +90,12 @@ SOURCE AND HEADER FILE NAME
OPTIONS
php ext_skel.php --ext <name> [--experimental] [--author <name>]
[--dir <path>] [--std] [--onlyunix]
[--onlywindows] [--help]
php ext_skel.php --ext <name> --vendor <name> [--experimental]
[--author <name>] [--dir <path>] [--std]
[--onlyunix] [--onlywindows] [--help]
--ext <name> The name of the extension defined as <name>
--vendor <name> The vendor of the extension for Packagist
--experimental Passed if this extension is experimental, this creates
the EXPERIMENTAL file in the root of the extension
--author <name> Your name, this is used if --std is passed and for the
@@ -147,6 +148,7 @@ function process_args($argv, $argc) {
'unix' => true,
'windows' => true,
'ext' => '',
'vendor' => '',
'dir' => __DIR__ . DIRECTORY_SEPARATOR,
'skel' => __DIR__ . DIRECTORY_SEPARATOR . 'skeleton' . DIRECTORY_SEPARATOR,
'author' => false,
@@ -185,6 +187,7 @@ function process_args($argv, $argc) {
}
break;
case 'ext':
case 'vendor':
case 'dir':
case 'author': {
if (!isset($argv[$i + 1]) || ($argv[$i + 1][0] == '-' && $argv[$i + 1][1] == '-')) {
@@ -204,6 +207,8 @@ function process_args($argv, $argc) {
if (empty($options['ext'])) {
error('No extension name passed, use "--ext <name>"');
} else if (empty($options['vendor'])) {
error('No vendor name passed, use "--vendor <name>"');
} else if (!$options['unix'] && !$options['windows']) {
error('Cannot pass both --onlyunix and --onlywindows');
} else if (!is_dir($options['skel'])) {
@@ -217,6 +222,12 @@ function process_args($argv, $argc) {
.' Using only lower case letters is preferred.');
}
// Validate vendor
if (!preg_match('/^[a-z][a-z0-9_-]+$/i', $options['vendor'])) {
error('Invalid vendor name. Valid names start with a letter,'
.' followed by any number of letters, numbers, hypens, or underscores.');
}
$options['ext'] = str_replace(['\\', '/'], '', strtolower($options['ext']));
return $options;
@@ -231,6 +242,7 @@ function process_source_tags($file, $short_name) {
error('Unable to open file for reading: ' . $short_name);
}
$source = str_replace('%VENDORNAME%', $options['vendor'], $source);
$source = str_replace('%EXTNAME%', $options['ext'], $source);
$source = str_replace('%EXTNAMECAPS%', strtoupper($options['ext']), $source);
@@ -290,6 +302,7 @@ function copy_config_scripts() {
}
$files[] = '.gitignore';
$files[] = 'composer.json';
foreach($files as $config_script) {
$new_config_script = $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $config_script;

View File

@@ -0,0 +1,19 @@
{
"name": "%VENDORNAME%/%EXTNAME%",
"type": "php-ext",
"license": "BSD-3-Clause",
"description": "Describe your extension here",
"require": {
"php": "^8.3"
},
"php-ext": {
"extension-name": "%EXTNAME%",
"configure-options": [
{
"name": "enable-%EXTNAME%",
"needs-value": false,
"description": "whether to enable %EXTNAME% support"
}
]
}
}