Commit: 89296f7a9eaecd03fe4c62737f6ba10bd5e1271c Author: Anatol Belski <[email protected]> Fri, 15 Sep 2017 19:12:04 +0200 Parents: 311b929c81d58a3e5e446d39bff4447a7ecc3651 Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=89296f7a9eaecd03fe4c62737f6ba10bd5e1271c Log: Parallel build for snaps, basic changes Changed paths: M include/Branch.php M script/snap.php Diff: diff --git a/include/Branch.php b/include/Branch.php index fd9edd2..31e5be1 100644 --- a/include/Branch.php +++ b/include/Branch.php @@ -6,6 +6,7 @@ include __DIR__ . '/Repository.php'; include __DIR__ . '/BuildVC.php'; class Branch { + const REQUIRED_BUILDS_NUM = 4; public $last_revision; public $last_revision_has_snap; public $config; @@ -47,6 +48,8 @@ class Branch { $data->revision_last = NULL; $data->revision_previous = NULL; $data->revision_last_exported = NULL; + $data->build_num = 0; + $data->builds = array(); } return $data; @@ -63,13 +66,27 @@ class Branch { $builds = $this->config->getBuildList(); if (!empty($builds)) { - foreach ($builds as $n => $v) { - if (in_array($n, $this->data->builds) && $this->hasUnfinishedBuild()) { + if ($build_name) { + if (in_array($build_name, $this->data->builds) && $this->hasUnfinishedBuild()) { throw new \Exception("Builds for '$n' are already done or in progress"); } - $this->data->builds[] = $n; - if ($build_name && $n == $build_name) { - break; + $found = 0; + foreach ($builds as $n => $v) { + if ($n == $build_name) { + $found = 1; + $this->data->builds[] = $n; + break; + } + } + if (!$found) { + throw new \Exception("Build name '$build_name' is not on the supported build list."); + } + } else { + foreach ($builds as $n => $v) { + if (in_array($n, $this->data->builds) && $this->hasUnfinishedBuild()) { + throw new \Exception("Builds for '$n' are already done or in progress"); + } + $this->data->builds[] = $n; } } } else { @@ -85,19 +102,20 @@ class Branch { throw new \Exception("last revision id is empty"); } - if ($this->requiredBuildRunsReached() && $this->hasNewRevision()) { + if ($this->requiredBuildRunsReached() && $this->hasNewRevision() || NULL == $this->data->revision_last) { $this->data->revision_previous = $this->data->revision_last; $this->data->revision_last = $last_id; } if ($this->requiredBuildRunsReached()) { $this->data->builds = array(); + $this->data->build_num = 0; } if ($this->hasUnfinishedBuild()) { $this->addBuildList($build_name); } - + $this->writeData(); return true; @@ -110,19 +128,16 @@ class Branch { public function requiredBuildRunsReached() { - /* XXX 4 stands for all the combinations, scan the files to get this number from there instead of hardcoding. */ - if (!isset($this->data->builds) || empty($this->data->builds)) { - return true; - } - - return count($this->data->builds) == 4; + $data = $this->readdata(); + $this->data->build_num = $data->build_num; + return $this->data->build_num == self::REQUIRED_BUILDS_NUM; } public function hasNewRevision() { $last = $this->repo->getLastCommitId(); - return $last && !$this->isLastRevisionExported($last); + return $last && !$this->isLastRevisionExported($last) || is_null($data->revision_last); } public function export($revision = false, $build_type = false, $zip = false, $is_zip = false) @@ -249,4 +264,16 @@ class Branch { return $build; } + + function buildFinished() + { + $this->data = $this->readdata(); + $this->data->build_num++; + $this->writeData(); + } + + function numBuildsRunning() + { + return count($this->data->builds); + } } diff --git a/script/snap.php b/script/snap.php index fab95a2..35c089d 100644 --- a/script/snap.php +++ b/script/snap.php @@ -28,6 +28,11 @@ try { goto out_here; } +if (!$branch->requiredBuildRunsReached() && rm\Branch::REQUIRED_BUILDS_NUM == $branch->numBuildsRunning()) { + $err_msg = "Waiting for " . $branch->getLastRevisionId() . " builds to finish."; + goto out_here; +} + $branch_name = $branch->config->getName(); $branch_name_short = $branch->config->getBranch(); @@ -35,17 +40,6 @@ echo "Running <" . realpath($config_path) . ">\n"; echo "\t$branch_name\n"; if ($branch->hasNewRevision() || $branch->hasUnfinishedBuild() || $force) { - - -/* 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; - }*/ try { if (!$branch->update("all" == $build_type ? NULL : $build_type)) { @@ -215,8 +209,11 @@ for ($i = 0; $i < count($builds_top) && ($force || $branch->hasNewRevision()); $ // $build->clean(); rmdir($build_src_path); + + $branch->buildFinished(); } + /* Only upload once, and then cleanup. */ if ($branch->requiredBuildRunsReached()) { $src_dir = $branch_name . '/r' . $last_rev; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
