foreach ($jobschedule->BuildConfigurations as $key => $value) { $xml .= '<buildconfiguration>'; $xml .= add_XML_value('name', $value); $xml .= add_XML_value('id', $key); if (isset($scheduleid) && $key == $ClientJobSchedule->GetBuildConfiguration()) { $xml .= add_XML_value('selected', '1'); } $xml .= '</buildconfiguration>'; } // OS versions $clientOS = new ClientOS(); $osids = $clientOS->getAll(); foreach ($osids as $osid) { $xml .= '<os>'; $clientOS->Id = $osid; $xml .= add_XML_value('name', $clientOS->GetName() . '-' . $clientOS->GetVersion() . '-' . $clientOS->GetBits() . 'bits'); $xml .= add_XML_value('id', $osid); if (isset($systems) && array_search($osid, $systems) !== false) { $xml .= add_XML_value('selected', '1'); } $xml .= '</os>'; } // Compiler versions $Compiler = new ClientCompiler(); $compilerids = $Compiler->getAll(); foreach ($compilerids as $compilerid) { $xml .= '<compiler>'; $Compiler->Id = $compilerid; $xml .= add_XML_value('name', $Compiler->GetName() . '-' . $Compiler->GetVersion()); $xml .= add_XML_value('id', $compilerid); if (isset($compilers) && array_search($compilerid, $compilers) !== false) {
public function GetCTestScript() { if (!$this->Id || !$this->SiteId) { add_log('ClientJobSchedule:GetCTestScript', 'Id not set'); return; } include 'config/config.php'; // Update the current run pdo_query("UPDATE client_jobschedule SET lastrun='" . date(FMT_DATETIMESTD) . "' WHERE id=" . qnum($this->Id)); $ClientSite = new ClientSite(); $ClientSite->Id = $this->SiteId; // Create a job $job = new ClientJob(); $job->ScheduleId = $this->Id; $job->StartDate = date('Y-m-d H:i:s'); $job->EndDate = date('1980-01-01 00:00:00'); $job->Status = CDASH_JOB_RUNNING; $job->SiteId = $this->SiteId; $job->OsId = $ClientSite->GetOS(); // Determine the appropriate CMake id (get the newest version) $cmake = pdo_query('SELECT sc.cmakeid FROM client_cmake,client_site2cmake AS sc LEFT JOIN client_jobschedule2cmake AS jc ON (jc.cmakeid=sc.cmakeid) WHERE client_cmake.id=sc.cmakeid AND sc.siteid=' . $this->SiteId . ' ORDER BY client_cmake.version DESC LIMIT 1'); $cmake_array = pdo_fetch_array($cmake); $job->CMakeId = $cmake_array[0]; // Determine the appropriate compiler $compiler = pdo_query('SELECT sc.compilerid FROM client_compiler,client_site2compiler AS sc LEFT JOIN client_jobschedule2compiler AS jc ON (jc.compilerid=sc.compilerid) WHERE client_compiler.id=sc.compilerid AND sc.siteid=' . $this->SiteId . ' ORDER BY client_compiler.version DESC LIMIT 1'); $compiler_array = pdo_fetch_array($compiler); $job->CompilerId = $compiler_array[0]; $job->Save(); $Project = new Project(); $Project->Id = $this->GetProjectId(); $Project->Fill(); $compiler = new ClientCompiler(); $compiler->Id = $job->CompilerId; $os = new ClientOS(); $os->Id = $job->OsId; // Initialize the variables $buildtype = 'Experimental'; //default switch ($this->GetType()) { case CDASH_JOB_EXPERIMENTAL: $buildtype = 'Experimental'; break; case CDASH_JOB_NIGHTLY: $buildtype = 'Nightly'; break; case CDASH_JOB_CONTINUOUS: $buildtype = 'Continuous'; break; } $ctest_script = '#' . $this->Id . "\n"; $ctest_script .= '#' . $Project->Name . "\n"; $ctest_script .= 'SET(JOB_BUILDTYPE ' . $buildtype . ')' . "\n"; $ctest_script .= 'SET(PROJECT_NAME "' . $Project->Name . '")' . "\n"; if (strlen($this->GetModule()) > 0) { $ctest_script .= 'SET(JOB_MODULE "' . $this->GetModule() . '")' . "\n"; } if (strlen($this->GetTag()) > 0) { $ctest_script .= 'SET(JOB_TAG "' . $this->GetTag() . '")' . "\n"; } if (strlen($this->GetBuildNameSuffix()) > 0) { $ctest_script .= 'SET(JOB_BUILDNAME_SUFFIX "' . $this->GetBuildNameSuffix() . '")' . "\n"; } $ctest_script .= 'SET(JOB_CMAKE_GENERATOR "' . $ClientSite->GetCompilerGenerator($job->CompilerId) . '")' . "\n"; $ctest_script .= 'SET(JOB_BUILD_CONFIGURATION "' . $this->BuildConfigurations[$this->GetBuildConfiguration()] . '")' . "\n"; $ctest_script .= 'SET(CLIENT_BASE_DIRECTORY "' . $ClientSite->GetBaseDirectory() . '")' . "\n"; $ctest_script .= 'SET(CLIENT_CMAKE_PATH "' . $ClientSite->GetCMakePath($job->CMakeId) . '")' . "\n"; $ctest_script .= 'SET(CLIENT_SITE "' . $ClientSite->GetName() . '")' . "\n"; $ctest_script .= 'SET(JOB_OS_NAME "' . $os->GetName() . '")' . "\n"; $ctest_script .= 'SET(JOB_OS_VERSION "' . $os->GetVersion() . '")' . "\n"; $ctest_script .= 'SET(JOB_OS_BITS "' . $os->GetBits() . '")' . "\n"; $ctest_script .= 'SET(JOB_COMPILER_NAME "' . $compiler->GetName() . '")' . "\n"; $ctest_script .= 'SET(JOB_COMPILER_VERSION "' . $compiler->GetVersion() . '")' . "\n"; $ctest_script .= 'SET(JOB_REPOSITORY "' . $this->GetRepository() . '")' . "\n"; // Set the program variables $programs = $ClientSite->GetPrograms(); $currentname = ''; foreach ($programs as $program) { $program_name = strtoupper($program['name']); $program_version = str_replace('.', '_', strtoupper($program['version'])); if ($program['name'] != $currentname) { $ctest_script .= 'SET(CLIENT_EXECUTABLE_' . $program_name . ' "' . $program['path'] . '")' . "\n"; $currentname = $program['name']; } $ctest_script .= 'SET(CLIENT_EXECUTABLE_' . $program_name . '_' . $program_version . ' "' . $program['path'] . '")' . "\n"; } if ($CDASH_USE_HTTPS === true) { $ctest_script .= 'set(CTEST_DROP_METHOD "https")' . "\n"; } else { $ctest_script .= 'set(CTEST_DROP_METHOD "http")' . "\n"; } $serverName = $CDASH_SERVER_NAME; if (strlen($serverName) == 0) { $serverName = $_SERVER['SERVER_NAME']; } $ctest_script .= 'set(CTEST_DROP_SITE "' . $serverName . '")' . "\n"; $dropLocation = dirname($_SERVER['PHP_SELF']) . '/submit.php?project=' . urlencode($Project->Name); $dropLocation .= '&clientscheduleid=' . $this->Id; $ctest_script .= 'set(CTEST_DROP_LOCATION "' . $dropLocation . '")' . "\n"; $ctest_script .= 'set(JOB_DROP_LOCATION "' . $dropLocation . '")' . "\n"; $ctest_script .= 'set(JOB_DROP_SITE "' . $serverName . '")' . "\n"; $ctest_script .= 'set(CTEST_DROP_SITE_CDASH TRUE)' . "\n"; $ctest_script .= 'set(CTEST_NOTES_FILES ${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME})' . "\n"; // Make the cache available $ctest_script .= 'set(JOB_INITIAL_CACHE "' . $this->GetCMakeCache() . '\\n")' . "\n"; // Set the macro to warn CDash that the script failed $ctest_script .= "\n" . 'MACRO(JOB_FAILED)' . "\n"; $uri = $_SERVER['REQUEST_URI']; $pos = strpos($uri, 'submit.php'); if ($pos !== false) { $uri = substr($uri, 0, $pos + 10); } $ctest_script .= ' file(DOWNLOAD "${CTEST_DROP_METHOD}://${CTEST_DROP_SITE}' . $uri . '?siteid=' . $this->SiteId . '&jobfailed=1" "${CLIENT_BASE_DIRECTORY}/scriptfailed.txt")' . "\n"; $ctest_script .= ' return()' . "\n"; $ctest_script .= 'ENDMACRO(JOB_FAILED)' . "\n\n"; if (strlen(trim($this->GetClientScript())) > 0) { $ctest_script .= $this->GetClientScript(); } elseif (strlen($Project->CTestTemplateScript) > 0) { $ctest_script .= $Project->CTestTemplateScript; } else { $ctest_script .= $Project->getDefaultJobTemplateScript(); } return $ctest_script; }
foreach ($jobschedule->BuildConfigurations as $key => $value) { $xml .= '<buildconfiguration>'; $xml .= add_XML_value("name", $value); $xml .= add_XML_value("id", $key); if (isset($scheduleid) && $key == $ClientJobSchedule->GetBuildConfiguration()) { $xml .= add_XML_value("selected", "1"); } $xml .= '</buildconfiguration>'; } // OS versions $clientOS = new ClientOS(); $osids = $clientOS->getAll(); foreach ($osids as $osid) { $xml .= '<os>'; $clientOS->Id = $osid; $xml .= add_XML_value("name", $clientOS->GetName() . "-" . $clientOS->GetVersion() . "-" . $clientOS->GetBits() . "bits"); $xml .= add_XML_value("id", $osid); if (isset($systems) && array_search($osid, $systems) !== false) { $xml .= add_XML_value("selected", "1"); } $xml .= '</os>'; } // Compiler versions $Compiler = new ClientCompiler(); $compilerids = $Compiler->getAll(); foreach ($compilerids as $compilerid) { $xml .= '<compiler>'; $Compiler->Id = $compilerid; $xml .= add_XML_value("name", $Compiler->GetName() . "-" . $Compiler->GetVersion()); $xml .= add_XML_value("id", $compilerid); if (isset($compilers) && array_search($compilerid, $compilers) !== false) {