Index: zorg/buildbot/builders/ClangBuilder.py =================================================================== --- zorg/buildbot/builders/ClangBuilder.py +++ zorg/buildbot/builders/ClangBuilder.py @@ -609,6 +609,11 @@ stage2_build = 'stage2' stage2_install = 'stage2.install' + # The installation step can be skipped if we aren't doing a multi-stage + # build, an upload, or an LNT test. + should_install_stage1 = (useTwoStage or runTestSuite or + stage1_upload_directory) + # Set up VS environment, if appropriate. if vs: f.addStep(SetProperty( @@ -617,17 +622,35 @@ assert not env, "Can't have custom builder env vars with VS" env = Property('slave_env') + # Allow users to force clean builds from the builder page by setting the + # "clean" property. + clean_build_requested = lambda step: step.build.getProperty("clean") or clean + ############# CLEANING - if clean: - f.addStep(ShellCommand(name='clean stage 1', - command=['rm','-rf',stage1_build], + f.addStep(ShellCommand(name='clean stage 1', + command=['rm','-rf',stage1_build], + warnOnFailure=True, + description='cleaning stage 1', + descriptionDone='clean', + workdir='.', + doStepIf=clean_build_requested)) + + if should_install_stage1: + # Clean the installation directory as well to remove stale build + # artifacts that no longer exist, such as old clang resource + # directories. + f.addStep(ShellCommand(name='clean stage 1 install', + command=['rm','-rf',stage1_install], warnOnFailure=True, description='cleaning stage 1', descriptionDone='clean', workdir='.', - env=env)) - else: + doStepIf=clean_build_requested)) + + if not clean: + # On builders that are normally incremental, test if build.ninja already + # exists to see if we can avoid an extra cmake run. f.addStep(SetProperty(name="check ninja files 1", workdir=stage1_build, command=check_build_cmd, @@ -666,7 +689,7 @@ workdir=stage1_build, env=env)) - if useTwoStage or runTestSuite or stage1_upload_directory: + if should_install_stage1: f.addStep(ShellCommand(name='install stage 1', command=ninja_install_cmd, description='ninja install', @@ -689,17 +712,24 @@ ############# STAGE 2 if useTwoStage: - # We always cleanly build the stage 2. If the compiler has been - # changed on the stage 1, we cannot trust any of the intermediate file - # from the old compiler. And if the stage 1 compiler is the same, we - # should not build in the first place. + # We always cleanly build the stage 2. If the compiler has been changed + # on the stage 1, we cannot trust any of the intermediate files from the + # old compiler. And if the stage 1 compiler is the same, we should not + # build in the first place. f.addStep(ShellCommand(name='clean stage 2', command=['rm','-rf',stage2_build], warnOnFailure=True, description='cleaning stage 2', descriptionDone='clean', - workdir='.', - env=env)) + workdir='.')) + + f.addStep(ShellCommand(name='clean stage 2 install', + command=['rm','-rf',stage2_install], + warnOnFailure=True, + description='cleaning stage 2', + descriptionDone='clean', + workdir='.')) + # Set the compiler using the CC and CXX environment variables to work around # backslash string escaping bugs somewhere between buildbot and cmake. The @@ -719,7 +749,6 @@ haltOnFailure=True, description='cmake stage 2', workdir=stage2_build, - doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK", env=env)) f.addStep(WarningCountingShellCommand(name='build stage 2',