forked from aws/aws-sdk-php
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
all: clean coverage docs | ||
|
||
test: | ||
vendor/bin/phpunit | ||
|
||
coverage: | ||
vendor/bin/phpunit --coverage-html=build/artifacts/coverage | ||
|
||
integration: | ||
vendor/bin/phpunit -c phpunit.functional.xml | ||
|
||
view-coverage: | ||
open build/artifacts/coverage/index.html | ||
|
||
clean: | ||
rm -rf build/artifacts | ||
cd docs && make clean | ||
|
||
docs: | ||
cd docs && make html | ||
|
||
view-docs: | ||
open docs/_build/html/index.html | ||
|
||
package: burgomaster | ||
time php build/packager.php | ||
|
||
burgomaster: | ||
mkdir -p build/artifacts | ||
curl -s https://raw.githubusercontent.com/mtdowling/Burgomaster/0.0.1/src/Burgomaster.php > build/artifacts/Burgomaster.php | ||
|
||
.PHONY: docs burgomaster |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,26 @@ | ||
<?php | ||
/** | ||
* Packages the zip and phar file using a staging directory. | ||
*/ | ||
|
||
function debug_log($message) | ||
{ | ||
echo $message . "\n"; | ||
} | ||
|
||
function deep_copy($from, $to) | ||
{ | ||
$dir = dirname($to); | ||
if (!is_dir($dir)) { | ||
mkdir($dir, 0777, true); | ||
} | ||
copy($from, $to); | ||
} | ||
|
||
// Files to be added to the package | ||
function create_staging_dir($baseDir) | ||
{ | ||
debug_log("Creating staging directory at: $baseDir"); | ||
debug_log(" Cleaning $baseDir"); | ||
exec("rm -rf $baseDir"); | ||
mkdir($baseDir); | ||
chdir(__DIR__ . '/..'); | ||
|
||
debug_log(" Copying meta-files to $baseDir"); | ||
foreach (['README.md', 'LICENSE.md', 'NOTICE.md'] as $file) { | ||
deep_copy($file, $baseDir . '/Aws/' . $file); | ||
} | ||
|
||
// Copy the autoloader | ||
debug_log(' Copying aws-autoloader'); | ||
copy(__DIR__ . '/aws-autoloader.php', $baseDir . '/aws-autoloader.php'); | ||
|
||
$directories = [ | ||
'src', | ||
'vendor/guzzle/guzzle/src', | ||
'vendor/symfony/event-dispatcher', | ||
'vendor/symfony/class-loader', | ||
'vendor/doctrine/cache/lib', | ||
'vendor/psr/log', | ||
'vendor/monolog/monolog/src' | ||
]; | ||
|
||
debug_log(' Copying files'); | ||
foreach ($directories as $dir) { | ||
recursive_copy($dir, $baseDir); | ||
} | ||
|
||
// Delete the duplicate LICENSE | ||
unlink($baseDir . '/LICENSE'); | ||
|
||
debug_log(" Created staging directory at: $baseDir"); | ||
} | ||
require __DIR__ . '/artifacts/Burgomaster.php'; | ||
|
||
$stageDirectory = __DIR__ . '/artifacts/staging'; | ||
$projectRoot = __DIR__ . '/../'; | ||
$burgomaster = new \Burgomaster($stageDirectory, $projectRoot); | ||
|
||
/** | ||
* Recursively copy a dependency | ||
*/ | ||
function recursive_copy($fromDir, $baseDir) | ||
{ | ||
// File extensions added to the output | ||
$exts = array_fill_keys(['php', 'pem'], true); | ||
|
||
$fromDir = realpath($fromDir); | ||
$iter = new RecursiveDirectoryIterator($fromDir); | ||
$iter = new RecursiveIteratorIterator($iter); | ||
|
||
debug_log(" > From $fromDir"); | ||
|
||
$total = 0; | ||
foreach ($iter as $file) { | ||
if (isset($exts[$file->getExtension()]) | ||
|| $file->getBaseName() == 'LICENSE' | ||
) { | ||
$toPath = str_replace($fromDir, '', (string) $file); | ||
$toPath = $baseDir . '/' . $toPath; | ||
deep_copy((string) $file, $toPath); | ||
$total++; | ||
} | ||
} | ||
|
||
debug_log(" Copied $total files"); | ||
} | ||
|
||
function create_phar($baseDir, $dest) | ||
{ | ||
debug_log('Creating full phar file'); | ||
$phar = new Phar($dest, 0, 'aws.phar'); | ||
$phar->buildFromDirectory($baseDir); | ||
$phar->setStub(file_get_contents(__DIR__ . '/phar-stub.php')); | ||
|
||
debug_log(" > Created at $dest"); | ||
} | ||
|
||
function test_phar($baseDir, $phar) | ||
{ | ||
debug_log('Testing the phar'); | ||
exec('php ' . __DIR__ . '/test_phar.php', $output, $ret); | ||
if ($ret !== 0) { | ||
die("Testing the phar failed with exit code {$ret}\n" | ||
. implode("\n", $output)); | ||
} | ||
debug_log(' > Phar is OK: ' . implode("\n", $output)); | ||
foreach (['README.md', 'LICENSE.md', 'NOTICE.md'] as $file) { | ||
$burgomaster->deepCopy($file, $file); | ||
} | ||
|
||
function create_zip($baseDir, $dest) | ||
{ | ||
debug_log('Creating zip file'); | ||
chdir($baseDir); | ||
exec("zip -r $dest ./"); | ||
debug_log(" > Created at $dest"); | ||
chdir(__DIR__); | ||
} | ||
|
||
$baseDir = realpath(__DIR__ . '/..') . '/build/artifacts/staging'; | ||
|
||
create_staging_dir($baseDir); | ||
create_phar($baseDir, __DIR__ . '/artifacts/aws.phar'); | ||
test_phar($baseDir, __DIR__ . '/artifacts/aws.phar'); | ||
create_zip($baseDir, __DIR__ . '/artifacts/aws.zip'); | ||
// Copy each dependency to the staging directory. Copy *.php and *.pem files. | ||
$burgomaster->recursiveCopy('src/Aws', 'Aws', ['php', 'json']); | ||
$burgomaster->recursiveCopy('vendor/guzzle/guzzle/src/Guzzle', 'Guzzle', ['php', 'pem']); | ||
$burgomaster->recursiveCopy('vendor/doctrine/cache/lib/Doctrine', 'Doctrine'); | ||
$burgomaster->recursiveCopy('vendor/psr/log/Psr', 'Psr'); | ||
$burgomaster->recursiveCopy('vendor/monolog/monolog/src/Monolog', 'Monlog'); | ||
$burgomaster->recursiveCopy('vendor/symfony/event-dispatcher/Symfony', 'Symfony'); | ||
|
||
$burgomaster->createAutoloader(); | ||
$burgomaster->createZip(__DIR__ . '/artifacts/aws.zip'); | ||
$burgomaster->createPhar(__DIR__ . '/artifacts/aws.phar'); | ||
$burgomaster->startSection('test_phar'); | ||
$burgomaster->debug('Phar output: ' | ||
. $burgomaster->exec('php ' . __DIR__ . '/test_phar.php')); | ||
$burgomaster->endSection(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters