Commit: 2118134880da652f06f0e3e80caa19a26e9761f4 Author: Anatol Belski <[email protected]> Sun, 20 Nov 2016 04:10:20 +0100 Parents: b170fbdbe4c878aeb8ef3858659d3021bcc2b27c Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=2118134880da652f06f0e3e80caa19a26e9761f4 Log: implement two builds per arch for snaps Changed paths: M include/Branch.php M script/snap.php Diff: diff --git a/include/Branch.php b/include/Branch.php index 307d55c..e2785bd 100644 --- a/include/Branch.php +++ b/include/Branch.php @@ -13,6 +13,7 @@ class Branch { public $db_path; private $has_new_revision; public $data = NULL; + private $required_build_runs = 2; public function __construct($config_path) { @@ -26,11 +27,15 @@ class Branch { $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)); + if ($this->data->build_run == $this->required_build_runs) { + $this->build_run = 0; + } } else { $data = new \StdClass; $data->revision_last = NULL; $data->revision_previous = NULL; $data->revision_last_exported = NULL; + $data->build_run = 0; $this->data = $data; } $this->addBuildList(); @@ -52,9 +57,12 @@ class Branch { public function update() { + $this->data->build_run++; + $last_id = $this->repo->getLastCommitId(); - if (strcasecmp($last_id, (string)$this->data->revision_last) != 0 || - strcasecmp($last_id, $this->data->revision_previous) != 0) { + /* Either there's no db file at all yet, or this is the last required build run. */ + if ($this->requiredBuldRunsReached() && (strcasecmp($last_id, (string)$this->data->revision_last) != 0 || strcasecmp($last_id, $this->data->revision_previous) != 0) + || NULL == $this->revision_last && NULL == $this->revision_previous) { $this->data->revision_previous = $this->data->revision_last; $this->data->revision_last = $last_id; $json = json_encode($this->data); @@ -63,9 +71,14 @@ class Branch { } } + public function requiredBuldRunsReached() + { + return $this->data->build_run == $this->required_build_runs; + } + public function hasNewRevision() { - return $this->has_new_revision || ( $this->data->revision_previous == NULL); + return $this->has_new_revision || $this->data->revision_previous == NULL; } public function export($revision = false, $build_type = false, $zip = false, $is_zip = false) @@ -114,9 +127,13 @@ class Branch { public function setLastRevisionExported($last_rev) { - $this->data->revision_last_exported = $last_rev; - $json = json_encode($this->data); - file_put_contents($this->db_path, $json); + /* Basically, we need two runs for x64 and x86, every run covers ts and nts. + Only set the revision exported, if we're on last required build run. */ + if ($this->requiredBuldRunsReached()) { + $this->data->revision_last_exported = $last_rev; + $json = json_encode($this->data); + file_put_contents($this->db_path, $json); + } } public function getLastRevisionExported() diff --git a/script/snap.php b/script/snap.php index 8d6844f..f93349d 100644 --- a/script/snap.php +++ b/script/snap.php @@ -5,15 +5,15 @@ include __DIR__ . '/../include/Tools.php'; use rmtools as rm; -if ($argc < 3 || $argc > 4) { - echo "Usage: snapshot <config name> <build type> [force 1/0]\n"; +if ($argc < 2 || $argc >3) { + echo "Usage: snapshot <config name> [force 1/0]\n"; exit(); } $new_rev = false; $branch_name = $argv[1]; -$build_type = strtolower($argv[2]); -$force = isset($argv[3]) ? true : false; +$build_type = "all"; /* Build both ts and NTS for one given arch. This also complies with the top level script, otherwise it'd need a special SDK setup. */ +$force = isset($argv[2]) ? true : false; $sdk_arch = getenv("PHP_SDK_ARCH"); if (!$sdk_arch) { throw new \Exception("Arch is empty, the SDK might not have been setup. "); @@ -32,6 +32,16 @@ echo "\t$branch_name\n"; echo "\tprevious revision was: " . $branch->getPreviousRevision() . "\n"; echo "\tlast revision is: " . $branch->getLastRevisionId() . "\n"; if ($force || $branch->hasNewRevision()) { +/* Prepared rewritten part, which might be helpful for PGO integration later. */ +/*$builds_top = $branch->getBuildList('windows'); +for ($i = 0; $i < count($builds_top) && ($force || $branch->hasNewRevision()); $i++) { + if (preg_match(",(ts|nts),", $builds_top[$i], $m)) { + $build_type = $m[0]; + } else { + echo "Unknown build type '{$builds_top[$i]}', skip\n"; + continue; + }*/ + if ($force || substr_compare($last_rev, $branch->getLastRevisionExported(), 0, 7) != 0) { $new_rev = true; echo "processing revision $last_rev\n"; @@ -60,7 +70,6 @@ if ($force || $branch->hasNewRevision()) { $last_rev = substr($last_rev, 0, 7); } $src_original_path = $branch->createSourceSnap($build_type); - $branch->setLastRevisionExported($last_rev); $build_dir_parent = $branch->config->getBuildLocation(); @@ -199,9 +208,12 @@ if ($force || $branch->hasNewRevision()) { // $build->clean(); rmdir($build_src_path); } + + $branch->setLastRevisionExported($last_rev); } } + if (!$new_rev) { echo "no new revision.\n"; } -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
