Skip to content

Commit

Permalink
Use pre-compiled PCOV binary for PHP7.4 on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Oct 4, 2019
1 parent 06929bd commit ba5306e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
1 change: 1 addition & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Utils tests', () => {
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.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('fedora.sh', '7.3', 'fedora')).toContain(
'Platform fedora is not supported'
Expand Down
20 changes: 11 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,26 @@ function readScript(filename, version, os_version) {
'scripts/pcov.sh'
]);
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':
switch (version) {
case '7.4':
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
case '7.3':
default:
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
break;
}
break;
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:
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;
Expand Down Expand Up @@ -179,7 +181,7 @@ function log(message, os_version, log_type) {
exports.log = log;
function getExtensionPrefix(extension) {
return __awaiter(this, void 0, void 0, function* () {
let zend = ['xdebug', 'opcache'];
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
switch (zend.indexOf(extension)) {
case 0:
case 1:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "1.3.7",
"version": "1.3.8",
"private": false,
"description": "Setup php action",
"main": "lib/setup-php.js",
Expand Down
Binary file added src/ext/php_pcov.dll
Binary file not shown.
6 changes: 4 additions & 2 deletions src/scripts/win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ if($installed -ne $version) {
}

echo "Housekeeping in PHP.ini, enabling openssl"
$ext_dir = "C:\tools\php\ext"
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') {
Enable-PhpExtension openssl
} else {
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"
Install-Composer -Scope System -Path C:\tools\php
$ext_dir = Get-PhpIniKey extension_dir
php -v
composer -V
36 changes: 15 additions & 21 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,34 @@ export async function readScript(
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':
switch (version) {
case '7.4':
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
case '7.3':
default:
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
break;
}
break;
case 'win32':
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
switch (version) {
case '7.4':
await readFiles74(['ext/php_pcov.dll']);
break;
}
break;
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}

return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
);
}

/**
Expand Down Expand Up @@ -189,7 +183,7 @@ export async function log(
}

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)) {
case 0:
case 1:
Expand Down

0 comments on commit ba5306e

Please sign in to comment.