diff --git a/buildbot/osuosl/master/config/builders.py b/buildbot/osuosl/master/config/builders.py index 23fc7585d..3ec91f1fc 100644 --- a/buildbot/osuosl/master/config/builders.py +++ b/buildbot/osuosl/master/config/builders.py @@ -19,6 +19,7 @@ from zorg.buildbot.builders import TestSuiteBuilder from zorg.buildbot.builders import BOLTBuilder from zorg.buildbot.builders import DebugifyBuilder +from zorg.buildbot.builders import ScriptedBuilder from zorg.buildbot.builders import HtmlDocsBuilder from zorg.buildbot.builders import DoxygenDocsBuilder @@ -1310,28 +1311,9 @@ def collapseRequestsDoxygen(master, builder, req1, req2): 'tags' : ["polly"], 'workernames' : ["polly-x86_64-fdcserver", "minipc-1050ti-linux"], 'builddir': "polly-x86_64-linux-test-suite", - 'factory' : PollyBuilder.getPollyBuildFactory( - clean=False, - install=False, - make='ninja', - extraCmakeArgs=[ - "-G", "Ninja", - "-DCMAKE_C_COMPILER_LAUNCHER=ccache", - "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", - "-DLLVM_ENABLE_ASSERTIONS=True", - "-DLLVM_TARGETS_TO_BUILD='X86;NVPTX'", - "-DCLANG_ENABLE_ARCMT=OFF", - "-DCLANG_ENABLE_STATIC_ANALYZER=OFF", - "-DCLANG_ENABLE_OBJC_REWRITER=OFF" - ], - testsuite=True, - extraTestsuiteCmakeArgs=[ - "-G", "Ninja", - "-DTEST_SUITE_COLLECT_COMPILE_TIME=OFF", - "-DTEST_SUITE_COLLECT_STATS=OFF", - "-DTEST_SUITE_COLLECT_CODE_SIZE=OFF", - util.Interpolate("-DTEST_SUITE_EXTERNALS_DIR=%(prop:builddir)s/../../test-suite-externals"), - ] + 'factory' : ScriptedBuilder.getScriptedBuildFactory( + "polly/ci/polly-x86_64-linux-test-suite.py", + depends_on_projects=["llvm", "clang", "polly"], )}, # AOSP builders. diff --git a/zorg/buildbot/builders/ScriptedBuilder.py b/zorg/buildbot/builders/ScriptedBuilder.py new file mode 100644 index 000000000..2b2193e19 --- /dev/null +++ b/zorg/buildbot/builders/ScriptedBuilder.py @@ -0,0 +1,79 @@ +import os + +from buildbot.plugins import steps, util + +from zorg.buildbot.commands.AnnotatedCommand import AnnotatedCommand +from zorg.buildbot.process.factory import LLVMBuildFactory + + +def getScriptedBuildFactory( + scriptpath, + *scriptargs, + depends_on_projects, + env=None, + timeout=1200, + script_interpreter="python", + warnOnWarnings=False, + **kwargs, +): + assert scriptpath, "Must specify a script the worker is going to execute" + assert ( + depends_on_projects + ), "Must specify a set of projects; any change one of those projects will trigger a worker run" + + llvm_srcdir = "llvm.src" + + # If true, clean everything, including source dirs + def cleanBuildRequested(step): + return step.build.getProperty("clean") + + f = LLVMBuildFactory( + depends_on_projects=depends_on_projects, llvm_srcdir=llvm_srcdir + ) + + # When cleaning, delete the source directory; everything should be deleted + # by the build script itself. + f.addStep( + steps.RemoveDirectory( + name="clean-srcdir", + dir=f.monorepo_dir, + warnOnFailure=True, + doStepIf=cleanBuildRequested, + ) + ) + + # Checkout the llvm-project repository + f.addGetSourcecodeSteps(**kwargs) + + # Prepare running the build script + command = [ + script_interpreter, + os.path.join( + "..", f.monorepo_dir, scriptpath + ), # Location of the build script is relative to the llvm-project checkout + f"--workdir=.", # AnnotatedCommand executes the script with build/ as cwd + ] + + # Add any user-defined command line switches + command += [util.Interpolate(arg) for arg in scriptargs] + + merged_env = { + "TERM": "dumb" # Be cautious and disable color output from all tools. + } + for k, v in env or {}: + # Overwrite pre-set items with the given ones, so user can set anything. + merged_env[k] = util.Interpolate(v) + + f.addStep( + AnnotatedCommand( + name="annotate", + description="Run build script", + timeout=timeout, + haltOnFailure=True, + warnOnWarnings=warnOnWarnings, + command=command, + env=merged_env, + ) + ) + + return f diff --git a/zorg/buildbot/commands/AnnotatedCommand.py b/zorg/buildbot/commands/AnnotatedCommand.py index d21f16746..5d91c2fd6 100644 --- a/zorg/buildbot/commands/AnnotatedCommand.py +++ b/zorg/buildbot/commands/AnnotatedCommand.py @@ -324,6 +324,8 @@ def __init__(self, **kwargs): 'BUILDBOT_BRANCH': util.Interpolate('%(prop:branch:-None)s'), 'BUILDBOT_BUILDERNAME': util.Interpolate('%(prop:buildername:-None)s'), 'BUILDBOT_BUILDNUMBER': util.Interpolate('%(prop:buildnumber:-None)s'), + 'BUILDBOT_CLEAN': util.Interpolate('%(prop:clean:-)s'), + 'BUILDBOT_CLEAN_OBJ': util.Interpolate('%(prop:clean_obj:-)s'), 'BUILDBOT_CLOBBER': util.Interpolate('%(prop:clobber:+1)s'), 'BUILDBOT_GOT_REVISION': util.Interpolate('%(prop:got_revision:-None)s'), 'BUILDBOT_REVISION': util.Interpolate('%(prop:revision:-None)s'),