Added: web/php-rmtools/trunk/client/data/branch/php53.ini =================================================================== --- web/php-rmtools/trunk/client/data/branch/php53.ini (rev 0) +++ web/php-rmtools/trunk/client/data/branch/php53.ini 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,21 @@ +name=php-5.3 +branch=5.3 +repo_name=phpnet +repo_module=/php/php-src +repo_branch=/branches/PHP_5_3 +build_dir=g:/temp/obj +build_location=g:/php-sdk/php53/vc9/x86/ + +[build-nts-windows-vc9-x86] +name=nts-windows-vc9-x86 +compiler=vc9 +arch=x86 +configure_options=--enable-snapshot-build --disable-zts --disable-isapi --enable-debug-pack --disable-isapi --without-mssql --without-pdo-mssql --without-pi3web --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared --enable-com-dotnet --with-mcrypt=static --enable-object-out-dir=d:/temp/obj/ +platform=windows + +[build-ts-windows-vc9-x86] +name=ts-windows-vc9-x86 +compiler=vc9 +arch=x86 +configure_options=--enable-snapshot-build --disable-isapi --enable-debug-pack --without-mssql --without-pdo-mssql --without-pi3web --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared --enable-com-dotnet --with-mcrypt=static --enable-object-out-dir=d:/temp/obj/ +platform=windows Added: web/php-rmtools/trunk/client/data/branch/phptrunk.ini =================================================================== --- web/php-rmtools/trunk/client/data/branch/phptrunk.ini (rev 0) +++ web/php-rmtools/trunk/client/data/branch/phptrunk.ini 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,21 @@ +name=php-trunk +branch=trunk +repo_name=phpnet +repo_module=/php/php-src +repo_branch=/trunk +build_dir=g:/temp/obj +build_location=g:/php-sdk/php6/vc9/x86/ + +[build-nts-windows-vc9-x86] +name=nts-windows-vc9-x86 +compiler=vc9 +arch=x86 +configure_options=--enable-snapshot-build --disable-zts --disable-isapi --enable-debug-pack --disable-isapi --without-mssql --without-pdo-mssql --without-pi3web --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared --enable-com-dotnet --with-mcrypt=static --enable-object-out-dir=d:/temp/obj/ +platform=windows + +[build-ts-windows-vc9-x86] +name=ts-windows-vc9-x86 +compiler=vc9 +arch=x86 +configure_options=--enable-snapshot-build --disable-isapi --enable-debug-pack --without-mssql --without-pdo-mssql --without-pi3web --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared --enable-com-dotnet --with-mcrypt=static --enable-object-out-dir=d:/temp/obj/ +platform=windows Added: web/php-rmtools/trunk/client/data/config/branch/php53.ini =================================================================== --- web/php-rmtools/trunk/client/data/config/branch/php53.ini (rev 0) +++ web/php-rmtools/trunk/client/data/config/branch/php53.ini 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,21 @@ +name=php-5.3 +branch=5.3 +repo_name=phpnet +repo_module=/php/php-src +repo_branch=/branches/PHP_5_3 +build_dir=g:/temp/obj +build_location=g:/php-sdk/php53/vc9/x86/ + +[build-nts-windows-vc9-x86] +name=nts-windows-vc9-x86 +compiler=vc9 +arch=x86 +configure_options=--enable-snapshot-build --disable-zts --disable-isapi --enable-debug-pack --disable-isapi --without-mssql --without-pdo-mssql --without-pi3web --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared --enable-com-dotnet --with-mcrypt=static --enable-object-out-dir=d:/temp/obj/ +platform=windows + +[build-ts-windows-vc9-x86] +name=ts-windows-vc9-x86 +compiler=vc9 +arch=x86 +configure_options=--enable-snapshot-build --disable-isapi --enable-debug-pack --without-mssql --without-pdo-mssql --without-pi3web --with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared --enable-com-dotnet --with-mcrypt=static --enable-object-out-dir=d:/temp/obj/ +platform=windows Added: web/php-rmtools/trunk/client/data/config/branch/phptrunk.ini =================================================================== --- web/php-rmtools/trunk/client/data/config/branch/phptrunk.ini (rev 0) +++ web/php-rmtools/trunk/client/data/config/branch/phptrunk.ini 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,3 @@ +branch=trunk +repo_name=php.net +repo_branch_name=/php-src/php/trunk Added: web/php-rmtools/trunk/client/data/config/credentials_ftps.php =================================================================== --- web/php-rmtools/trunk/client/data/config/credentials_ftps.php (rev 0) +++ web/php-rmtools/trunk/client/data/config/credentials_ftps.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,4 @@ +'); + } + $this->config = new BranchConfig($config_path); + $this->repo = Repository::fromBranchConfig($this->config); + $this->repo->setModule($this->config->getModule()); + $this->repo->setBranch($this->config->getBranch()); + $this->db_path = __DIR__ . '/../data/db/' . $this->config->getName() . '.json'; + if (file_exists($this->db_path)) { + $this->data = json_decode(file_get_contents($this->db_path)); + } else { + $this->data = array( + 'revision_last' => NULL, + 'revision_previous' => NULL, + 'revision_last_exported' => NULL, + ); + } + $this->addBuildList(); + } + + private function addBuildList() + { + $builds = $this->config->getBuildList(); + + if (!empty($builds)) { + $this->data->builds = array(); + foreach ($builds as $n => $v) { + $this->data->builds[] = $n; + } + } else { + $this->data->builds = NULL; + } + } + + public function update() + { + $this->data->revision_previous = $this->data->revision_last; + $this->data->revision_last = $this->repo->getLastCommitId(); + $json = json_encode($this->data); + file_put_contents($this->db_path, $json); + } + + public function hasNewRevision() + { + return ($this->data->revision_last == $this->data->revision_previous || $this->data->revision_previous == NULL); + } + + public function export($revision = false, $zip = false) + { + $dir_name = $this->config->getName() . '-src-r' . $this->data->revision_last; + $target = $this->config->getBuildDir() . '/' . $dir_name; + $this->repo->export($target); + if ($zip) { + $zip_path = $dir_name . '.zip'; + $cmd = "zip -q -r $zip_path $dir_name"; + $res = exec_single_log($cmd, $this->config->getBuildDir()); + } + $target = realpath($target); + return $target; + } + + public function createSourceSnap($revision = false) + { + return $this->export($revision = $revision, true); + } + + public function setLastRevisionExported($last_rev) + { + $this->data->revision_last_exported = $last_rev; + $json = json_encode($this->data); + file_put_contents($this->db_path, $json); + } + + public function getLastRevisionExported() + { + return $this->data->revision_last_exported; + } + + public function getLastRevisionId() + { + if (!$this->data->revision_last) { + $this->update(); + } + return $this->data->revision_last; + } + + function getBuildList($platform) + { + $builds = array(); + foreach ($this->data->builds as $build_name) { + $build = $this->config->getBuildFromName($build_name); + if (isset($build['platform']) && $build['platform'] == $platform) { + $builds[] = $build_name; + } + } + return $builds; + } + + function createBuildInstance($build_name) + { + $build = $this->config->getBuildFromName($build_name); + + if (!$build) { + throw new \Exception("Invalid build name <$build_name>"); + } + + $compiler = strtolower($build['compiler']); + $arch = strtolower($build['arch']); + switch ($compiler) { + case 'vc9': + case 'vc6': + $class_name = 'rmtools\BuildVC'; + break; + case 'icc': + break; + case 'gcc': + break; + } + $build = new $class_name($this, $build_name); + return $build; + } +} Added: web/php-rmtools/trunk/client/include/BranchConfig.php =================================================================== --- web/php-rmtools/trunk/client/include/BranchConfig.php (rev 0) +++ web/php-rmtools/trunk/client/include/BranchConfig.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,69 @@ + 'configure_options', + 'BuildDir' => 'build_dir', + 'BuildLocation' => 'build_location', + 'SourceDir' => 'source_dir', + 'Include' => 'INCLUDE', + 'Lib' => 'LIB', + 'Path' => 'PATH', + 'Compiler' => 'compiler', + 'Architecture' => 'arch', + 'Branch' => 'branch', + 'Name' => 'name', + 'RepoName'=>'repo_name', + 'Branch'=> 'repo_branch', + 'Module' => 'repo_module', + ); + + function __construct($path) + { + //$this->config = parse_ini_file($path, false, INI_SCANNER_RAW); + $this->config = parse_ini_file($path, true,INI_SCANNER_RAW); + if (!$this->config) { + throw new \Exception('Cannot parse config file <' . $path . '>'); + } + + $builds = array(); + + foreach ($this->config as $name => $entry) { + if (substr($name, 0, 6) == 'build-') { + $name = str_ireplace('build-', '', $name); + $builds[$name] = $entry; + } + } + $this->builds = $builds; + } + + function __call($name, $key) { + $name = str_replace('get', '', $name); + if (!isset($this->config_keys[$name])) { + throw new \Exception("Invalid config entry name <$name>"); + } + + $name = $this->config_keys[$name]; + return (isset($this->config[$name]) ? $this->config[$name] : ''); + } + + function getBuildList() + { + return $this->builds; + } + + function getBuildFromName($build_name) { + return isset($this->builds[$build_name]) ? $this->builds[$build_name] : NULL; + } + + function getConfigureOptions($build_name) + { + if (isset($this->builds[$build_name]) && isset($this->builds[$build_name]['configure_options'])) { + return $this->builds[$build_name]['configure_options']; + } else { + return ''; + } + } +} Added: web/php-rmtools/trunk/client/include/Build.php =================================================================== --- web/php-rmtools/trunk/client/include/Build.php (rev 0) +++ web/php-rmtools/trunk/client/include/Build.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,7 @@ +branch = $branch; + $this->build_name = $build_name; + $this->obj_dir = $this->branch->config->getBuildDir(); + $this->compiler = $this->branch->config->getCompiler(); + $this->architecture = $this->branch->config->getArchitecture(); + + $vc_env_prefix = strtoupper($this->compiler); + if ($this->architecture == 'x64') { + $vc_env_prefix .= '_X64_'; + } else { + $vc_env_prefix .= '_'; + } + + $env = array(); + $env['PATH'] = getenv($vc_env_prefix . 'PATH') . ';' . getenv('PATH') ; + $env['INCLUDE'] = getenv($vc_env_prefix . 'INCLUDE'); + $env['LIB'] = getenv($vc_env_prefix . 'LIB'); + + /* We don't support anymore VC6, so calling these scripts from the + SDK are just fine */ + if (!$env['INCLUDE'] || !$env['LIB']) { + $env['INCLUDE'] = getenv('INCLUDE'); + $env['LIB'] = getenv('LIB'); + } + + $env['TMP'] = $env['TEMP'] = getenv('TEMP'); + $env['SystemDrive'] = getenv('SystemDrive'); + $env['SystemRoot'] = getenv('SystemRoot'); + $env['BISON_SIMPLE'] = getenv('BISON_SIMPLE'); + $this->env = $env; + } + + function setSourceDir($src_dir) + { + $this->build_dir = $src_dir; + } + + private function addLogsToArchive() + { + $zip = new \ZipArchive(); + if ($zip->open($this->archive_path) === FALSE) { + throw new \Exception('cannot open archive'); + } + $zip->addFromString('logs\buildconf.txt', $this->log_buildconf); + $zip->addFromString('logs\configure.txt', $this->log_configure); + $zip->addFromString('logs\make.txt', $this->log_make); + $zip->addFromString('logs\archive.txt', $this->log_archive); + $zip->close(); + } + + function buildconf() + { + $cmd = 'buildconf'; + $ret = exec_single_log($cmd, $this->build_dir, $this->env); + if (!$ret) { + throw new \Exception('buildconf failed'); + } + $this->log_buildconf = $ret['log']; + } + + function configure($extra = false) + { + $args = $this->branch->config->getConfigureOptions($this->build_name) . ($extra ?: $extra); + $cmd = 'configure ' . $args . ' --enable-object-out-dir=' . $this->obj_dir . '/' . $this->build_name; + mkdir($this->obj_dir . '/' . $this->build_name); + $ret = exec_single_log($cmd, $this->build_dir, $this->env); + if (!$ret) { + throw new \Exception('Configure failed'); + } + $this->log_configure = $ret['log']; + } + + function make() + { + $cmd = 'nmake'; + $ret = exec_single_log($cmd, $this->build_dir, $this->env); + if (!$ret) { + throw new \Exception('Make failed'); + } + $this->log_make = $ret['log']; + } + + function makeArchive() + { + $cmd = 'nmake snap'; + $ret = exec_single_log($cmd, $this->build_dir, $this->env); + if (!$ret) { + throw new \Exception('Make snap failed'); + } + + $this->log_archive = $ret['log']; + + if (!preg_match('/Build dir: (.*)/', $this->log_configure, $matches)) { + throw new \Exception('Make archive failed, cannot find build dir'); + } + $zip_dir = trim($matches[1]); + + if (!preg_match('/.*(php-\d\.\d\.\d.*\.zip)/', $this->log_archive, $matches)) { + throw new \Exception('Make archive failed, cannot find php archive'); + } + $zip_filename = trim($matches[1]); + + if (!preg_match('/.*(php-devel-pack-\d\.\d\.\d.*\.zip)/', $this->log_archive, $matches)) { + throw new \Exception('Make archive failed, cannot find php-devel archive'); + } + $zip_devel_filename = trim($matches[1]); + $this->zip_devel_filename = $zip_devel_filename; + + if (!preg_match('/.*(php-debug-pack-\d\.\d\.\d.*\.zip)/', $this->log_archive, $matches)) { + throw new \Exception('Make archive failed, cannot find php-debug archive'); + } + $zip_debug_filename = trim($matches[1]); + $this->zip_debug_filename = $zip_debug_filename; + + $this->archive_path = realpath($zip_dir . '/' . $zip_filename); + $this->debug_path = realpath($zip_dir . '/' . $zip_debug_filename); + $this->devel_path = realpath($zip_dir . '/' . $zip_devel_filename); + + $this->addLogsToArchive(); + } + + function getMakeLogParsed() + { + $parser = new MakeLogParserVc; + $tmpfile = $this->obj_dir . '/' . 'make.txt'; + file_put_contents($tmpfile, $this->log_make); + $parser->parse($tmpfile, $this->build_dir); + $this->stats = $parser->stats; + return $parser->toHtml($this->build_name); + } + + function getStats() + { + return $this->stats; + } + + function clean() + { + $dir = $this->obj_dir . '/' . $this->build_name; + //rmdir_rf($this->obj_dir . '/' . $this->build_name); + echo "rm $dir\n"; + } + + function getLogs() + { + + } +} Added: web/php-rmtools/trunk/client/include/LogParser.php =================================================================== --- web/php-rmtools/trunk/client/include/LogParser.php (rev 0) +++ web/php-rmtools/trunk/client/include/LogParser.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,9 @@ +log; + ob_start(); + include __DIR__ . '/../template/make_log.tpl.php'; + $html = ob_get_contents(); + ob_end_clean(); + return $html; + } +} Added: web/php-rmtools/trunk/client/include/MakeLogParserVC.php =================================================================== --- web/php-rmtools/trunk/client/include/MakeLogParserVC.php (rev 0) +++ web/php-rmtools/trunk/client/include/MakeLogParserVC.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,148 @@ +stats = array('warning' => 0, 'error' => 0); + $pcre = '/(error|warning):\s+(.+)/'; + $pcre = '/(error|warning)/'; + $lines = file($path); + if (empty($lines)) { + return NULL; + } + $listing = array(); + $line_nr = 1; + + if ($root_src_dir && $root_src_dir[strlen($root_src_dir) -1] != '\\') { + $root_src_dir .= '\\'; + } + + //win32\build\deplister.c(50) : warning C4090: 'function' : different 'const' qualifiers + $log = ''; + $log = array(); + foreach ($lines as $line) { + $out = '#' . ($line_nr++) . ' '; + $res = preg_match($pcre, $line); + if ($res) { + /* absolute path + error/warning */ + $txt = $line; + $re1='([a-z]:\\\\(?:[-\\w\\.\\d]+\\\\)*(?:[-\\w\\.\\d]+)?)'; # Windows Path 1 + $re2='.*?'; # Non-greedy match on filler + $re3='(\\d+)'; # Integer Number 1 + $re4='.*?'; # Non-greedy match on filler + $re5='((?:[a-z][a-z]+))'; # Word 1 + $re6='.*?'; # Non-greedy match on filler + $re7='((?:[a-z][a-z]*[0-9]+[a-z0-9]*))'; # Alphanum 1 + $re8 =':(.*?)$'; + if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8."/is", $txt, $matches)) + { + $winpath1 = $matches[1][0]; + $int1 = $matches[2][0]; + $word1 = $matches[3][0]; + $alphanum1 = $matches[4][0]; + $error_msg = trim(str_replace(array("\r","\n"), array('',''),$matches[5][0])); + $row = "match 1: ($winpath1) ($int1) ($word1) ($alphanum1) ($error_msg)\n"; + $row = array( + 'file' => $winpath1, + 'line' => $int1, + 'level' => $word1, + 'code' => $alphanum1, + 'message' => $error_msg + ); + } else { + /* relative path + error/warning */ + $re1='(.*?)'; # Non-greedy match on filler + $re2=''; # Uninteresting: int + $re3=''; # Non-greedy match on filler + $re4='\((\\d+)\)'; # Integer Number 1 + $re5='.*?'; # Non-greedy match on filler + $re6='((?:[a-z][a-z]+))'; # Word 1 + $re7='.*?'; # Non-greedy match on filler + $re8='((?:[a-z][a-z]*[0-9]+[a-z0-9]*))'; # Alphanum 1 + $re9 =':(.*?)$'; + + if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9."/is", $txt, $matches)) + { + $path=$matches[1][0]; + $int1=$matches[2][0]; + $word1=$matches[3][0]; + $alphanum1=$matches[4][0]; + $error_msg=trim(str_replace(array("\r","\n"), array('',''),$matches[5][0])); + $out .= "match 2: ($path) ($int1) ($word1) ($alphanum1) ($error_msg)\n"; + $row = array( + 'file' => $path, + 'line' => $int1, + 'level' => $word1, + 'code' => $alphanum1, + 'message' => $error_msg + ); + } else { + /* cl.exe, link, etc. + error/warning */ + $re1='((?:[a-z][a-z]+))'; # Word 1 + $re2='.*?'; # Non-greedy match on filler + $re3='((?:[a-z][a-z]+))'; # Word 2 + $re4='.*?'; # Non-greedy match on filler + $re5='((?:[a-z][a-z]*[0-9]+[a-z0-9]*))'; # Alphanum 1 + $re6 =':(.*?)$'; + + if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6."/is", $txt, $matches)) + { + $word1=$matches[1][0]; + $word2=$matches[2][0]; + $alphanum1=$matches[3][0]; + + $error_msg = trim(str_replace(array("\r","\n"), array('',''), $matches[4][0])); + $out .= "match 3: ($word1) ($word2) ($alphanum1) ($error_msg)\n"; + if (substr($alphanum1, 0, 3) == 'LNK') { + if (strpos($txt, '.lib') || strpos($txt, '.obj')) { + $pos = strpos($txt, ':'); + $file = substr($txt, 0, $pos); + $re = preg_match('/^.*: (warning|error) LNK[0-9]+:.*$/', $txt, $matches); + if ($re) { + $level = $matches[1]; + } else { + $level = ''; + } + } + + $row = array( + 'file' => $file, + 'line' => '', + 'level' => $level, + 'code' => $alphanum1, + 'message' => $error_msg + ); + } else { + $row = array( + 'file' => '', + 'line' => $word1, + 'level' => $word2, + 'code' => $alphanum1, + 'message' => $error_msg + ); + } + } else { + continue; + } + } + } + + $row['file'] = str_ireplace($root_src_dir, '', $row['file']); + $row['section'] = strtolower(dirname($row['file'])); + $row['file'] = str_ireplace($row['section'] . '\\', '', $row['file']); + if (isset($this->stats[$row['level']])) { + $this->stats[$row['level']]++; + } + $log[] = $row; + } else { + continue; + } + } + $this->log = $log; + } +} Added: web/php-rmtools/trunk/client/include/Repository.php =================================================================== --- web/php-rmtools/trunk/client/include/Repository.php (rev 0) +++ web/php-rmtools/trunk/client/include/Repository.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,32 @@ +getRepoName(); + $config_path = __DIR__ . '/../data/config/repo/' . $name . '.ini'; + + if (!is_readable($config_path)) { + throw new \Exception('Cannot open repo data <' . $config_path . '>'); + } + + $repo = parse_ini_file($config_path, true,INI_SCANNER_RAW); + if (!$repo) { + throw new \Exception('Cannot parse config file <' . $config_path . '>'); + } + + if (!isset($repo['type'])) { + throw new \Exception('Invalid repo config data, no type defined'); + } + switch ($repo['type']) { + case 'svn': + $r = new Svn($repo['url']); + return $r; + break; + } + } +} Added: web/php-rmtools/trunk/client/include/Svn.php =================================================================== --- web/php-rmtools/trunk/client/include/Svn.php (rev 0) +++ web/php-rmtools/trunk/client/include/Svn.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,55 @@ +repo_url = $repo_url; + } + + function setModule($module) { + $this->module = $module; + } + + function setBranch($branch) { + $this->branch = $branch; + } + + public function export($dest, $revision = false) + { + $cmd = $this->svn_cmd . ' export -q ' . $this->repo_url . $this->module. $this->branch . ' ' . $dest; + $res = exec_single_log($cmd); + if ($res === FALSE) { + throw new \Exception('svn export failed <' . $this->repo_url . '/' . $this->module. '/' . $this->branch . '>'); + } + if ($res['log']) { + file_put_contents('g:/temp/obj/svnlog.txt', $res['log']); + } + } + + public function info() + { + } + + public function getLastCommitId() + { + $cmd = $this->svn_cmd . ' info --xml ' . $this->repo_url . $this->module. $this->branch; + + $res = exec_sep_log($cmd); + if ($res && is_null($res['log_stdout'])) { + throw new \Exception('svn log failed <' . $this->repo_url . '/' . $this->module. '/' . $this->branch . '>'); + } + + $sx = new \SimpleXMLElement($res['log_stdout']); + if (!$sx) { + throw new \Exception('svn log failed ' . $path); + } + $revision = (int)($sx->entry->commit['revision']); + return $revision; + } +} Added: web/php-rmtools/trunk/client/include/Tools.php =================================================================== --- web/php-rmtools/trunk/client/include/Tools.php (rev 0) +++ web/php-rmtools/trunk/client/include/Tools.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,188 @@ + array("pipe", "w"), // stdout is a pipe that the child will write to + 2 => array("pipe", "w") // stderr is a file to write to + ); + + $env = NULL; + $process = proc_open($cmd, $descriptor_spec, $pipes, $cwd, $env); + + if (is_resource($process)) { + // $pipes now looks like this: + // 0 => writeable handle connected to child stdin + // 1 => readable handle connected to child stdout + // Any error output will be appended to /tmp/error-output.txt + $log_stdout = stream_get_contents($pipes[1]); + $log_stderr = stream_get_contents($pipes[2]); + fclose($pipes[1]); + fclose($pipes[2]); + + $return_value = proc_close($process); + } + + return array( + 'log_stdout' => $log_stdout, + 'log_stderr' => $log_stderr, + 'return_value' => $return_value + ); +} + +function exec_single_log($cmd, $cwd = NULL, $env = NULL) +{ + /* We take one log only, for stdout and stderr + So it looks like a normal output. + */ + $descriptor_spec = array( + 1 => array("pipe", "w"), // stdout + ); + + $cmd .= ' 2>&1'; + + $process = proc_open($cmd, $descriptor_spec, $pipes, $cwd, $env); + + if (is_resource($process)) { + // $pipes now looks like this: + // 0 => writeable handle connected to child stdin + // 1 => readable handle connected to child stdout + // Any error output will be appended to /tmp/error-output.txt + $log = stream_get_contents($pipes[1]); + fclose($pipes[1]); + $return_value = proc_close($process); + } else { + return false; + } + + $ret = array( + 'return_value' => $return_value, + 'log' => $log + ); + return $ret; +} + +function wget($url, $dest) +{ + $fp = fopen ($dest, 'wb+'); + $ch = \curl_init(); + \curl_setopt($ch, CURLOPT_URL,$url); + \curl_setopt($ch, CURLOPT_FILE, $fp); + \curl_exec($ch); + \curl_close($ch); + \fclose($fp); +} + +function rmdir_rf($path) +{ + if (is_dir($path)) { + $objects = scandir($path); + foreach ($objects as $object) { + if ($object != "." && $object != "..") { + if (is_dir($path."/".$object)) { + rmdir_rf($path."/".$object); + }else { + @unlink($path."/".$object); + } + } + } + reset($objects); + rmdir($path); + } +} + +function ftp_make_directory($ftp_stream, $dir) +{ + if (ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true; + if (!make_directory($ftp_stream, dirname($dir))) return false; + return ftp_mkdir($ftp_stream, $dir); +} + +function ftp_is_dir($ftp_stream, $dir) +{ + $original_directory = ftp_pwd($ftp_stream); + if ( @ftp_chdir( $ftp_stream, $dir ) ) { + ftp_chdir( $ftp_stream, $original_directory ); + return true; + } else { + return false; + } +} + +function upload_build_result_ftp_curl($src_dir, $target) +{ + include __DIR__ . '/../data/config/credentials_ftps.php'; + + $ftp = ftp_connect($ftp_server); + $login_result = ftp_login($ftp, $user_snaps, $password); + if (!$login_result) { + return false; + } + $res = ftp_make_directory($ftp, $target. '/logs'); + ftp_close($ftp); + + $curl = array(); + + $ftpserver = 'windows.php.net'; + $ftp_path = $target; + $ftp_user = $user_snaps; + $ftp_password = $password; + + if ($ftp_path[0] != '/') { + $ftp_path = '/' . $ftp_path; + } + $mh = \curl_multi_init(); + + $files = glob($src_dir . '/*.{zip,json}', GLOB_BRACE); + + foreach ($files as $i => $local_file) { + + $ch = $curl[$i] = \curl_init(); + $fp = fopen($local_file, "rb"); + $local_file = basename($local_file); + + $remoteurl = "ftps://${ftp_user}:${ftp_password}@${ftpserver}${ftp_path}/${local_file}"; + + \curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + \curl_setopt($ch, CURLOPT_URL, $remoteurl); + \curl_setopt($ch, CURLOPT_UPLOAD, 1); + \curl_setopt($ch, CURLOPT_INFILE, $fp); + \curl_setopt($ch , CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password); + + \curl_multi_add_handle ($mh, $ch); + } + + $files = glob($src_dir . '/logs/*.*'); + + foreach ($files as $i => $local_file) { + + $ch = $curl[$i] = \curl_init(); + $fp = fopen($local_file, "rb"); + $local_file = basename($local_file); + + $remoteurl = "ftps://${ftp_user}:${ftp_password}@${ftpserver}${ftp_path}/logs/${local_file}"; + + \curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + \curl_setopt($ch, CURLOPT_URL, $remoteurl); + \curl_setopt($ch, CURLOPT_UPLOAD, 1); + \curl_setopt($ch, CURLOPT_INFILE, $fp); + \curl_setopt($ch , CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password); + + \curl_multi_add_handle ($mh, $ch); + } + + do { + $n = \curl_multi_exec($mh,$active); + } while ($active); + + foreach ($curl as $ch) { + \curl_multi_remove_handle($mh, $ch); + if (\curl_errno($ch) != 0) { + echo \curl_error($ch) . "\n"; + } + \curl_close($ch); + } + \curl_multi_close($mh); +} Added: web/php-rmtools/trunk/client/script/snap.php =================================================================== --- web/php-rmtools/trunk/client/script/snap.php (rev 0) +++ web/php-rmtools/trunk/client/script/snap.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,110 @@ + 3) { + echo "Usage: snapshot [force 1/0]\n"; + exit(); +} + +$new_rev = false; +$branch_name = $argv[1]; +$force = isset($argv[2]) ? true : false; +$config_path = __DIR__ . '/../data/config/branch/' . $branch_name . '.ini'; + +$branch = new rm\Branch($config_path); +$branch->update(); + +$branch_name = $branch->config->getName(); + +if ($force || $branch->hasNewRevision()) { + $last_rev = $branch->getLastRevisionId(); + if ($force || $last_rev != $branch->getLastRevisionExported()) { + $new_rev = true; + echo "processing revision $last_rev\n"; + $src_original_path = $branch->createSourceSnap(); + $branch->setLastRevisionExported($last_rev); + + $build_dir_parent = $branch->config->getBuildLocation(); + + if (!is_dir($build_dir_parent)) { + echo "Invalid build location <$build_dir_parent>\n"; + exit(-1); + } + + $toupload_dir = TMP_DIR . '/' . $branch_name . '/r' . $last_rev . '-builds/'; + if (!is_dir($toupload_dir)) { + mkdir($toupload_dir, 0655, true); + } + + if (!is_dir($toupload_dir . '/logs')) { + mkdir($toupload_dir . '/logs', 0655, true); + } + + copy($src_original_path . '.zip', $toupload_dir . '/' . $branch_name . '-src-r'. $last_rev . '.zip'); + + $builds = $branch->getBuildList('windows'); + + foreach ($builds as $build_name) { + $build_src_path = realpath($build_dir_parent) . DIRECTORY_SEPARATOR . $build_name; + $log = rm\exec_single_log('mklink /J ' . $build_src_path . ' ' . $src_original_path); + + $build = $branch->createBuildInstance($build_name); + echo "running build in <$build_src_path>\n"; + try { + $build->setSourceDir($build_src_path); + $build->buildconf(); + $build->configure(); + $build->make(); + $build->makeArchive(); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + echo $build->log_buildconf; + } + + if ($build->archive_path) { + copy($build->archive_path, $toupload_dir . '/php-' . $branch_name . '-' . $build_name . '-r'. $last_rev . '.zip'); + } + if ($build->archive_path) { + copy($build->devel_path, $toupload_dir . '/php-devel-pack-' . $branch_name . '-' . $build_name . '-r'. $last_rev . '.zip'); + } + if ($build->archive_path) { + copy($build->debug_path, $toupload_dir . '/php-debug-pack-' . $branch_name . '-' . $build_name . '-r'. $last_rev . '.zip'); + } + + file_put_contents($toupload_dir . '/logs/buildconf-' . $build_name . '-r'. $last_rev . '.txt', $build->log_buildconf); + file_put_contents($toupload_dir . '/logs/configure-' . $build_name . '-r'. $last_rev . '.txt', $build->log_configure); + file_put_contents($toupload_dir . '/logs/make-' . $build_name . '-r'. $last_rev . '.txt', $build->log_make); + file_put_contents($toupload_dir . '/logs/archive-' . $build_name . '-r'. $last_rev . '.txt', $build->log_archive); + + $html_make_log = $build->getMakeLogParsed(); + file_put_contents($toupload_dir . '/logs/make-' . $build_name . '-r'. $last_rev . '.html', $html_make_log); + copy(__DIR__ . '/../template/log_style.css', $toupload_dir . '/logs/log_style.css'); + + $stats = $build->getStats(); + $json_filename = $build_name . '.json'; + + $json_data = array( + 'stats' => $stats, + 'has_php_pkg' => file_exists($build->archive_path), + 'has_debug_pkg' => file_exists($build->debug_path), + 'has_devel_pkg' => file_exists($build->devel_path), + ); + $json = json_encode($json_data); + file_put_contents($toupload_dir . '/' . $json_filename, $json); + + rm\upload_build_result_ftp_curl($toupload_dir, $branch_name . '/r' . $last_rev); + $build->clean(); + rmdir($build_src_path); + } + } +} + +if (!$new_rev) { + echo "no new revision.\n"; +} + +echo "Done.\n"; Added: web/php-rmtools/trunk/client/template/log_style.css =================================================================== --- web/php-rmtools/trunk/client/template/log_style.css (rev 0) +++ web/php-rmtools/trunk/client/template/log_style.css 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,12 @@ +body {background-color: #ffffff;font-size: 80.01%; /* 12px [1] */color: black;font-family: arial, sans-serif;padding: 1em;margin: 0em;} +#log {margin-top:.5em;} +#log .con{font-size:small;color:#000;} +#log .l { color:#666; } +#log .m {background-color:#ffb;} +#log i {color: green; font-weight:bold;} +#log tr.dir{background-color:#C5D5A9;} +#log td.f{width:3em;padding-left:2em;padding-right:.5em;} +#log .alt {background-color: #E8E8F0;} +#log td.error{background-color: #FF0000;} +#log td.warning{background-color: #FF9966;} +#log td.lib{background-color: #FF9933;} Added: web/php-rmtools/trunk/client/template/make_log.tpl.php =================================================================== --- web/php-rmtools/trunk/client/template/make_log.tpl.php (rev 0) +++ web/php-rmtools/trunk/client/template/make_log.tpl.php 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,56 @@ + + + + +<?php echo $title; ?> + + +

+
+ + + + + + >> + +
File:LineLevelCodeMessage
 
+
+ + Added: web/php-rmtools/trunk/client/template/untitled =================================================================== --- web/php-rmtools/trunk/client/template/untitled (rev 0) +++ web/php-rmtools/trunk/client/template/untitled 2011-04-25 12:44:28 UTC (rev 310472) @@ -0,0 +1,7 @@ +#results {margin-top:.5em;} +#results .con{font-size:small;color:#000;} +#more .l, #results .l { color:#666; } +#results .m {background-color:#ffb;} +#results i {color: green; font-weight:bold;} +#results tr.dir{background-color:#C5D5A9;} +#results td.f{width:3em;padding-left:2em;padding-right:.5em;}