Index: zorg/buildbot/builders/SanitizerBuilderWindows.py =================================================================== --- zorg/buildbot/builders/SanitizerBuilderWindows.py +++ zorg/buildbot/builders/SanitizerBuilderWindows.py @@ -7,6 +7,7 @@ from buildbot.steps.slave import RemoveDirectory from buildbot.steps.source import SVN from buildbot.process.properties import Property +from buildbot.process.properties import Interpolate from zorg.buildbot.builders.Util import getVisualStudioEnvironment from zorg.buildbot.builders.Util import extractSlaveEnvironment from zorg.buildbot.commands.NinjaCommand import NinjaCommand @@ -64,6 +65,7 @@ # Global configurations build_dir='build' + build_fuzzer_dir='build-fuzzer' ############# CLEANING cleanBuildRequested = lambda step: step.build.getProperty("clean") or clean @@ -112,4 +114,69 @@ workdir=build_dir, env=Property('slave_env'))) + # Clean fuzzer build dir. + f.addStep(RemoveDirectory(name='clean '+build_fuzzer_dir, + dir=build_fuzzer_dir, + haltOnFailure=False, + flunkOnFailure=False, + doStepIf=cleanBuildRequested + )) + + # Get absolute path to build dir. + f.addStep(SetProperty(name="get_builddir", + command=["pwd"], + property="builddir", + description="set build dir", + workdir=build_dir)) + + # Get clang version. + lib_clang_dir = "%(prop:builddir)s\\" + config + "\\lib\\clang" + f.addStep(SetProperty(name="get clang version", + command=["dir", "/b", Interpolate(lib_clang_dir)], + property="clang_version", + description="get clang version", + workdir=build_dir)) + + # Get compiler-rt's libraries dir. + dll_path = lib_clang_dir + "\\%(prop:clang_version)s\\lib\\windows" + # Get binary dir. + bin_path = "%(prop:builddir)s\\" + config + "\\bin" + # Get absolute path to clang-cl. + clang_cl = bin_path + "\\clang-cl" + + # Update slave_env to add fresh clang, tools and compiler-rt dlls to path. + update_path_cmd = "set Path=\""+bin_path+";"+dll_path+";%Path%\" && set" + f.addStep(SetProperty(command=Interpolate(update_path_cmd), + extract_fn=extractSlaveEnvironment, + env=Property('slave_env'))) + + f.addStep(ShellCommand(name='cmake', + command=[cmake, "-G", "Ninja", "../llvm", + "-DCMAKE_BUILD_TYPE="+config, + "-DLLVM_ENABLE_ASSERTIONS=ON", + Interpolate("-DCMAKE_C_COMPILER="+clang_cl), + Interpolate("-DCMAKE_CXX_COMPILER="+clang_cl), + "-DLLVM_USE_SANITIZER=Address", + "-DLLVM_USE_SANITIZE_COVERAGE=YES"] + + extra_cmake_args, + haltOnFailure=True, + workdir=build_fuzzer_dir, + env=Property('slave_env'))) + + # Build libFuzzer. + f.addStep(NinjaCommand(name='build LLVMFuzzer', + targets=['LLVMFuzzer'], + haltOnFailure=True, + description='ninja LLVMFuzzer', + workdir=build_dir, + env=Property('slave_env'))) + + # Run libFuzzer's tests. + f.addStep(NinjaCommand(name='run fuzzer tests', + targets=['check-fuzzer'], + haltOnFailure=True, + description='ninja check-fuzzer', + workdir=build_fuzzer_dir, + env=Property('slave_env'))) + return f