Exemple #1
0
def getCmakeWithNinjaMultistageBuildFactory(depends_on_projects=None,
                                            llvm_srcdir=None,
                                            obj_dir=None,
                                            checks=None,
                                            install_dir=None,
                                            clean=False,
                                            extra_configure_args=None,
                                            env=None,
                                            stages=2,
                                            stage_names=None,
                                            **kwargs):

    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
        'TERM': 'dumb'  # Be cautious and disable color output from all tools.
    }
    if env is not None:
        # Overwrite pre-set items with the given ones, so user can set anything.
        merged_env.update(env)

    # Make a local copy of the configure args, as we are going to modify that.
    if extra_configure_args:
        cmake_args = extra_configure_args[:]
    else:
        cmake_args = list()

    assert stages > 1, "It should be at least 2 stages in a multistage build."
    if stage_names is None:
        stage_names = list()
        for i in range(1, stages + 1):
            stage_names.append("stage%s" % i)
    else:
        assert len(
            stage_names
        ) == stages, "Please specify names for none or all of the requested stages."

    if obj_dir is None:
        obj_dir = "build"
    if install_dir is None:
        install_dir = "install"

    if checks is None:
        checks = ['check-all']

    stage_objdirs = list()
    stage_installdirs = list()
    for s in stage_names:
        stage_objdirs.append("%s/%s" % (obj_dir, s))
        stage_installdirs.append("%s/%s" % (install_dir, s))

    f = getLLVMBuildFactoryAndPrepareForSourcecodeSteps(
        depends_on_projects=depends_on_projects,
        llvm_srcdir=llvm_srcdir,
        obj_dir=obj_dir,
        install_dir=install_dir,
        env=env,
        stage_objdirs=stage_objdirs,
        stage_installdirs=stage_installdirs,
        stage_names=stage_names,
        **kwargs)  # Pass through all the extra arguments.

    # Get the source code.
    # We have consumed kwargs specific to this factory, so
    # it is safe to pass all the remaining kwargs down.
    f.addGetSourcecodeSteps(**kwargs)

    # Set proper defaults.
    CmakeCommand.applyDefaultOptions(cmake_args, [
        ('-DCMAKE_BUILD_TYPE=', 'Release'),
        ('-DLLVM_BUILD_TESTS=', 'ON'),
        ('-DLLVM_ENABLE_ASSERTIONS=', 'OFF'),
        ('-DLLVM_OPTIMIZED_TABLEGEN=', 'ON'),
    ])

    if 'clang' in depends_on_projects:
        CmakeCommand.applyDefaultOptions(cmake_args, [
            ('-DCLANG_BUILD_EXAMPLES=', 'OFF'),
        ])

    # Some options are required for this build no matter what.
    CmakeCommand.applyRequiredOptions(cmake_args, [
        ('-G', 'Ninja'),
    ])

    # The stage 1 is special, though. We use the system compiler and
    # do incremental build, unless a clean one has been requested.
    cmake_args_stage1 = cmake_args[:]
    CmakeCommand.applyDefaultOptions(
        cmake_args_stage1,
        [
            # Do not expect warning free build by the system toolchain.
            ('-DLLVM_ENABLE_WERROR=', 'OFF'),
        ])

    cleanBuildRequested = lambda step: step.build.getProperty(
        "clean", default=step.build.getProperty("clean_obj")) or clean

    addCmakeSteps(f,
                  cleanBuildRequested=cleanBuildRequested,
                  obj_dir=stage_objdirs[0],
                  install_dir=stage_installdirs[0],
                  extra_configure_args=cmake_args_stage1,
                  env=env,
                  stage_name=stage_names[0],
                  **kwargs)

    addNinjaSteps(f,
                  obj_dir=stage_objdirs[0],
                  checks=checks,
                  install_dir=stage_installdirs[0],
                  env=env,
                  stage_name=stage_names[0],
                  **kwargs)

    # Build the rest stage by stage, using just built compiler to compile
    # the next stage.
    CmakeCommand.applyDefaultOptions(
        cmake_args,
        [
            # We should be warnings free when use just built compiler.
            ('-DLLVM_ENABLE_WERROR=', 'ON'),
        ])
    # If we build LLD, we would link with LLD.
    # Otherwise we link with a system linker.
    if 'lld' in f.depends_on_projects:
        CmakeCommand.applyDefaultOptions(cmake_args, [
            ('-DLLVM_ENABLE_LLD=', 'ON'),
        ])

    for stage_idx in range(1, stages):

        # Directories to use in this stage.
        obj_dir = f.stage_objdirs[stage_idx]
        src_dir = LLVMBuildFactory.pathRelativeToBuild(f.llvm_srcdir, obj_dir)
        install_dir = LLVMBuildFactory.pathRelativeToBuild(
            f.stage_installdirs[stage_idx], obj_dir)
        staged_install = f.stage_installdirs[stage_idx - 1]

        # Configure the compiler to use in this stage.
        cmake_args_stageN = cmake_args[:]
        CmakeCommand.applyRequiredOptions(cmake_args_stageN, [
            ('-DCMAKE_INSTALL_PREFIX=', install_dir),
        ])
        cmake_args_stageN.append(
            WithProperties("-DCMAKE_CXX_COMPILER=%(workdir)s/" +
                           staged_install + "/bin/clang++"))
        cmake_args_stageN.append(
            WithProperties("-DCMAKE_C_COMPILER=%(workdir)s/" + staged_install +
                           "/bin/clang"))

        addCmakeSteps(
            f,
            True,  # We always do a clean build for the staged builds.
            obj_dir=stage_objdirs[stage_idx],
            install_dir=stage_installdirs[stage_idx],
            extra_configure_args=cmake_args_stageN,
            env=env,
            stage_name=stage_names[stage_idx],
            **kwargs)

        addNinjaSteps(f,
                      obj_dir=stage_objdirs[stage_idx],
                      checks=checks,
                      install_dir=stage_installdirs[stage_idx],
                      env=env,
                      stage_name=stage_names[stage_idx],
                      **kwargs)

    return f
Exemple #2
0
 def testLambdaCallable(self):
     self.assertRaises(ValueError,
                       lambda: WithProperties('%(foo)s', foo='bar'))
Exemple #3
0
def getLLVMBuildFactory(
    triple=None,  # Triple to build, host, and target.
    clean=True,  # "clean-llvm" step is requested if true.
    test=True,  # "test-llvm" step is requested if true.
    expensive_checks=False,
    examples=False,  # "compile.examples" step is requested if true.
    valgrind=False,  # Valgrind is used on "test-llvm" step if true.
    valgrindLeakCheck=False,  # Valgrind leak check is requested if true.
    valgrindSuppressions=None,  # Valgrind suppression file.
    jobs='%(jobs)s',  # Number of concurrent jobs.
    timeout=20,  # Timeout if no activity seen (minutes).
    make='make',  # Make command.
    enable_shared=False,  # Enable shared (--enable-shared configure parameters added) if true.
    enable_targets=None,  # List of enabled targets (--enable-targets configure param).
    defaultBranch='trunk',  # Branch to build.
    llvmgccdir=None,  # Path to llvm-gcc.
    config_name='Debug+Asserts',  # Configuration name.
    env={},  # Environmental variables for all steps.
    extra_configure_args=[]):  # Extra args for the conigure step.
    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
        'TERM': 'dumb'  # Make sure Clang doesn't use color escape sequences.
    }
    if env is not None:
        merged_env.update(
            env
        )  # Overwrite pre-set items with the given ones, so user can set anything.

    llvm_srcdir = "llvm.src"
    llvm_objdir = "llvm.obj"

    f = buildbot.process.factory.BuildFactory()

    # Determine the build directory.
    f.addStep(
        buildbot.steps.shell.SetProperty(name="get_builddir",
                                         command=["pwd"],
                                         property="builddir",
                                         description="set build dir",
                                         workdir=".",
                                         env=merged_env))

    # Checkout sources.
    f.addStep(
        SVN(name='svn-llvm',
            mode='update',
            baseURL='http://llvm.org/svn/llvm-project/llvm/',
            defaultBranch=defaultBranch,
            workdir=llvm_srcdir))

    # Force without llvm-gcc so we don't run afoul of Frontend test failures.
    configure_args = [
        WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir)
    ]
    if llvmgccdir:
        configure_args += ['--with-llvmgccdir=%s' % llvmgccdir]
    else:
        configure_args += ["--without-llvmgcc", "--without-llvmgxx"]
    configure_args += getConfigArgs(config_name)
    if enable_targets is not None:
        configure_args.append('--enable-targets=%s' % enable_targets)
    if triple:
        configure_args += [
            '--build=%s' % triple,
            '--host=%s' % triple,
            '--target=%s' % triple
        ]
    if enable_shared:
        configure_args.append('--enable-shared')
    configure_args.extend(extra_configure_args)
    f.addStep(
        Configure(command=configure_args,
                  description=['configuring', config_name],
                  descriptionDone=['configure', config_name],
                  workdir=llvm_objdir,
                  env=merged_env))
    if clean:
        f.addStep(
            WarningCountingShellCommand(name="clean-llvm",
                                        command=[make, 'clean'],
                                        haltOnFailure=True,
                                        description="cleaning llvm",
                                        descriptionDone="clean llvm",
                                        workdir=llvm_objdir,
                                        env=merged_env))
    f.addStep(
        WarningCountingShellCommand(
            name="compile",
            command=['nice', '-n', '10', make,
                     WithProperties("-j%s" % jobs)],
            haltOnFailure=True,
            description="compiling llvm",
            descriptionDone="compile llvm",
            workdir=llvm_objdir,
            env=merged_env,
            timeout=timeout * 60))
    if examples:
        f.addStep(
            WarningCountingShellCommand(
                name="compile.examples",
                command=[
                    'nice', '-n', '10', make,
                    WithProperties("-j%s" % jobs), 'BUILD_EXAMPLES=1'
                ],
                haltOnFailure=True,
                description=["compiling", "llvm", "examples"],
                descriptionDone=["compile", "llvm", "examples"],
                workdir=llvm_objdir,
                env=merged_env,
                timeout=timeout * 60))
    if test:
        litTestArgs = '-v -j %s' % jobs
        if valgrind:
            litTestArgs += ' --vg '
            if valgrindLeakCheck:
                litTestArgs += ' --vg-leak'
            if valgrindSuppressions is not None:
                litTestArgs += ' --vg-arg --suppressions=%%(builddir)s/llvm/%s' % valgrindSuppressions
        f.addStep(
            LitTestCommand(name='test-llvm',
                           command=[
                               make, "check-lit", "VERBOSE=1",
                               WithProperties("LIT_ARGS=%s" % litTestArgs)
                           ],
                           description=["testing", "llvm"],
                           descriptionDone=["test", "llvm"],
                           workdir=llvm_objdir,
                           env=merged_env))
    return f
Exemple #4
0
 def testDict(self):
     # test dict-style substitution with WithProperties
     self.props.setProperty("other", "foo", "test")
     command = WithProperties("build-%(other)s.tar.gz")
     self.failUnlessEqual(self.props.render(command), "build-foo.tar.gz")
Exemple #5
0
 def testLambdaSubst(self):
     command = WithProperties('%(foo)s', foo=lambda _: 'bar')
     self.failUnlessEqual(self.props.render(command), 'bar')
Exemple #6
0
 def testLambdaOverride(self):
     self.props.setProperty('x', 10, 'test')
     command = WithProperties('%(x)s', x=lambda _: 20)
     d = self.build.render(command)
     d.addCallback(self.failUnlessEqual, '20')
     return d
Exemple #7
0
def _getClangCMakeBuildFactory(
            clean=True,
            test=True,
            cmake='cmake',
            jobs=None,

            # VS tools environment variable if using MSVC. For example,
            # %VS120COMNTOOLS% selects the 2013 toolchain.
            vs=None,
            vs_target_arch='x86',

            # Multi-stage compilation
            useTwoStage=False,
            testStage1=True,
            stage1_config='Release',
            stage2_config='Release',

            # Test-suite
            runTestSuite=False,
            nt_flags=[],
            testsuite_flags=[],
            submitURL=None,
            testerName=None,

            # Environmental variables for all steps.
            env={},
            extra_cmake_args=[],

            # Extra repositories
            checkout_clang_tools_extra=True,
            checkout_compiler_rt=True,
            checkout_lld=True,
            checkout_libcxx=False,
            checkout_test_suite=False,

            # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
            stage1_upload_directory=None,

            # Use a lower compression level to generate the build-cache package faster
            # default is 6 according to documentation
            xz_compression_factor=6,
            use_pixz_compression=False,

            # Triggers
            trigger_after_stage1=[]):

    ############# PREPARING
    f = buildbot.process.factory.BuildFactory()

    clean_build_requested = lambda step: clean or step.build.getProperty("clean")

    addSVNUpdateSteps(f,
                      checkout_clang_tools_extra=checkout_clang_tools_extra,
                      checkout_compiler_rt=checkout_compiler_rt,
                      checkout_lld=checkout_lld,
                      checkout_test_suite=runTestSuite or checkout_test_suite,
                      checkout_libcxx=checkout_libcxx)

    # If jobs not defined, Ninja will choose a suitable value
    jobs_cmd = []
    lit_args = "'-v"
    if jobs is not None:
        jobs_cmd = ["-j"+str(jobs)]
        lit_args += " -j"+str(jobs)+"'"
    else:
        lit_args += "'"
    ninja_cmd = ['ninja'] + jobs_cmd
    ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
    ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd

    # Global configurations
    stage1_build = 'stage1'
    stage1_install = 'stage1.install'
    stage2_build = 'stage2'
    stage2_install = 'stage2.install'

    # Set up VS environment, if appropriate.
    if vs:
        f.addStep(SetProperty(
            command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
            extract_fn=builders_util.extractSlaveEnvironment))
        assert not env, "Can't have custom builder env vars with VS"
        env = Property('slave_env')


    ############# CLEANING
    f.addStep(ShellCommand(name='clean stage 1',
                           command=['rm','-rf',stage1_build],
                           warnOnFailure=True,
                           haltOnFailure=False,
                           flunkOnFailure=False,
                           description='cleaning stage 1',
                           descriptionDone='clean',
                           workdir='.',
                           doStepIf=clean_build_requested))


    ############# STAGE 1
    f.addStep(ShellCommand(name='cmake stage 1',
                           command=[cmake, "-G", "Ninja", "../llvm",
                                    "-DCMAKE_BUILD_TYPE="+stage1_config,
                                    "-DLLVM_ENABLE_ASSERTIONS=True",
                                    "-DLLVM_LIT_ARGS="+lit_args,
                                    "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
                                    + extra_cmake_args,
                           haltOnFailure=True,
                           description='cmake stage 1',
                           workdir=stage1_build,
                           doStepIf=FileDoesNotExist("build.ninja"),
                           env=env))

    f.addStep(WarningCountingShellCommand(name='build stage 1',
                                          command=ninja_cmd,
                                          haltOnFailure=True,
                                          description='ninja all',
                                          workdir=stage1_build,
                                          env=env))

    if test and testStage1:
        haltOnStage1Check = not useTwoStage and not runTestSuite
        f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
                                   command=ninja_check_cmd,
                                   haltOnFailure=haltOnStage1Check,
                                   description=["checking stage 1"],
                                   descriptionDone=["stage 1 checked"],
                                   workdir=stage1_build,
                                   env=env))

    if useTwoStage or runTestSuite or stage1_upload_directory:
        f.addStep(ShellCommand(name='clean stage 1 install',
                               command=['rm','-rf',stage1_install],
                               warnOnFailure=True,
                               haltOnFailure=False,
                               flunkOnFailure=False,
                               description='cleaning stage 1 install',
                               descriptionDone='clean',
                               workdir='.'))
        f.addStep(ShellCommand(name='install stage 1',
                               command=ninja_install_cmd,
                               description='ninja install',
                               workdir=stage1_build,
                               env=env))

    if stage1_upload_directory:
        addGCSUploadSteps(f, 'stage 1', stage1_install, stage1_upload_directory,
                          env, gcs_url_property='stage1_package_gcs_url',
                          use_pixz_compression=use_pixz_compression,
                          xz_compression_factor=xz_compression_factor)

    # Compute the cmake define flag to set the C and C++ compiler to clang. Use
    # clang-cl if we used MSVC for stage1.
    if not vs:
        cc = 'clang'
        cxx = 'clang++'
    else:
        cc = 'clang-cl.exe'
        cxx = 'clang-cl.exe'


    ############# 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.
        f.addStep(ShellCommand(name='clean stage 2',
                               command=['rm','-rf',stage2_build],
                               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
        # env.exe helper is required to run the tests, so hopefully it's already on
        # PATH.
        cmake_cmd2 = ['env',
                      WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
                      WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
                      cmake, "-G", "Ninja", "../llvm",
                      "-DCMAKE_BUILD_TYPE="+stage2_config,
                      "-DLLVM_ENABLE_ASSERTIONS=True",
                      "-DLLVM_LIT_ARGS="+lit_args,
                      "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args

        f.addStep(ShellCommand(name='cmake stage 2',
                               command=cmake_cmd2,
                               haltOnFailure=True,
                               description='cmake stage 2',
                               workdir=stage2_build,
                               env=env))

        f.addStep(WarningCountingShellCommand(name='build stage 2',
                                              command=ninja_cmd,
                                              haltOnFailure=True,
                                              description='ninja all',
                                              workdir=stage2_build,
                                              env=env))

        if test:
            f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
                                       command=ninja_check_cmd,
                                       haltOnFailure=not runTestSuite,
                                       description=["checking stage 2"],
                                       descriptionDone=["stage 2 checked"],
                                       workdir=stage2_build,
                                       env=env))

    ############# TEST SUITE
    ## Test-Suite (stage 2 if built, stage 1 otherwise)
    if runTestSuite:
        compiler_path = stage1_install
        if useTwoStage:
            compiler_path=stage2_install
            f.addStep(ShellCommand(name='clean stage 2 install',
                                   command=['rm','-rf',stage2_install],
                                   warnOnFailure=True,
                                   description='cleaning stage 2 install',
                                   descriptionDone='clean',
                                   workdir='.'))
            f.addStep(ShellCommand(name='install stage 2',
                                   command=ninja_install_cmd,
                                   description='ninja install 2',
                                   workdir=stage2_build,
                                   env=env))

        # Get generated python, lnt
        python = WithProperties('%(workdir)s/test/sandbox/bin/python')
        lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
        lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')

        # Paths
        sandbox = WithProperties('%(workdir)s/test/sandbox')
        test_suite_dir = WithProperties('%(workdir)s/test/test-suite')

        # Get latest built Clang (stage1 or stage2)
        cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
        cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)

        # LNT Command line (don't pass -jN. Users need to pass both --threads
        # and --build-threads in nt_flags/test_suite_flags to get the same effect)
        use_runtest_testsuite = len(nt_flags) == 0
        if not use_runtest_testsuite:
            test_suite_cmd = [python, lnt, 'runtest', 'nt',
                              '--no-timestamp',
                              '--sandbox', sandbox,
                              '--test-suite', test_suite_dir,
                              '--cc', cc,
                              '--cxx', cxx]
            # Append any option provided by the user
            test_suite_cmd.extend(nt_flags)
        else:
            lit = WithProperties('%(workdir)s/'+stage1_build+'/bin/llvm-lit')
            test_suite_cmd = [python, lnt, 'runtest', 'test-suite',
                              '--no-timestamp',
                              '--sandbox', sandbox,
                              '--test-suite', test_suite_dir,
                              '--cc', cc,
                              '--cxx', cxx,
                              '--use-lit', lit]
            # Append any option provided by the user
            test_suite_cmd.extend(testsuite_flags)

        # Only submit if a URL has been specified
        if submitURL is not None:
            if not isinstance(submitURL, list):
                submitURL = [submitURL]
            for url in submitURL:
                test_suite_cmd.extend(['--submit', url])
            # lnt runtest test-suite doesn't understand --no-machdep-info:
            if testerName and not use_runtest_testsuite:
                test_suite_cmd.extend(['--no-machdep-info', testerName])
        # CC and CXX are needed as env for build-tools
        test_suite_env = copy.deepcopy(env)
        test_suite_env['CC'] = cc
        test_suite_env['CXX'] = cxx

        # Steps to prepare, build and run LNT
        f.addStep(ShellCommand(name='clean sandbox',
                               command=['rm', '-rf', 'sandbox'],
                               haltOnFailure=True,
                               description='removing sandbox directory',
                               workdir='test',
                               env=env))
        f.addStep(ShellCommand(name='recreate sandbox',
                               command=['virtualenv', 'sandbox'],
                               haltOnFailure=True,
                               description='recreating sandbox',
                               workdir='test',
                               env=env))
        f.addStep(ShellCommand(name='setup lit',
                               command=[python, lnt_setup, 'develop'],
                               haltOnFailure=True,
                               description='setting up LNT in sandbox',
                               workdir='test/sandbox',
                               env=env))
        f.addStep(commands.LitTestCommand.LitTestCommand(
                               name='test-suite',
                               command=test_suite_cmd,
                               haltOnFailure=True,
                               description=['running the test suite'],
                               workdir='test/sandbox',
                               logfiles={'configure.log'   : 'build/configure.log',
                                         'build-tools.log' : 'build/build-tools.log',
                                         'test.log'        : 'build/test.log',
                                         'report.json'     : 'build/report.json'},
                               env=test_suite_env))

    return f
Exemple #8
0
def make_dolphin_osx_build(mode="normal"):
    f = BuildFactory()

    f.addStep(
        GitNoBranch(repourl="https://github.com/dolphin-emu/dolphin.git",
                    progress=True,
                    mode="incremental"))

    f.addStep(
        ShellCommand(command=["mkdir", "-p", "build"],
                     logEnviron=False,
                     description="mkbuilddir",
                     descriptionDone="mkbuilddir"))

    f.addStep(
        ShellCommand(command=[
            "cmake", "-GNinja", "-DDISTRIBUTOR=dolphin-emu.org", ".."
        ],
                     workdir="build/build",
                     description="configuring",
                     descriptionDone="configure",
                     haltOnFailure=True))

    f.addStep(
        Compile(command=["ninja"],
                workdir="build/build",
                description="building",
                descriptionDone="build",
                haltOnFailure=True))

    f.addStep(
        Test(command=["ninja", "unittests"],
             workdir="build/build",
             description="testing",
             descriptionDone="test",
             haltOnFailure=True))

    f.addStep(
        ShellCommand(command="/build/codesign.sh --deep Binaries/Dolphin.app",
                     workdir="build/build",
                     description="signing",
                     descriptionDone="sign",
                     haltOnFailure=True))

    f.addStep(
        ShellCommand(command=[
            "hdiutil", "create", "dolphin.dmg", "-format", "UDBZ",
            "-srcfolder", "Binaries/dolphin.app", "-ov", "-volname",
            WithProperties("Dolphin %s-%s", "branchname", "shortrev")
        ],
                     workdir="build/build",
                     logEnviron=False,
                     description="packaging",
                     descriptionDone="package"))

    f.addStep(
        ShellCommand(command="/build/codesign.sh --deep dolphin.dmg",
                     workdir="build/build",
                     description="signing dmg",
                     descriptionDone="sign dmg",
                     haltOnFailure=True))

    if mode == "normal":
        master_filename = WithProperties(
            "/srv/http/dl/builds/dolphin-%s-%s.dmg", "branchname", "shortrev")
        url = WithProperties(
            "https://dl.dolphin-emu.org/builds/dolphin-%s-%s.dmg",
            "branchname", "shortrev")
    elif mode == "wip":
        master_filename = WithProperties(
            "/srv/http/dl/wips/%s-dolphin-%s-%s.dmg", "author", "branchname",
            "shortrev")
        url = WithProperties(
            "https://dl.dolphin-emu.org/wips/%s-dolphin-%s-%s.dmg", "author",
            "branchname", "shortrev")
    elif mode == "pr":
        master_filename = WithProperties(
            "/srv/http/dl/prs/%s-dolphin-latest.dmg", "branchname")
        url = WithProperties(
            "https://dl.dolphin-emu.org/prs/%s-dolphin-latest.dmg",
            "branchname")
    else:
        master_filename = url = ""

    if master_filename and url:
        f.addStep(
            FileUpload(workersrc="build/dolphin.dmg",
                       masterdest=master_filename,
                       url=url,
                       keepstamp=True,
                       mode=0o644))

    if mode == "normal":
        f.addStep(
            MasterShellCommand(command="/home/buildbot/bin/send_build.py",
                               env={
                                   "BRANCH":
                                   WithProperties("%s", "branchname"),
                                   "SHORTREV":
                                   WithProperties("%s", "shortrev"),
                                   "HASH":
                                   WithProperties("%s", "revision"),
                                   "AUTHOR":
                                   WithProperties("%s", "author"),
                                   "DESCRIPTION":
                                   WithProperties("%s", "description"),
                                   "TARGET_SYSTEM":
                                   "macOS",
                                   "USER_OS_MATCHER":
                                   "osx",
                                   "BUILD_URL":
                                   url,
                               },
                               description="notifying website",
                               descriptionDone="website notice"))

    return f
Exemple #9
0
def make_android_package(mode="normal"):
    f = BuildFactory()

    f.addStep(
        GitNoBranch(repourl="https://github.com/dolphin-emu/dolphin.git",
                    progress=True,
                    mode="incremental"))

    if mode == "normal":
        f.addStep(
            ShellCommand(command="./gradlew assembleRelease "
                         "-Pkeystore=$HOME/dolphin-release.keystore "
                         "-Pstorepass=$(cat ~/.keystore-password) "
                         "-Pkeyalias=mykey "
                         "-Pkeypass=$(cat ~/.keystore-password) ",
                         workdir="build/Source/Android",
                         description="Gradle",
                         descriptionDone="Gradle",
                         haltOnFailure=True))

        source_filename = "Source/Android/app/build/outputs/apk/release/app-release.apk"
        master_filename = WithProperties(
            "/srv/http/dl/builds/dolphin-%s-%s.apk", "branchname", "shortrev")
        url = WithProperties(
            "https://dl.dolphin-emu.org/builds/dolphin-%s-%s.apk",
            "branchname", "shortrev")

    else:
        f.addStep(
            ShellCommand(command="./gradlew assembleDebug",
                         workdir="build/Source/Android",
                         description="Gradle",
                         descriptionDone="Gradle",
                         haltOnFailure=True))

        source_filename = "Source/Android/app/build/outputs/apk/debug/app-debug.apk"
        master_filename = WithProperties(
            "/srv/http/dl/prs/%s-dolphin-latest.apk", "branchname")
        url = WithProperties(
            "https://dl.dolphin-emu.org/prs/%s-dolphin-latest.apk",
            "branchname")

    f.addStep(
        FileUpload(workersrc=source_filename,
                   masterdest=master_filename,
                   url=url,
                   keepstamp=True,
                   mode=0o644))

    if mode == "normal":
        f.addStep(
            MasterShellCommand(command="/home/buildbot/bin/send_build.py",
                               env={
                                   "BRANCH":
                                   WithProperties("%s", "branchname"),
                                   "SHORTREV":
                                   WithProperties("%s", "shortrev"),
                                   "HASH":
                                   WithProperties("%s", "revision"),
                                   "AUTHOR":
                                   WithProperties("%s", "author"),
                                   "DESCRIPTION":
                                   WithProperties("%s", "description"),
                                   "TARGET_SYSTEM":
                                   "Android",
                                   "USER_OS_MATCHER":
                                   "android",
                                   "BUILD_URL":
                                   url,
                               },
                               description="notifying website",
                               descriptionDone="website notice"))

    return f
Exemple #10
0
def make_dolphin_win_build(build_type, mode="normal"):
    f = BuildFactory()

    mode = mode.split(",")
    normal = "normal" in mode
    debug = "debug" in mode
    wip = "wip" in mode
    pr = "pr" in mode
    fifoci_golden = "fifoci_golden" in mode

    f.addStep(
        GitNoBranch(repourl="https://github.com/dolphin-emu/dolphin.git",
                    progress=True,
                    mode="incremental"))
    f.addStep(RemoveDirectory(dir="build/Binary"))

    branch = WithProperties("%s", "branchname")
    env = {"DOLPHIN_BRANCH": branch, "DOLPHIN_DISTRIBUTOR": "dolphin-emu.org"}
    if normal:
        env["DOLPHIN_DEFAULT_UPDATE_TRACK"] = "beta"
    f.addStep(
        Compile(command=[
            "msbuild.exe", "/v:m", "/p:Platform=x64",
            "/p:Configuration=%s" % build_type, "dolphin-emu.sln"
        ],
                env=env,
                workdir="build/Source",
                description="building",
                descriptionDone="build",
                haltOnFailure=True))
    f.addStep(
        Test(command=[
            "msbuild.exe", "/v:m", "/p:Platform=x64",
            "/p:Configuration=%s" % build_type, "/p:RunUnitTests=true",
            "dolphin-emu.sln"
        ],
             env=env,
             workdir="build/Source",
             description="testing",
             descriptionDone="test",
             haltOnFailure=True))

    dolphin_name = "DolphinD" if debug else "Dolphin"

    f.addStep(
        ShellCommand(command=[
            "C:\\buildbot\\signbin.bat",
            "Binary\\x64\\%s.exe" % dolphin_name
        ],
                     logEnviron=False,
                     description="signing binary",
                     descriptionDone="sign binary"))

    f.addStep(
        ShellCommand(
            command=["xcopy", "Binary\\x64", "Dolphin-x64", "/S", "/I", "/Y"],
            logEnviron=False,
            description="copying output",
            descriptionDone="output copy"))

    out_filename = WithProperties("Dolphin-%s-%s-x64.7z", "branchname",
                                  "shortrev")
    f.addStep(
        ShellCommand(command=["7z", "a", "-r", out_filename, "Dolphin-x64"],
                     logEnviron=False,
                     description="compressing",
                     descriptionDone="compression"))

    if debug:
        fn_arch = "dbg-x64"
    else:
        fn_arch = "x64"

    if "normal" in mode:
        master_filename = WithProperties(
            "/srv/http/dl/builds/dolphin-%%s-%%s-%s.7z" % fn_arch,
            "branchname", "shortrev")
        url = WithProperties(
            "https://dl.dolphin-emu.org/builds/dolphin-%%s-%%s-%s.7z" %
            fn_arch, "branchname", "shortrev")
    elif wip:
        master_filename = WithProperties(
            "/srv/http/dl/wips/%%s-dolphin-%%s-%%s-%s.7z" % fn_arch, "author",
            "branchname", "shortrev")
        url = WithProperties(
            "https://dl.dolphin-emu.org/wips/%%s-dolphin-%%s-%%s-%s.7z" %
            fn_arch, "author", "branchname", "shortrev")
    elif pr:
        master_filename = WithProperties(
            "/srv/http/dl/prs/%%s-dolphin-latest-%s.7z" % fn_arch,
            "branchname")
        url = WithProperties(
            "https://dl.dolphin-emu.org/prs/%%s-dolphin-latest-%s.7z" %
            fn_arch, "branchname")
    else:
        master_filename = url = ""

    f.addStep(SetProperty(property="build_url", value=url))

    if master_filename and url:
        f.addStep(
            FileUpload(workersrc=out_filename,
                       masterdest=master_filename,
                       url=url,
                       keepstamp=True,
                       mode=0o644))

    if fifoci_golden:
        if pr:
            f.addStep(
                Trigger(schedulerNames=["pr-fifoci-win"],
                        copy_properties=[
                            "pr_id", "headrev", "branchname", "shortrev",
                            "build_url"
                        ]))
        else:
            f.addStep(
                TriggerIfBranch(schedulerNames=["fifoci-win"],
                                branchList=["master"],
                                copy_properties=["shortrev", "build_url"]))

    if "normal" in mode and "debug" not in mode:
        f.addStep(
            MasterShellCommand(
                command=
                "/home/buildbot/venv/bin/python /home/buildbot/bin/send_build.py",
                env={
                    "BRANCH": WithProperties("%s", "branchname"),
                    "SHORTREV": WithProperties("%s", "shortrev"),
                    "HASH": WithProperties("%s", "revision"),
                    "AUTHOR": WithProperties("%s", "author"),
                    "DESCRIPTION": WithProperties("%s", "description"),
                    "TARGET_SYSTEM": "Windows x64",
                    "USER_OS_MATCHER": "win",
                    "BUILD_URL": url,
                },
                description="notifying website",
                descriptionDone="website notice"))

        f.addStep(
            MasterShellCommand(command=[
                "/home/buildbot/venv/bin/python",
                "/home/buildbot/bin/make_manifest.py", "--input",
                master_filename, "--version_hash",
                WithProperties("%s", "revision"), "--output-manifest-store",
                "/data/nas/update/manifest", "--output-content-store",
                "/data/nas/update/content", "--signing-key",
                "/home/buildbot/update.signing.key"
            ],
                               description="writing update manifest",
                               descriptionDone="update manifest write"))

    f.addStep(
        ShellCommand(command=["del", "/F", "/S", "/Q", out_filename],
                     logEnviron=False,
                     description="cleaning up files",
                     descriptionDone="cleanup files"))

    f.addStep(
        ShellCommand(command=["rmdir", "/S", "/Q", "Dolphin-x64"],
                     logEnviron=False,
                     description="cleaning up dirs",
                     descriptionDone="cleanup dirs"))

    return f
Exemple #11
0
def make_fifoci_win(type, mode="normal"):
    mode = mode.split(",")
    normal = "normal" in mode
    pr = "pr" in mode

    f = BuildFactory()
    f.addStep(
        GitNoBranch(repourl="https://github.com/dolphin-emu/dolphin.git",
                    progress=True,
                    mode="incremental"))
    f.addStep(
        ShellCommand(command="powershell C:/utils/bin/updfifoci.ps1",
                     description="updating FifoCI",
                     descriptionDone="FifoCI update"))
    f.addStep(
        RemoveDirectory("build/tmp", haltOnFailure=False,
                        flunkOnFailure=False))
    f.addStep(MakeDirectory("build/tmp"))
    f.addStep(
        ShellCommand(command=WithProperties(
            "powershell C:/utils/bin/wgetwrapper.ps1 %s build.7z",
            "build_url"),
                     description="downloading build",
                     descriptionDone="download",
                     workdir="build/tmp",
                     haltOnFailure=True))
    f.addStep(
        ShellCommand(command="7z x build.7z",
                     description="extracting build",
                     descriptionDone="extracting",
                     workdir="build/tmp",
                     haltOnFailure=True))

    url_base = "https://fifoci.dolphin-emu.org"
    args = [
        "--type",
        type,
        "--dolphin",
        "Dolphin-x64/Dolphin.exe",
        "--rev_base_hash",
        "%(revision)s",
        "--output",
        "result.zip",
        "--url_base",
        url_base,
        "--dff_dir",
        "C:/dff",
    ]
    if normal:
        args += [
            "--rev_hash",
            "%(revision)s",
            "--rev_name",
            "%(shortrev)s",
            "--rev_submitted",
            "true",
        ]
    elif pr:
        args += [
            "--rev_hash",
            "%(headrev)s",
            "--rev_name",
            "%(branchname)s-%(shortrev)s",
            "--rev_submitted",
            "false",
        ]
    command = "C:/Python34/python.exe C:/fifoci/runner/runner.py " + " ".join(
        args)
    f.addStep(
        ShellCommand(command=WithProperties(command),
                     workdir="build/tmp",
                     description="gfx testing",
                     descriptionDone="gfx test",
                     haltOnFailure=True))

    f.addStep(
        FileUpload(workersrc="tmp/result.zip",
                   masterdest="/tmp/fifoci-%s-result.zip" % type,
                   mode=0o644))

    f.addStep(
        MasterShellCommand(
            command="sudo -u fifoci /home/fifoci/python "
            "/home/fifoci/fifoci/frontend/manage.py import_results "
            "/tmp/fifoci-%s-result.zip" % type,
            description="importing result",
            descriptionDone="result import"))

    return f
Exemple #12
0
def getLLVMCMakeBuildFactory(
    clean=True,  # "clean-llvm" step is requested if true.
    test=True,  # "test-llvm" step is requested if true.
    jobs='%(jobs)s',  # Number of concurrent jobs.
    timeout=20,  # Timeout if no activity seen (minutes).
    make='make',  # Make command.
    enable_shared=False,  # Enable shared (-DBUILD_SHARED_LIBS=ON configure parameters added) if true.
    defaultBranch='trunk',  # Branch to build.
    config_name='Debug',  # Configuration name.
    env=None,  # Environmental variables for all steps.
    extra_cmake_args=[]):  # Extra args for the cmake step.
    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
        'TERM': 'dumb'  # Make sure Clang doesn't use color escape sequences.
    }
    if env is not None:
        merged_env.update(
            env
        )  # Overwrite pre-set items with the given ones, so user can set anything.

    llvm_srcdir = "llvm.src"
    llvm_objdir = "llvm.obj"

    f = buildbot.process.factory.BuildFactory()

    # Determine the build directory.
    f.addStep(
        buildbot.steps.shell.SetProperty(name="get_builddir",
                                         command=["pwd"],
                                         property="builddir",
                                         description="set build dir",
                                         workdir=".",
                                         env=merged_env))

    # Checkout sources.
    f.addStep(
        SVN(name='svn-llvm',
            mode='update',
            baseURL='http://llvm.org/svn/llvm-project/llvm/',
            defaultBranch=defaultBranch,
            workdir=llvm_srcdir))

    cmake_args = ['cmake']
    cmake_args += ["-DCMAKE_BUILD_TYPE=" + config_name]
    if enable_shared:
        cmake_args.append('-DBUILD_SHARED_LIBS=ON')
    cmake_args.extend(extra_cmake_args)
    cmake_args += ['../' + llvm_srcdir]
    f.addStep(
        Configure(command=cmake_args,
                  description=['configuring', config_name],
                  descriptionDone=['configure', config_name],
                  workdir=llvm_objdir,
                  env=merged_env))
    if clean:
        f.addStep(
            WarningCountingShellCommand(name="clean-llvm",
                                        command=[make, 'clean'],
                                        haltOnFailure=True,
                                        description="cleaning llvm",
                                        descriptionDone="clean llvm",
                                        workdir=llvm_objdir,
                                        env=merged_env))
    f.addStep(
        WarningCountingShellCommand(
            name="compile",
            command=['nice', '-n', '10', make,
                     WithProperties("-j%s" % jobs)],
            haltOnFailure=True,
            description="compiling llvm",
            descriptionDone="compile llvm",
            workdir=llvm_objdir,
            env=merged_env,
            timeout=timeout * 60))
    if test:
        litTestArgs = '-v -j %s' % jobs
        f.addStep(
            LitTestCommand(name='test-llvm',
                           command=[
                               make, "check-all", "VERBOSE=1",
                               WithProperties("-j%s" % jobs),
                               WithProperties("LIT_ARGS=%s" % litTestArgs)
                           ],
                           description=["testing", "llvm"],
                           descriptionDone=["test", "llvm"],
                           workdir=llvm_objdir,
                           env=merged_env))
    return f
Exemple #13
0
def getABITestsuitBuildFactory(
            clean = True,
            depends_on_projects  = None,
            extra_configure_args = None, # Extra CMake args for all stages.
            jobs = None,                 # Restrict a degree of parallelism if needed.
            env  = None,                 # Environmental variables for all steps.
            **kwargs):

    # Prepare environmental variables. Set here all env we want for all steps.
    merged_env = {
        'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
        }
    if env is not None:
        # Overwrite pre-set items with the given ones, so user can set anything.
        merged_env.update(env)

    if depends_on_projects:
        depends_on_projects = list(depends_on_projects)
    else:
        depends_on_projects = ['llvm', 'clang', 'clang-tools-extra', 'compiler-rt', 'lld']

    if extra_configure_args is None:
        cmake_args = list()
    else:
        cmake_args = list(extra_configure_args)

    # Some options are required for this build no matter what.
    CmakeCommand.applyRequiredOptions(cmake_args, [
        ('-G',                      'Ninja'),
        ])

    cleanBuildRequested = lambda step: step.build.getProperty("clean", default=step.build.getProperty("clean_obj")) or clean

    f = UnifiedTreeBuilder.getLLVMBuildFactoryAndPrepareForSourcecodeSteps(
            depends_on_projects=depends_on_projects,
            llvm_srcdir="llvm",
            obj_dir="build",
            cleanBuildRequested=cleanBuildRequested,
            env=merged_env,
            **kwargs) # Pass through all the extra arguments.

    # Consume is_legacy_mode if given.
    # TODO: Remove this once legacy mode gets dropped.
    kwargs.pop('is_legacy_mode', None)

    # First of all, we shall checkout the latest test-suite.
    f.addGetSourcecodeForProject(
        project='test-suite',
        src_dir='test-suite',
        alwaysUseLatest=True,
        **kwargs)

    # Then get the LLVM source code revision this particular build is for.
    f.addGetSourcecodeSteps(**kwargs)

    UnifiedTreeBuilder.addCmakeSteps(
        f,
        cleanBuildRequested=cleanBuildRequested,
        obj_dir=f.obj_dir,
        extra_configure_args=cmake_args,
        env=env,
        **kwargs)

    f.addStep(NinjaCommand(name="build-unified-tree",
                           haltOnFailure=True,
                           description=["Build", "unified", "tree"],
                           env=merged_env,
                           workdir=f.obj_dir,
                           **kwargs # Pass through all the extra arguments.
                           ))

    # Run the ABI test.
    abi_test_env = {
        'PYTHONPATH' : WithProperties("%(workdir)s/" + f.llvm_srcdir + "/utils/lit:${PYTHONPATH}"),
        'PATH'       : WithProperties("%(workdir)s/" + f.obj_dir + "/bin:${PATH}"),
        }
    merged_env.update(abi_test_env)

    abi_test_cmd = ["python", "linux-x86.py", "clang", "test", "-v"]
    if jobs:
        abi_test_cmd.append("-j" + str(jobs))

    f.addStep(LitTestCommand(name='abi-test-suite',
                             command=abi_test_cmd,
                             description=["running", "ABI", "test-suite"],
                             descriptionDone=["ABI", "test-suite", "completed"],
                             workdir='test-suite/ABI-Testsuite',
                             env=merged_env))

    return f
def getAnnotatedBuildFactory(
    script,
    clean=False,
    depends_on_projects=None,
    env=None,
    extra_args=None,
    timeout=1200,
    checkout_llvm_sources=True):
    """
    Returns a new build factory that uses AnnotatedCommand, which
    allows the build to be run by version-controlled scripts that do
    not require a buildmaster restart to update.

    script: script under "builders/annotated" to be run by python
    clean: set to true for a clean build of llvm
    depends_on_projects: which subprojects to enable
        llvm must be first in the list
        (default: ["llvm", "clang", "compiler-rt", "libcxx",
                   "libcxxabi", "libunwind", "lld"])
    env: environment overrides (map; default is no overrides)
    extra_args: extra arguments to pass to the script (default: [])
    timeout: specifies the builder's timeout in seconds (default: 1200)
    """

    if depends_on_projects is None:
        depends_on_projects = [
            "llvm",
            "clang",
            "compiler-rt",
            "libcxx",
            "libcxxabi",
            "libunwind",
            "lld"]
    if extra_args is None:
        extra_args = []

    f = LLVMBuildFactory(
        clean=clean,
        depends_on_projects=depends_on_projects)

    if clean:
        f.addStep(SetProperty(property='clean', command='echo 1'))

    # We normally use the clean property to indicate that we want a
    # clean build, but AnnotatedCommand uses the clobber property
    # instead. Therefore, set clobber if clean is set to a truthy
    # value.  This will cause AnnotatedCommand to set
    # BUILDBOT_CLOBBER=1 in the environment, which is how we
    # communicate to the script that we need a clean build.
    f.addStep(SetProperty(
        property='clobber',
        command='echo 1',
        doStepIf=lambda step: step.build.getProperty('clean', False)))

    merged_env = {
        'TERM': 'dumb'  # Be cautious and disable color output from all tools.
    }
    if env is not None:
        # Overwrite pre-set items with the given ones, so user can set
        # anything.
        merged_env.update(env)

    scripts_dir = "annotated"

    # Check out zorg so we can run the annotator scripts.
    f.addGetSourcecodeForProject(
        name='update-annotated-scripts',
        project='zorg',
        src_dir='llvm-zorg',
        alwaysUseLatest=True)

    if checkout_llvm_sources:
      f.addGetSourcecodeSteps()

    extra_args_with_props = [WithProperties(arg) for arg in extra_args]
    # Explicitly use '/' as separator, because it works on *nix and Windows.
    if script.startswith('/'):
      command = [script]
    else:
      script_path = "../llvm-zorg/zorg/buildbot/builders/annotated/%s" % (script)
      command = ["python", script_path, WithProperties("--jobs=%(jobs:-)s")]
    command += extra_args_with_props

    f.addStep(AnnotatedCommand(name="annotate",
                               description="annotate",
                               timeout=timeout,
                               haltOnFailure=True,
                               command=command,
                               env=merged_env))
    return f
Exemple #15
0
 def testLambdaSubst(self):
     command = WithProperties('%(foo)s', foo=lambda _: 'bar')
     d = self.build.render(command)
     d.addCallback(self.failUnlessEqual, 'bar')
     return d
Exemple #16
0
def make_fifoci_linux(type, mode="normal"):
    # Requirements for a FifoCI linux buildworker:
    #  - ~/python pointing to the fifoci virtualenv Python.
    #  - ~/dff existing to cache DFF files
    #  - ~/fifoci pointing to FifoCI Git

    mode = mode.split(",")
    normal = "normal" in mode
    pr = "pr" in mode

    f = BuildFactory()
    f.addStep(
        GitNoBranch(repourl="https://github.com/dolphin-emu/dolphin.git",
                    progress=True,
                    mode="incremental"))

    f.addStep(
        ShellCommand(
            command=
            "cd ~/fifoci && git fetch && git checkout master && git reset --hard origin/master || true",
            logEnviron=False,
            description="Updating FifoCI",
            descriptionDone="FifoCI update"))

    f.addStep(
        ShellCommand(command=["mkdir", "-p", "build"],
                     logEnviron=False,
                     description="mkbuilddir",
                     descriptionDone="mkbuilddir"))

    f.addStep(
        ShellCommand(
            command=
            "cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/prefix -DENABLE_QT=OFF -DENABLE_EVDEV=OFF -GNinja ..",
            workdir="build/build",
            description="configuring",
            descriptionDone="configure",
            haltOnFailure=True))

    f.addStep(
        Compile(command=["ninja"],
                workdir="build/build",
                description="building",
                descriptionDone="build",
                haltOnFailure=True))

    f.addStep(
        Compile(command=["ninja", "install"],
                workdir="build/build",
                description="installing",
                descriptionDone="install",
                haltOnFailure=True))

    url_base = "https://fifoci.dolphin-emu.org"
    args = [
        "--type",
        type,
        "--dolphin",
        "$(pwd)/prefix/bin/dolphin-emu-nogui",
        "--rev_base_hash",
        "$(git rev-parse HEAD)",
        "--output",
        "result.zip",
        "--url_base",
        url_base,
        "--dff_dir",
        "~/dff",
    ]
    if normal:
        args += [
            "--rev_hash",
            "$(git rev-parse HEAD)",
            "--rev_name",
            "%(shortrev)s",
            "--rev_submitted",
            "true",
        ]
    elif pr:
        args += [
            "--rev_hash",
            "%(headrev)s",
            "--rev_name",
            "%(branchname)s-%(shortrev)s",
            "--rev_submitted",
            "false",
        ]
    command = "~/python ~/fifoci/runner/runner.py " + " ".join(args)
    f.addStep(
        ShellCommand(command=WithProperties(command),
                     workdir="build/build",
                     description="gfx testing",
                     descriptionDone="gfx test",
                     haltOnFailure=True))

    f.addStep(
        FileUpload(workersrc="build/result.zip",
                   masterdest="/tmp/fifoci-%s-result.zip" % type,
                   mode=0o644))

    f.addStep(
        MasterShellCommand(
            command="sudo -u fifoci /home/fifoci/python "
            "/home/fifoci/fifoci/frontend/manage.py import_results "
            "/tmp/fifoci-%s-result.zip" % type,
            description="importing result",
            descriptionDone="result import"))

    return f
Exemple #17
0
 def testLambdaHasattr(self):
     command = WithProperties(
         '%(foo)s', foo=lambda b: b.hasProperty('x') and 'x' or 'y')
     d = self.build.render(command)
     d.addCallback(self.failUnlessEqual, 'y')
     return d
    def __init__(self, python, source, uncleanWarnings, trialTests=None,
                 trialMode=None, virtualenv=False,
                 virtualenv_module='virtualenv',
                 platform='unix',
                 forceGarbageCollection=False):
        if not isinstance(source, list):
            source = [source]
        else:
            source = list(source)

        # If permissions get messed up on a slave, this can fix it.
        # But it breaks on old slaves so it's not enabled all the time
        # (and it can't fix old slaves, obviously).

        # self._fixPermissions(source)

        BuildFactory.__init__(self, source)

        if type(python) is str:
            python = [python, "-Wall"]

        assert platform in ["unix", "windows"]

        self._platform = platform
        if platform == "unix":
            self._path = posixpath
        elif platform == "windows":
            self._path = ntpath

        self.python = python
        self.virtualenv = virtualenv
        self.uncleanWarnings = uncleanWarnings
        self.forceGarbageCollection = forceGarbageCollection
        self.trialMode = trialMode
        if trialTests is None:
            trialTests = [WithProperties("%(test-case-name:~twisted)s")]
        self.trialTests = trialTests

        if virtualenv:
            # Hopefully temporary workaround for --clear not working:
            # https://github.com/pypa/virtualenv/issues/929
            self.addStep(
                shell.ShellCommand,
                command = self.python + [
                    "-c", "import shutil, sys;"
                    "shutil.rmtree(sys.argv[1], ignore_errors=True)",
                    self._virtualEnvPath,
                ]
            )
            self.addStep(
                shell.ShellCommand,
                command = self.python + [
                    "-m", virtualenv_module, self._virtualEnvPath,
                ]
            )

        else:
            # Report the versions, since we're using the system ones. If it's a
            # virtualenv, it's up to the venv factory to report the versions
            # itself.
            self._reportVersions(python=self.python)
Exemple #19
0
def getClangBuildFactory(
            triple=None,
            clean=True,
            test=True,
            package_dst=None,
            run_cxx_tests=False,
            examples=False,
            valgrind=False,
            valgrindLeakCheck=False,
            useTwoStage=False,
            completely_clean=False, 
            make='make',
            jobs="%(jobs)s",
            stage1_config='Debug+Asserts',
            stage2_config='Release+Asserts',
            env={}, # Environmental variables for all steps.
            extra_configure_args=[],
            stage2_extra_configure_args=[],
            use_pty_in_tests=False,
            trunk_revision=None,
            force_checkout=False,
            extra_clean_step=None,
            checkout_compiler_rt=False,
            checkout_lld=False,
            run_gdb=False,
            run_modern_gdb=False,
            run_gcc=False):
    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
        'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
                 }
    if env is not None:
        # Overwrite pre-set items with the given ones, so user can set anything.
        merged_env.update(env)

    llvm_srcdir = "llvm.src"
    llvm_1_objdir = "llvm.obj"
    llvm_1_installdir = "llvm.install.1"
    llvm_2_objdir = "llvm.obj.2"
    llvm_2_installdir = "llvm.install"

    f = buildbot.process.factory.BuildFactory()

    # Determine the build directory.
    f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
                                               command=["pwd"],
                                               property="builddir",
                                               description="set build dir",
                                               workdir=".",
                                               env=merged_env))

    # Blow away completely, if requested.
    if completely_clean:
        f.addStep(ShellCommand(name="rm-llvm.src",
                               command=["rm", "-rf", llvm_srcdir],
                               haltOnFailure=True,
                               description=["rm src dir", "llvm"],
                               workdir=".",
                               env=merged_env))

    # Checkout sources.
    if trunk_revision:
        # The SVN build step provides no mechanism to check out a specific revision
        # based on a property, so just run the commands directly here.
        svn_co = ['svn', 'checkout']
        if force_checkout:
            svn_co += ['--force']
        svn_co += ['--revision', WithProperties(trunk_revision)]

        svn_co_llvm = svn_co + \
          [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
                          trunk_revision),
           llvm_srcdir]
        svn_co_clang = svn_co + \
          [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
                          trunk_revision),
           '%s/tools/clang' % llvm_srcdir]
        svn_co_clang_tools_extra = svn_co + \
          [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
                          trunk_revision),
           '%s/tools/clang/tools/extra' % llvm_srcdir]

        f.addStep(ShellCommand(name='svn-llvm',
                               command=svn_co_llvm,
                               haltOnFailure=True,
                               workdir='.'))
        f.addStep(ShellCommand(name='svn-clang',
                               command=svn_co_clang,
                               haltOnFailure=True,
                               workdir='.'))
        f.addStep(ShellCommand(name='svn-clang-tools-extra',
                               command=svn_co_clang_tools_extra,
                               haltOnFailure=True,
                               workdir='.'))
    else:
        f.addStep(SVN(name='svn-llvm',
                      mode='update',
                      baseURL='http://llvm.org/svn/llvm-project/llvm/',
                      defaultBranch='trunk',
                      workdir=llvm_srcdir))
        f.addStep(SVN(name='svn-clang',
                      mode='update',
                      baseURL='http://llvm.org/svn/llvm-project/cfe/',
                      defaultBranch='trunk',
                      workdir='%s/tools/clang' % llvm_srcdir))
        f.addStep(SVN(name='svn-clang-tools-extra',
                      mode='update',
                      baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
                      defaultBranch='trunk',
                      workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
        if checkout_compiler_rt:
            f.addStep(SVN(name='svn-compiler-rt',
                          mode='update',
                          baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
                          defaultBranch='trunk',
                          workdir='%s/projects/compiler-rt' % llvm_srcdir))

    # Clean up llvm (stage 1); unless in-dir.
    if clean and llvm_srcdir != llvm_1_objdir:
        f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
                               command=["rm", "-rf", llvm_1_objdir],
                               haltOnFailure=True,
                               description=["rm build dir", "llvm"],
                               workdir=".",
                               env=merged_env))

    if not clean:
        expected_makefile = 'Makefile'
        f.addStep(SetProperty(name="Makefile_isready",
                              workdir=llvm_1_objdir,
                              command=["sh", "-c",
                                       "test -e %s && echo OK || echo Missing" % expected_makefile],
                              flunkOnFailure=False,
                              property="exists_Makefile"))

    cmake_triple_arg = []
    if triple:
        cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
    f.addStep(ShellCommand(name='cmake',
                           command=['cmake',
                                    '-DLLVM_BUILD_TESTS=ON',
                                    '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
                                   cmake_triple_arg +
                                   extra_configure_args +
                                   ["../" + llvm_srcdir],
                           description='cmake stage1',
                           workdir=llvm_1_objdir,
                           env=merged_env,
                           doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))

    # Make clean if using in-dir builds.
    if clean and llvm_srcdir == llvm_1_objdir:
        f.addStep(WarningCountingShellCommand(name="clean-llvm",
                                              command=[make, "clean"],
                                              haltOnFailure=True,
                                              description="cleaning llvm",
                                              descriptionDone="clean llvm",
                                              workdir=llvm_1_objdir,
                                              doStepIf=clean,
                                              env=merged_env))

    if extra_clean_step:
        f.addStep(extra_clean_step)

    f.addStep(WarningCountingShellCommand(name="compile",
                                          command=['nice', '-n', '10',
                                                   make, WithProperties("-j%s" % jobs)],
                                          haltOnFailure=True,
                                          flunkOnFailure=not run_gdb,
                                          description=["compiling", stage1_config],
                                          descriptionDone=["compile", stage1_config],
                                          workdir=llvm_1_objdir,
                                          env=merged_env))

    if examples:
        f.addStep(WarningCountingShellCommand(name="compile.examples",
                                              command=['nice', '-n', '10',
                                                       make, WithProperties("-j%s" % jobs),
                                                       "BUILD_EXAMPLES=1"],
                                              haltOnFailure=True,
                                              description=["compiling", stage1_config, "examples"],
                                              descriptionDone=["compile", stage1_config, "examples"],
                                              workdir=llvm_1_objdir,
                                              env=merged_env))

    clangTestArgs = '-v -j %s' % jobs
    if valgrind:
        clangTestArgs += ' --vg'
        if valgrindLeakCheck:
            clangTestArgs += ' --vg-leak'
        clangTestArgs += ' --vg-arg --suppressions=%(builddir)s/llvm/tools/clang/utils/valgrind/x86_64-pc-linux-gnu_gcc-4.3.3.supp --vg-arg --suppressions=%(builddir)s/llvm/utils/valgrind/x86_64-pc-linux-gnu.supp'
    extraTestDirs = ''
    if run_cxx_tests:
        extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
    if test:
        f.addStep(lit_test_command.LitTestCommand(name='check-all',
                                   command=[make, "check-all", "VERBOSE=1",
                                            WithProperties("LIT_ARGS=%s" % clangTestArgs),
                                            WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
                                   flunkOnFailure=not run_gdb,
                                   description=["checking"],
                                   descriptionDone=["checked"],
                                   workdir=llvm_1_objdir,
                                   usePTY=use_pty_in_tests,
                                   env=merged_env))

    # TODO: Install llvm and clang for stage1.

    if run_gdb or run_gcc or run_modern_gdb:
        ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
        install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
        if run_gdb:
            addClangGDBTests(f, ignores, install_prefix)
        if run_modern_gdb:
            addModernClangGDBTests(f, jobs, install_prefix)
        if run_gcc:
            addClangGCCTests(f, ignores, install_prefix)

    if not useTwoStage:
        if package_dst:
            name = WithProperties(
                "%(builddir)s/" + llvm_1_objdir +
                "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
            f.addStep(ShellCommand(name='pkg.tar',
                                   description="tar root",
                                   command=["tar", "zcvf", name, "./"],
                                   workdir=llvm_1_installdir,
                                   warnOnFailure=True,
                                   flunkOnFailure=False,
                                   haltOnFailure=False,
                                   env=merged_env))
            f.addStep(ShellCommand(name='pkg.upload',
                                   description="upload root",
                                   command=["scp", name,
                                            WithProperties(
                            package_dst + "/%(buildername)s")],
                                   workdir=".",
                                   warnOnFailure=True,
                                   flunkOnFailure=False,
                                   haltOnFailure=False,
                                   env=merged_env))

        return f

    # Clean up llvm (stage 2).
    #
    # 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.
    f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
                           command=["rm", "-rf", llvm_2_objdir],
                           haltOnFailure=True,
                           description=["rm build dir", "llvm", "(stage 2)"],
                           workdir=".",
                           env=merged_env))

    # Configure llvm (stage 2).
    f.addStep(ShellCommand(name='cmake',
                           command=['cmake'] + stage2_extra_configure_args + [
                                    '-DLLVM_BUILD_TESTS=ON',
                                    WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
                                    WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
                                    '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
                                    "../" + llvm_srcdir],
                           description='cmake stage2',
                           workdir=llvm_2_objdir,
                           env=merged_env))

    # Build llvm (stage 2).
    f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
                                          command=['nice', '-n', '10',
                                                   make, WithProperties("-j%s" % jobs)],
                                          haltOnFailure=True,
                                          description=["compiling", "(stage 2)",
                                                       stage2_config],
                                          descriptionDone=["compile", "(stage 2)",
                                                           stage2_config],
                                          workdir=llvm_2_objdir,
                                          env=merged_env))

    if test:
        f.addStep(lit_test_command.LitTestCommand(name='check-all',
                                   command=[make, "check-all", "VERBOSE=1",
                                            WithProperties("LIT_ARGS=%s" % clangTestArgs),
                                            WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
                                   description=["checking"],
                                   descriptionDone=["checked"],
                                   workdir=llvm_2_objdir,
                                   usePTY=use_pty_in_tests,
                                   env=merged_env))

    # TODO: Install llvm and clang for stage2.

    if package_dst:
        name = WithProperties(
            "%(builddir)s/" + llvm_2_objdir +
            "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
        f.addStep(ShellCommand(name='pkg.tar',
                               description="tar root",
                               command=["tar", "zcvf", name, "./"],
                               workdir=llvm_2_installdir,
                               warnOnFailure=True,
                               flunkOnFailure=False,
                               haltOnFailure=False,
                               env=merged_env))
        f.addStep(ShellCommand(name='pkg.upload',
                               description="upload root",
                               command=["scp", name,
                                        WithProperties(
                        package_dst + "/%(buildername)s")],
                               workdir=".",
                               warnOnFailure=True,
                               flunkOnFailure=False,
                               haltOnFailure=False,
                               env=merged_env))

    return f
    def __init__(self, source, toxEnv, buildID, reactors=["default"],
                 allowSystemPackages=False, platform="unix", python="python",
                 env={}):

        tests = [WithProperties("%(test-case-name:~)s")]
        tests = []

        BuildFactory.__init__(self, source)

        assert platform in ["unix", "windows"]

        self._platform = platform
        if platform == "unix":
            self._path = posixpath
        elif platform == "windows":
            self._path = ntpath

        self.addStep(
            shell.ShellCommand,
            description="clearing virtualenv".split(" "),
            command = [python, "-c", "import shutil; shutil.rmtree('" + self._virtualEnvPath + "', True)"],
        )

        self.addStep(
            shell.ShellCommand,
            description="making virtualenv".split(" "),
            command = [python, "-m", "virtualenv", "--clear",
                       self._virtualEnvPath]
        )

        self.addVirtualEnvStep(
            shell.ShellCommand,
            description="installing tox".split(" "),
            command=["python", "-m", "pip", "install", "tox", "virtualenv",
                     "coverage", "codecov"]
        )

        self.addVirtualEnvStep(
            shell.ShellCommand,
            description="clearing coverage".split(" "),
            command=["coverage", "erase"]
        )

        for reactor in reactors:
            self.addVirtualEnvStep(TrialTox,
                                   allowSystemPackages=allowSystemPackages,
                                   reactor=reactor,
                                   tests=tests,
                                   toxEnv=toxEnv,
                                   commandNumber=2,
                                   _env=env,
            )

        self.addVirtualEnvStep(
            shell.ShellCommand,
            description = "run coverage combine".split(" "),
            command=["python", "-m", "coverage", 'combine']
        )

        self.addVirtualEnvStep(
            shell.ShellCommand,
            description = "run coverage xml".split(" "),
            command=["python", "-m", "coverage", 'xml', '-o', 'coverage.xml',
                     '-i'])

        self.addVirtualEnvStep(
            shell.ShellCommand,
            warnOnFailure=True,
            description="upload to codecov".split(" "),
            command=["codecov",
                     "--token={}".format(private.codecov_twisted_token),
                     "--build={}".format(buildID),
                     "--file=coverage.xml",
                     WithProperties("--commit=%(got_revision)s")
            ],
        )
Exemple #21
0
 def testBasic(self):
     # test basic substitution with WithProperties
     self.props.setProperty("revision", "47", "test")
     command = WithProperties("build-%s.tar.gz", "revision")
     self.failUnlessEqual(self.props.render(command), "build-47.tar.gz")
def getCUDATestsuiteBuildFactory(
        externals,  # Directory with CUDA, thrust and gcc versions for testing.
        always_clean=True,
        test=False,
        useTwoStage=False,
        cmake='cmake',
        extra_cmake_args=None,  # Extra CMake args for all stages.
        extra_ts_cmake_args=None,  # extra cmake args for testsuite.
        jobs=None,
        cuda_jobs=1,  # number of simultaneous CUDA apps to run
        env=None,  # Environmental variables for all steps.
        enable_thrust_tests=False,
        split_thrust_tests=False,  # Each thrust test is a separate executable.
        run_thrust_tests=False,
        enable_libcxx=True,  # checkout/build libcxx to test with.
        gpu_arch_list=None,
        gpu_devices=None,  # List of devices to make visible to  CUDA
        stage1_config='Release',
        stage2_config='Release'):

    if extra_cmake_args is None:
        extra_cmake_args = []
    if extra_ts_cmake_args is None:
        extra_ts_cmake_args = []

    # Prepare environmental variables. Set here all env we want for all steps.
    merged_env = {
        'TERM': 'dumb'  # Make sure Clang doesn't use color escape sequences.
    }
    if env is not None:
        # Overwrite pre-set items with the given ones, so user can set
        # anything.
        merged_env.update(env)

    source_dir = 'llvm'   # Should match the one used in getClangCMakeBuildFactory.
    stage1_build_dir = 'stage1'  # Should match the one defined in getClangCMakeBuildFactory.
    stage2_build_dir = 'stage2'  # Should match the one defined in getClangCMakeBuildFactory.

    if useTwoStage:
        clang_build_dir = stage2_build_dir
    else:
        clang_build_dir = stage1_build_dir

    # Build clang.
    f = ClangBuilder.getClangCMakeBuildFactory(
            clean=always_clean,
            test=test,
            cmake=cmake,
            extra_cmake_args=extra_cmake_args,
            jobs=jobs,
            env=merged_env,
            useTwoStage=useTwoStage,
            stage1_config=stage1_config,
            stage2_config=stage2_config,
            checkout_libcxx=enable_libcxx,
            checkout_test_suite=True)

    cuda_test_env = {
        'PYTHONPATH': WithProperties("%(workdir)s/" + source_dir +
                                     "/utils/lit:${PYTHONPATH}"),
        'PATH': WithProperties("%(workdir)s/" + clang_build_dir +
                               "/bin:${PATH}"),
    }
    # Limit GPUs visible to CUDA.
    if gpu_devices:
        cuda_test_env["CUDA_VISIBLE_DEVICES"] = ",".join(
            str(x) for x in gpu_devices)
    merged_env.update(cuda_test_env)

    ts_build_dir = 'test-suite-build'

    # Completely remove test suite build dir.
    f.addStep(
        RemoveDirectory(name="Remove old test-suite build directory",
                        dir=ts_build_dir))

    if extra_ts_cmake_args:
        cmake_args = extra_ts_cmake_args[:]
    else:
        cmake_args = []

    # Set proper defaults.
    CmakeCommand.applyDefaultOptions(cmake_args, [
        ('-DCMAKE_BUILD_TYPE=',        'Release'),
    ])

    # Some options are required for this stage no matter what.
    CmakeCommand.applyRequiredOptions(cmake_args, [
        ('-G',                      'Ninja'),
    ])

    cmake_args.append(
        WithProperties(
            "-DCMAKE_CXX_COMPILER=%(workdir)s/" +
                                    clang_build_dir + "/bin/clang++"
        ))
    cmake_args.append(
        WithProperties(
            "-DCMAKE_C_COMPILER=%(workdir)s/" + clang_build_dir + "/bin/clang"
        ))

    cmake_args.append('-DTEST_SUITE_SUBDIRS=External'),
                      # Limit to External tests only.

    if externals:
        cmake_args.append('-DTEST_SUITE_EXTERNALS_DIR=' + externals)
    if split_thrust_tests:
        cmake_args.append('-DTHRUST_SPLIT_TESTS=1')
    if gpu_arch_list:
        cmake_args.append('-DCUDA_GPU_ARCH=' + ';'.join(gpu_arch_list))
    if cuda_jobs:
        cmake_args.append('-DCUDA_JOBS=%s' % cuda_jobs)

    # Then do fresh cmake configuration.
    f.addStep(CmakeCommand(name='cmake test-suite',
                           description='cmake test-suite',
                           haltOnFailure=True,
                           options=cmake_args,
                           path="../test/test-suite",
                           workdir=ts_build_dir,
                           env=merged_env))

    # Always build simple CUDA tests. They serve as compilation
    # smoketests and will fail quickly if compiler has obvious issues
    # compiling CUDA files.
    f.addStep(NinjaCommand(
        name='ninja build simple CUDA tests',
        targets=["cuda-tests-simple"],
        jobs=jobs,
        haltOnFailure=True,
        description=["building simple CUDA tests"],
        descriptionDone=["simple CUDA tests built."],
        workdir=ts_build_dir,
        env=merged_env))

    f.addStep(NinjaCommand(
        name='run simple CUDA tests',
        targets=["check-cuda-simple"],
        jobs=1, # lit will parallelize the jobs
        haltOnFailure=True,
        description=["Running simple CUDA tests"],
        descriptionDone=["simple CUDA tests done."],
        workdir=ts_build_dir,
        env=merged_env))

    # If we've enabled thrust tests, build them now.
    # WARNING: This takes a lot of time to build.
    if (enable_thrust_tests):
        f.addStep(NinjaCommand(
            name='ninja build thrust',
            targets=["cuda-tests-thrust"],
            jobs=jobs,
            haltOnFailure=True,
            description=["building thrust tests"],
            descriptionDone=["thrust tests built."],
            workdir=ts_build_dir,
            env=merged_env))
        # Run them. That also takes a while.
        # TODO(tra) we may want to run more than one instance so one
        # can be compiling tests while another is running them on GPU.
        if run_thrust_tests:
            f.addStep(NinjaCommand(
                name='run all CUDA tests',
                targets=["check"],
                jobs=1, # lit will parallelize the jobs.
                haltOnFailure=True,
                description=["running all CUDA tests."],
                descriptionDone=["all cuda tests done."],
                workdir=ts_build_dir,
                env=merged_env))

    return f
Exemple #23
0
 def testEmpty(self):
     # None should render as ''
     self.props.setProperty("empty", None, "test")
     command = WithProperties("build-%(empty)s.tar.gz")
     self.failUnlessEqual(self.props.render(command), "build-.tar.gz")
Exemple #24
0
 def testSimpleUnset(self):
     d = self.build.render(WithProperties('%(prop_nosuch)s'))
     return self.assertFailure(d, KeyError)
Exemple #25
0
 def testLambdaOverride(self):
     self.props.setProperty('x', 10, 'test')
     command = WithProperties('%(x)s', x=lambda _: 20)
     self.failUnlessEqual(self.props.render(command), '20')
Exemple #26
0
 def testInvalidParams(self):
     self.assertRaises(ValueError,
                       lambda: WithProperties("%s %(foo)s", 1, foo=2))
Exemple #27
0
 def testLambdaUseExisting(self):
     self.props.setProperty('x', 10, 'test')
     self.props.setProperty('y', 20, 'test')
     command = WithProperties('%(z)s', z=lambda pmap: pmap['x'] + pmap['y'])
     self.failUnlessEqual(self.props.render(command), '30')
Exemple #28
0
 def doTestSimpleWithProperties(self, fmtstring, expect, **kwargs):
     d = self.build.render(WithProperties(fmtstring, **kwargs))
     d.addCallback(self.failUnlessEqual, "%s" % expect)
     return d
Exemple #29
0
def getPollyBuildFactory(
    clean=False,
    install=False,
    make='make',
    jobs=None,
    checkAll=False,
    env=None,
    extraCmakeArgs=None,
    testsuite=False,extraTestsuiteCmakeArgs=None,
    **kwargs):

    if extraCmakeArgs is None:
        extraCmakeArgs=[]
    if extraTestsuiteCmakeArgs is None:
        extraTestsuiteCmakeArgs = []

    llvm_srcdir = "llvm.src"
    llvm_objdir = "llvm.obj"
    llvm_instdir = "llvm.inst"
    testsuite_srcdir = "test-suite.src"
    testsuite_builddir = "test-suite.build"

    jobs_cmd = []
    if jobs is not None:
        jobs_cmd = ["-j"+str(jobs)]
    build_cmd = [make] + jobs_cmd
    install_cmd = [make, 'install'] + jobs_cmd
    check_all_cmd = [make, 'check-all'] + jobs_cmd
    check_polly_cmd = [make, 'check-polly'] + jobs_cmd
    cmake_install = []
    if install:
        cmake_install = ["-DCMAKE_INSTALL_PREFIX=../%s" % llvm_instdir]
    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
                   'TERM' : 'dumb'     # Make sure Clang doesn't use color escape sequences.
                 }
    if env:
        merged_env.update(env)  # Overwrite pre-set items with the given ones, so user can set anything.

    depends_on_projects = ['llvm','clang','polly']
    if testsuite:
        # XRay tests in test-suite require compiler-rt
        depends_on_projects += ['compiler-rt']

    cleanBuildRequestedByProperty = lambda step: step.build.getProperty("clean", False)
    cleanBuildRequested = lambda step: clean or step.build.getProperty("clean", default=step.build.getProperty("clean_obj"))

    f = LLVMBuildFactory(
            depends_on_projects=depends_on_projects,
            llvm_srcdir=llvm_srcdir,
            obj_dir=llvm_objdir,
            install_dir=llvm_instdir,
            cleanBuildRequested=cleanBuildRequested,
            **kwargs) # Pass through all the extra arguments.

    f.addStep(RemoveDirectory(name='clean-src-dir',
                           dir=f.monorepo_dir,
                           warnOnFailure=True,
                           doStepIf=cleanBuildRequestedByProperty))

    # Get the source code.
    f.addGetSourcecodeSteps(**kwargs)

    # Clean build dir
    f.addStep(RemoveDirectory(name='clean-build-dir',
                           dir=llvm_objdir,
                           warnOnFailure=True,
                           doStepIf=cleanBuildRequested))

    # Create configuration files with cmake
    cmakeCommand = ["cmake", "../%s/llvm" % llvm_srcdir,
                    "-DCMAKE_COLOR_MAKEFILE=OFF",
                    "-DPOLLY_TEST_DISABLE_BAR=ON",
                    "-DPOLLY_ENABLE_GPGPU_CODEGEN=ON",
                    "-DCMAKE_BUILD_TYPE=Release",
                    "-DLLVM_POLLY_LINK_INTO_TOOLS=ON",
                    "-DLLVM_ENABLE_PROJECTS=%s" % ";".join(f.depends_on_projects),
                   ] + cmake_install + extraCmakeArgs
    f.addStep(ShellCommand(name="cmake-configure",
                           command=cmakeCommand,
                           haltOnFailure=False,
                           description=["cmake configure"],
                           workdir=llvm_objdir,
                           env=merged_env))

    # Build
    f.addStep(WarningCountingShellCommand(name="build",
                           command=build_cmd,
                           haltOnFailure=True,
                           description=["build"],
                           workdir=llvm_objdir,
                           env=merged_env))

    clangexe = "%(workdir)s/" + llvm_objdir + "/bin/clang"
    clangxxexe = "%(workdir)s/" + llvm_objdir + "/bin/clang++"
    litexe = "%(workdir)s/" + llvm_objdir + "/bin/llvm-lit"
    sizeexe = "%(workdir)s/" + llvm_objdir + "/bin/llvm-size"

    # Clean install dir
    if install:
        f.addStep(RemoveDirectory(name='clean-install-dir',
                               dir=llvm_instdir,
                               haltOnFailure=False,
                               doStepIf=cleanBuildRequested))

        f.addStep(ShellCommand(name="install",
                               command=install_cmd,
                               haltOnFailure=True,
                               description=["install"],
                               workdir=llvm_objdir,
                               env=merged_env))

        # If installing, use the installed version of clang.
        clangexe = "%(workdir)s/" + llvm_instdir + "/bin/clang"
        clangxxexe = "%(workdir)s/" + llvm_instdir + "/bin/clang++"
        sizeexe = "%(workdir)s/" + llvm_instdir + "/bin/llvm-size"

    # Test
    if checkAll:
        f.addStep(LitTestCommand(name="check_all",
                               command=check_all_cmd,
                               haltOnFailure=False,
                               description=["check all"],
                               workdir=llvm_objdir,
                               env=merged_env))
    else:
        f.addStep(LitTestCommand(name="check_polly",
                               command=check_polly_cmd,
                               haltOnFailure=False,
                               description=["check polly"],
                               workdir=llvm_objdir,
                               env=merged_env))

    if testsuite:
        f.addStep(RemoveDirectory(name='test-suite_clean-src-dir',
                           dir=testsuite_srcdir,
                           haltOnFailure=False,
                           warnOnFailure=True,
                           doStepIf=cleanBuildRequestedByProperty))

        f.addGetSourcecodeForProject(
            project='test-suite',
            src_dir=testsuite_srcdir,
            alwaysUseLatest=True)

        f.addStep(RemoveDirectory(name='test-suite_clean-build-dir',
                           dir=testsuite_builddir,
                           haltOnFailure=False,
                           warnOnFailure=True))

        # -Wno-unused-command-line-argument is needed because linking will not uses the "-mllvm -polly" argument.
        f.addStep(ShellCommand(name='test-suite_cmake-configure',
                           description=["Test-Suite: cmake"],
                           command=["cmake", '-B', testsuite_builddir, '-S', testsuite_srcdir,
                                    "-DCMAKE_BUILD_TYPE=Release",
                                    "-DTEST_SUITE_COLLECT_STATS=ON",
                                    "-DTEST_SUITE_EXTRA_C_FLAGS=-Wno-unused-command-line-argument -mllvm -polly",
                                    "-DTEST_SUITE_EXTRA_CXX_FLAGS=-mllvm -polly",
                                    "-DTEST_SUITE_LIT_FLAGS=-vv;-o;report.json",
                                    WithProperties("-DCMAKE_C_COMPILER=" + clangexe),
                                    WithProperties("-DCMAKE_CXX_COMPILER=" + clangxxexe),
                                    WithProperties("-DTEST_SUITE_LLVM_SIZE=" + sizeexe),
                                    WithProperties("-DTEST_SUITE_LIT=" + litexe),
                                ] + extraTestsuiteCmakeArgs,
                           haltOnFailure=True,
                           workdir='.',
                           env=merged_env))

        f.addStep(WarningCountingShellCommand(name='test-suite_build',
                           description=["Test-Suite: build"],
                           # Continue building; programs that don't compile will fail with NOEXE.
                           command=[make, 'all', '-k0'] + jobs_cmd,
                           haltOnFailure=False,
                           flunkOnFailure=True,
                           workdir=testsuite_builddir,
                           env=merged_env))

        f.addStep(LitTestCommand(name='test-suite_run',
                            description=['Test-Suite: run'],
                            command=[WithProperties(litexe), '-vv', '-o', 'report.json', '.'],
                            haltOnFailure=True,
                            workdir=testsuite_builddir,
                            logfiles={
                                'test.log'   : 'test.log',
                                'report.json': 'report.json'
                                 },
                            env=merged_env))

    return f
Exemple #30
0
  def TriggerFactory(self, factory, slave_type, factory_properties):
    """Add post steps on a build created by BuildFactory."""
    # Trigger any schedulers waiting on the build to complete.
    factory_properties = factory_properties or {}
    if factory_properties.get('trigger') is None:
      return

    trigger_name = factory_properties.get('trigger')
    # Propagate properties to the children if this is set in the factory.
    trigger_properties = factory_properties.get('trigger_properties', [])
    factory.addStep(trigger.Trigger(
        schedulerNames=[trigger_name],
        updateSourceStamp=False,
        waitForFinish=False,
        set_properties={
            # Here are the standard names of the parent build properties.
            'parent_buildername': WithProperties('%(buildername:-)s'),
            'parent_buildnumber': WithProperties('%(buildnumber:-)s'),
            'parent_branch': WithProperties('%(branch:-)s'),
            'parent_got_revision': WithProperties('%(got_revision:-)s'),
            'parent_got_webkit_revision':
                WithProperties('%(got_webkit_revision:-)s'),
            'parent_got_nacl_revision':
                WithProperties('%(got_nacl_revision:-)s'),
            'parent_revision': WithProperties('%(revision:-)s'),
            'parent_scheduler': WithProperties('%(scheduler:-)s'),
            'parent_slavename': WithProperties('%(slavename:-)s'),

            # And some scripts were written to use non-standard names.
            'parent_cr_revision': WithProperties('%(got_revision:-)s'),
            'parent_wk_revision': WithProperties('%(got_webkit_revision:-)s'),
            'parentname': WithProperties('%(buildername)s'),
            'parentslavename': WithProperties('%(slavename:-)s'),
            },
        copy_properties=trigger_properties))