2016-12-05 13:42:38 +00:00
|
|
|
<?php if( !defined('__ROOT__') ) define('__ROOT__', dirname(dirname(__FILE__)) );
|
|
|
|
|
|
|
|
|
|
|
|
class Builder{
|
|
|
|
|
|
|
|
|
|
|
|
private static function src(){ return __ROOT__.'/src'; }
|
2016-12-05 18:54:19 +00:00
|
|
|
private $packages = null;
|
2016-12-05 13:42:38 +00:00
|
|
|
private $root = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* BUILDS A BUILDER WITH SPECIFIC LOCATION AND CONFIG
|
|
|
|
*
|
|
|
|
* @pRoot<String> Path to project root
|
2016-12-05 18:54:19 +00:00
|
|
|
* @pPackages<Array> Packages to load
|
2016-12-05 13:42:38 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-12-05 18:54:19 +00:00
|
|
|
public function __construct($pRoot, $pPackages){
|
2016-12-05 13:42:38 +00:00
|
|
|
/* [1] Stores the path
|
|
|
|
=========================================================*/
|
|
|
|
$this->root = $pRoot;
|
|
|
|
|
2016-12-05 18:54:19 +00:00
|
|
|
/* [2] Stores the packages
|
2016-12-05 13:42:38 +00:00
|
|
|
=========================================================*/
|
2016-12-05 18:54:19 +00:00
|
|
|
$this->packages = $pPackages;
|
2016-12-05 13:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function build(){
|
|
|
|
|
|
|
|
/* [1] Builds project's base file structure
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) Copy from src/files */
|
|
|
|
shell_exec("cp -r ".__ROOT__."/src/files/* ".$this->root);
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-05 18:54:19 +00:00
|
|
|
/* [2] Browse each package to load
|
2016-12-05 13:42:38 +00:00
|
|
|
=========================================================*/
|
2016-12-05 18:54:19 +00:00
|
|
|
foreach($this->packages as $package=>$version){
|
|
|
|
$path = "/$package/$version";
|
2016-12-05 13:42:38 +00:00
|
|
|
|
2016-12-05 18:54:19 +00:00
|
|
|
/* (1) Copy package folder if it exists */
|
|
|
|
if( file_exists(__ROOT__."/src/packages$path/") && is_dir(__ROOT__."/src/packages$path/") && count(scandir(__ROOT__."/src/packages$path/")) > 2 )
|
|
|
|
shell_exec("cp -r ".__ROOT__."/src/packages$path ".$this->root."/build/$package");
|
2016-12-05 13:42:38 +00:00
|
|
|
|
2016-12-05 18:54:19 +00:00
|
|
|
/* (2) Copy package config if it exists */
|
2016-12-05 13:42:38 +00:00
|
|
|
if( file_exists(__ROOT__."/src/config$path/") && is_dir(__ROOT__."/src/config$path/") && count(scandir(__ROOT__."/src/config$path/")) > 2 )
|
|
|
|
shell_exec("cp -r ".__ROOT__."/src/config$path/* ".$this->root."/config/");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|