Use pre-compiled PCOV binary for PHP7.4 on windows

This commit is contained in:
Shivam Mathur 2019-10-04 13:30:16 +05:30
parent 06929bdf4c
commit ba5306eea9
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
7 changed files with 33 additions and 34 deletions

View File

@ -56,6 +56,7 @@ describe('Utils tests', () => {
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin); expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux); expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux); expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32); expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain( expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
'Platform fedora is not supported' 'Platform fedora is not supported'

View File

@ -79,24 +79,26 @@ function readScript(filename, version, os_version) {
'scripts/pcov.sh' 'scripts/pcov.sh'
]); ]);
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8'); return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
case '7.3':
default:
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
} }
break;
case 'linux': case 'linux':
switch (version) { switch (version) {
case '7.4': case '7.4':
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']); yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); break;
case '7.3':
default:
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
} }
break;
case 'win32': case 'win32':
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); switch (version) {
case '7.4':
yield readFiles74(['ext/php_pcov.dll']);
break;
}
break;
default: default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error'); return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
} }
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
}); });
} }
exports.readScript = readScript; exports.readScript = readScript;
@ -179,7 +181,7 @@ function log(message, os_version, log_type) {
exports.log = log; exports.log = log;
function getExtensionPrefix(extension) { function getExtensionPrefix(extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let zend = ['xdebug', 'opcache']; let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
switch (zend.indexOf(extension)) { switch (zend.indexOf(extension)) {
case 0: case 0:
case 1: case 1:

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.3.7", "version": "1.3.8",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.3.7", "version": "1.3.8",
"private": false, "private": false,
"description": "Setup php action", "description": "Setup php action",
"main": "lib/setup-php.js", "main": "lib/setup-php.js",

BIN
src/ext/php_pcov.dll Normal file

Binary file not shown.

View File

@ -26,16 +26,18 @@ if($installed -ne $version) {
} }
echo "Housekeeping in PHP.ini, enabling openssl" echo "Housekeeping in PHP.ini, enabling openssl"
$ext_dir = "C:\tools\php\ext"
Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'" Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'"
Set-PhpIniKey extension_dir C:\tools\php\ext Set-PhpIniKey extension_dir $ext_dir
if($version -lt '7.4') { if($version -lt '7.4') {
Enable-PhpExtension openssl Enable-PhpExtension openssl
} else { } else {
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll" Add-Content C:\tools\php\php.ini "extension=php_openssl.dll"
Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
} }
echo "Installing Composer" echo "Installing Composer"
Install-Composer -Scope System -Path C:\tools\php Install-Composer -Scope System -Path C:\tools\php
$ext_dir = Get-PhpIniKey extension_dir
php -v php -v
composer -V composer -V

View File

@ -70,33 +70,22 @@ export async function readScript(
path.join(__dirname, '../src/scripts/7.4.sh'), path.join(__dirname, '../src/scripts/7.4.sh'),
'utf8' 'utf8'
); );
case '7.3':
default:
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
} }
break;
case 'linux': case 'linux':
switch (version) { switch (version) {
case '7.4': case '7.4':
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']); await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
return fs.readFileSync( break;
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
case '7.3':
default:
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
} }
break;
case 'win32': case 'win32':
return fs.readFileSync( switch (version) {
path.join(__dirname, '../src/scripts/' + filename), case '7.4':
'utf8' await readFiles74(['ext/php_pcov.dll']);
); break;
}
break;
default: default:
return await log( return await log(
'Platform ' + os_version + ' is not supported', 'Platform ' + os_version + ' is not supported',
@ -104,6 +93,11 @@ export async function readScript(
'error' 'error'
); );
} }
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
} }
/** /**
@ -189,7 +183,7 @@ export async function log(
} }
export async function getExtensionPrefix(extension: string): Promise<string> { export async function getExtensionPrefix(extension: string): Promise<string> {
let zend: Array<string> = ['xdebug', 'opcache']; let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
switch (zend.indexOf(extension)) { switch (zend.indexOf(extension)) {
case 0: case 0:
case 1: case 1: