Пример #1
0
def main():
    if os.path.isdir(DEST_FOLDER):
        print('    Removing old copy of %s...' % DEST_FOLDER)
        ioutil.nuke(DEST_FOLDER, contents_only=True)
    print('    Copying files to %s...' % DEST_FOLDER)
    err = ioutil.transform_tree(SRC_FOLDER, DEST_FOLDER, item_filter=filter_some)
    return err
Пример #2
0
    def config(self, sb, options):
        '''
        Prompt the user for choices about which build options should
        be active; use the results to prepare the build root for targets
        to be made. This might involve creating/configuring makefiles,
        etc.
        '''
        # The following use of iftop is okay since supports validates that we are
        #  in the code root already
        uber_src = os.path.join(sb.get_iftop_folder_path(), self.get_build_file())
        uber_dst = os.path.join(sb.get_code_root(), self.get_build_file())
        _copy_file(uber_src, uber_dst)

        open(sb.get_code_root() + 'CTestCustom.ctest', 'w').close()
        timeout = sb.get_build_timeout_seconds()

        compiler_names = CompilerNames()
        user_specified_compiler = compiler_names.parse_compiler_name(options.compiler)
        default_compiler = compiler_names.get_default_compiler(sb)
        last_used_compiler = _get_cmake_cache_listed_compiler(sb)
        last_used_build_root = sb.get_built_root()

        if options.compiler and not user_specified_compiler:
            print('ERROR: compiler specified is unknown. Use one of the following:\n{0}'.format(compiler_names))
            return 2

        compiler_name = user_specified_compiler if user_specified_compiler else default_compiler

        #print('Sandbox is {0}already configured'.format('' if _is_sandbox_already_configured(last_used_build_root) else 'not '))
        #print('Last used compiler is {0}'.format(last_used_compiler))
        print('Using compiler {0}'.format(compiler_name))

        if _update_platform_variant(compiler_name, sb):
            print('Removing build directory {0}'.format(os.path.basename(last_used_build_root)))
            ioutil.nuke(last_used_build_root, contents_only=False)

        if _is_sandbox_already_configured(last_used_build_root) and last_used_compiler and last_used_compiler != compiler_name:
            print('Removing contents of build directory {0}'.format(os.path.basename(sb.get_built_root())))
            _clean_built_root(sb)

        build_cfg = '-DCMAKE_BUILD_TYPE:STRING={0} '.format(options.build_type.capitalize() if options.build_type else '')

        if not options.prompt:
            verbose = ' --trace' if options.verbose else ''
            generator = compiler_name
            cmd = _get_cmake_compiler_specific_env(sb)
            cmd += 'cmake {0}-G"{1}" --build "{2}" "{3}"{4}'.format(build_cfg, generator, sb.get_built_root(), sb.get_code_root(), verbose)
        else:
            tool = 'cmake-gui' if os.name == 'nt' else 'ccmake'
            timeout = 3600*4    # Time-out is 4 hours for the UI version! Lets hope they want control of their command prompt before then.
            cmd = '{0} "{1}"'.format(tool, sb.get_code_root())

        if not os.path.isdir(sb.get_built_root()):
            os.mkdir(sb.get_built_root())

        exitCode, stdout = run_make_command(cmd, timeout=sb.get_build_timeout_seconds(), cwd=sb.get_built_root())

        return exitCode
Пример #3
0
def main():
    if os.path.isdir(DEST_FOLDER):
        print('    Removing old copy of %s...' % DEST_FOLDER)
        ioutil.nuke(DEST_FOLDER, contents_only=True)
    print('    Copying files to %s...' % DEST_FOLDER)
    err = ioutil.transform_tree(SRC_FOLDER,
                                DEST_FOLDER,
                                item_filter=filter_some)
    return err
Пример #4
0
def main(argv):
    parser = _define_options()
    options, args = parser.parse_args(argv)
    dest_folder = os.path.abspath(options.dest)
    if not os.path.isdir(dest_folder):
        os.makedirs(dest_folder)
    else:
        print('    Removing old copy of %s...' % dest_folder)
        ioutil.nuke(dest_folder, contents_only=True)
    print('    Copying files to %s...' % dest_folder)
    ioutil.transform_tree(MY_BUILT_FOLDER, dest_folder)
Пример #5
0
def main(argv):
    parser = _define_options()
    options, args = parser.parse_args(argv)
    dest_folder = os.path.abspath(options.dest)
    if not os.path.isdir(dest_folder):
        os.makedirs(dest_folder)
    else:
        print('    Removing old copy of %s...' % dest_folder)
        ioutil.nuke(dest_folder, contents_only=True)
    print('    Copying files to %s...' % dest_folder)
    ioutil.transform_tree(MY_BUILT_FOLDER, dest_folder)
Пример #6
0
def assemble_default(comp, sb=None, path=None, quiet=True):
    '''
    Use default logic to populate a runnable assembly: just copy the
    component's built root.
    '''
    if sb is None:
        sb = sandbox.current
    if path is None:
        path = sb.get_run_root()
    built_path = sb.get_component_path(comp, component.BUILT_ASPECT_NAME)
    if os.path.isdir(path):
        ioutil.nuke(path, contents_only=True)
    return ioutil.transform_tree(built_path, path)
Пример #7
0
def main():
    if os.path.isdir(DEST_FOLDER):
        print('    Removing old copy of %s...' % DEST_FOLDER)
        # We use ioutil.nuke() instead of shutil.rmtree() so we can leave the folder
        # itself around. That is helpful on dev machines where a developer might
        # have a shell open with current working dir = the folder we're trying to
        # empty.
        ioutil.nuke(DEST_FOLDER, contents_only=True)
    print('    Copying files to %s...' % DEST_FOLDER)
    ioutil.transform_tree(SRC_FOLDER, DEST_FOLDER, item_filter=filter_some)
    # Embed buildscripts under sadm so app is runnable in isolation in built form.
    embed('buildscripts')
    embed('bzr-plugins')
    return 0
Пример #8
0
def main():
    if os.path.isdir(DEST_FOLDER):
        print('    Removing old copy of %s...' % DEST_FOLDER)
        # We use ioutil.nuke() instead of shutil.rmtree() so we can leave the folder
        # itself around. That is helpful on dev machines where a developer might
        # have a shell open with current working dir = the folder we're trying to
        # empty.
        ioutil.nuke(DEST_FOLDER, contents_only=True)
    print('    Copying files to %s...' % DEST_FOLDER)
    ioutil.transform_tree(SRC_FOLDER, DEST_FOLDER, item_filter=filter_some)
    # Embed buildscripts under sadm so app is runnable in isolation in built form.
    embed('buildscripts')
    embed('bzr-plugins')
    return 0
Пример #9
0
 def zip(self, folder):
     """Zip translations by locale"""
     if os.path.exists(folder):
         assert os.path.isdir(folder)
     files = os.listdir(folder)
     for component in self.pathsByComponent:
         locales = self.getTargetedLocales(component)
         for f in files:
             if os.path.isdir(folder + "/" + f) and f.find(".zip") == -1:
                 for loc in locales:
                     zipFiles = self.gatherLocales(folder, f, loc)
                     if zipFiles != []:
                         zipName = f + "-" + loc + ".zip"
                         print "Creating zip folder %s" % os.path.join(folder, zipName)
                         if os.path.exists(zipName):
                             ioutil.nuke(zipName)
                         z = zipfile.ZipFile(folder + zipName, "w", zipfile.ZIP_DEFLATED)
                         for zf in zipFiles:
                             z.write(folder + zf, zf)
Пример #10
0
 def zip(self, folder):
     '''Zip translations by locale'''
     if os.path.exists(folder):
         assert (os.path.isdir(folder))
     files = os.listdir(folder)
     for component in self.pathsByComponent:
         locales = self.getTargetedLocales(component)
         for f in files:
             if os.path.isdir(folder + '/' + f) and f.find('.zip') == -1:
                 for loc in locales:
                     zipFiles = self.gatherLocales(folder, f, loc)
                     if zipFiles != []:
                         zipName = f + '-' + loc + '.zip'
                         print 'Creating zip folder %s' % os.path.join(
                             folder, zipName)
                         if os.path.exists(zipName):
                             ioutil.nuke(zipName)
                         z = zipfile.ZipFile(folder + zipName, "w",
                                             zipfile.ZIP_DEFLATED)
                         for zf in zipFiles:
                             z.write(folder + zf, zf)
Пример #11
0
 def export(self, folder):
     if os.path.exists(folder):
         assert (os.path.isdir(folder))
     path = ioutil.norm_folder(folder) + self.getBatchName() + '/'
     print('exporting to %s' % path)
     if os.path.exists(path):
         ioutil.nuke(path)
     os.makedirs(path)
     for component in self.pathsByComponent:
         locales = self.getTargetedLocales(component)
         pathPats = self.pathsByComponent[component]
         for paths in pathPats:
             pathPat = paths[1]
             for loc in locales:
                 if loc != 'en':
                     relpath = pathPat % loc
                     fullpath = path + relpath
                     fldr = os.path.dirname(fullpath)
                     if not os.path.exists(fldr):
                         os.makedirs(fldr)
                     self.exportFile(fullpath, relpath)
     self.zip(folder)
Пример #12
0
 def export(self, folder):
     if os.path.exists(folder):
         assert os.path.isdir(folder)
     path = ioutil.norm_folder(folder) + self.getBatchName() + "/"
     print ("exporting to %s" % path)
     if os.path.exists(path):
         ioutil.nuke(path)
     os.makedirs(path)
     for component in self.pathsByComponent:
         locales = self.getTargetedLocales(component)
         pathPats = self.pathsByComponent[component]
         for paths in pathPats:
             pathPat = paths[1]
             for loc in locales:
                 if loc != "en":
                     relpath = pathPat % loc
                     fullpath = path + relpath
                     fldr = os.path.dirname(fullpath)
                     if not os.path.exists(fldr):
                         os.makedirs(fldr)
                     self.exportFile(fullpath, relpath)
     self.zip(folder)
Пример #13
0
 def clean(self, built_root, clean_exclusions):
     '''
     This is the only clean method we will implement for any of the builders.
     But if the individual builders require a different set of files to be
     deleted inside of the built root then they can define a different 'skip'
     method.
     @param built_root The directory which holds all of the build generated
     files.
     @param clean_exclusions A function object which will be called for each
     file to decide whether to delete it or not.
     return 0 on success and 1 on failure
     '''
     return 0 if ioutil.nuke(built_root, contents_only=True, skip=clean_exclusions) else 1
Пример #14
0
 def clean(self, built_root, clean_exclusions):
     '''
     This is the only clean method we will implement for any of the builders.
     But if the individual builders require a different set of files to be
     deleted inside of the built root then they can define a different 'skip'
     method.
     @param built_root The directory which holds all of the build generated
     files.
     @param clean_exclusions A function object which will be called for each
     file to decide whether to delete it or not.
     return 0 on success and 1 on failure
     '''
     return 0 if ioutil.nuke(
         built_root, contents_only=True, skip=clean_exclusions) else 1
Пример #15
0
def report(sb, state):
    rr = sb.get_report_root()
    root = sb.get_root()
    need_checkin = vcs.folder_is_tied_to_vcs(rr)
    try:
        # Get latest version of reports so we are less likely to cause merge
        # conflicts.
        wr = vcs.get_working_repository()
        use_master = False
        if not need_checkin:
            url = os.path.join(wr.master_reporoot, sb.get_branch(), sb.get_top_component(), 'report', ). replace('\\', '/')
            publish.create_branch(url, False)
            use_master = True
        wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=use_master)
        need_checkin = vcs.folder_is_tied_to_vcs(rr)
        # Report our results.
        bi = buildinfo.BuildInfo()
        machineFolder = os.path.join(rr, bi.host).replace('\\', '/')
        summary = EvalSummary(sb.get_build_id(), sb.get_sandboxtype().get_style(), bi.host,
                              state.phase, state.reason, state.start_time,
                              state.timestamps, sb.get_targeted_platform_variant(),
                              bi.os, bi.bitness, bi.version)
        db = Dashboard(rr)
        db.add_summary(summary)
        if os.path.exists(os.path.join(root, 'eval-log.txt')):
            shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)
        # Check in our changes.
        if need_checkin:
            status = vcs.get_status(rr)
            if 'unknown' in status:
                vcs.add(rr)
            vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
            try:
                vcs.push(rr)
            except BzrCommandError, e:
                if 'diverged' in ("%s" % e):
                    print "\nAttemping to resolve diverged report aspect"
                    print "\nNuking report dir %s" % rr
                    if not ioutil.nuke(rr):
                        print "\nAuto resolving diverged report aspect failed!"

                    bi = BranchInfo(branchname=sb.get_branch(), componentname=sb.get_top_component(), aspectname='report')
                    aspectdir = bi.get_branchdir(wr.local_reporoot)
                    print "\nNuking report repo %s" % aspectdir
                    if not ioutil.nuke(aspectdir):
                        print "\nAuto resolving diverged report aspect failed!"

                    # Use the master because we have a problem here.
                    wr.create_local_branch(sb.get_top_component(), 'report', sb.get_branch(), use_master=True)
                    wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=True)

                    db = Dashboard(rr)
                    db.add_summary(summary)
                    if os.path.exists(os.path.join(root, 'eval-log.txt')):
                        shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)

                    status = vcs.get_status(rr)
                    if 'unknown' in status:
                        vcs.add(rr)
                    vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
                    vcs.push(rr)
                    print "\nAuto resolve diverged report aspect success!"
                else:
                    raise e
    except:
        traceback.print_exc()
Пример #16
0
    def config(self, sb, options):
        '''
        Prompt the user for choices about which build options should
        be active; use the results to prepare the build root for targets
        to be made. This might involve creating/configuring makefiles,
        etc.
        '''
        # The following use of iftop is okay since supports validates that we are
        #  in the code root already
        uber_src = os.path.join(sb.get_iftop_folder_path(),
                                self.get_build_file())
        uber_dst = os.path.join(sb.get_code_root(), self.get_build_file())
        _copy_file(uber_src, uber_dst)

        open(sb.get_code_root() + 'CTestCustom.ctest', 'w').close()
        timeout = sb.get_build_timeout_seconds()

        compiler_names = CompilerNames()
        user_specified_compiler = compiler_names.parse_compiler_name(
            options.compiler)
        default_compiler = compiler_names.get_default_compiler(sb)
        last_used_compiler = _get_cmake_cache_listed_compiler(sb)
        last_used_build_root = sb.get_built_root()

        if options.compiler and not user_specified_compiler:
            print(
                'ERROR: compiler specified is unknown. Use one of the following:\n{0}'
                .format(compiler_names))
            return 2

        compiler_name = user_specified_compiler if user_specified_compiler else default_compiler

        #print('Sandbox is {0}already configured'.format('' if _is_sandbox_already_configured(last_used_build_root) else 'not '))
        #print('Last used compiler is {0}'.format(last_used_compiler))
        print('Using compiler {0}'.format(compiler_name))

        if _update_platform_variant(compiler_name, sb):
            print('Removing build directory {0}'.format(
                os.path.basename(last_used_build_root)))
            ioutil.nuke(last_used_build_root, contents_only=False)

        if _is_sandbox_already_configured(
                last_used_build_root
        ) and last_used_compiler and last_used_compiler != compiler_name:
            print('Removing contents of build directory {0}'.format(
                os.path.basename(sb.get_built_root())))
            _clean_built_root(sb)

        build_cfg = '-DCMAKE_BUILD_TYPE:STRING={0} '.format(
            options.build_type.capitalize() if options.build_type else '')

        if not options.prompt:
            verbose = ' --trace' if options.verbose else ''
            generator = compiler_name
            cmd = _get_cmake_compiler_specific_env(sb)
            cmd += 'cmake {0}-G"{1}" --build "{2}" "{3}"{4}'.format(
                build_cfg, generator, sb.get_built_root(), sb.get_code_root(),
                verbose)
        else:
            tool = 'cmake-gui' if os.name == 'nt' else 'ccmake'
            timeout = 3600 * 4  # Time-out is 4 hours for the UI version! Lets hope they want control of their command prompt before then.
            cmd = '{0} "{1}"'.format(tool, sb.get_code_root())

        if not os.path.isdir(sb.get_built_root()):
            os.mkdir(sb.get_built_root())

        exitCode, stdout = run_make_command(
            cmd,
            timeout=sb.get_build_timeout_seconds(),
            cwd=sb.get_built_root())

        return exitCode
Пример #17
0
 def remove(self):
     """
     Remove all evidence that a sandbox ever existed.
     """
     ioutil.nuke(self.get_root())
Пример #18
0
def report(sb, state):
    rr = sb.get_report_root()
    root = sb.get_root()
    need_checkin = vcs.folder_is_tied_to_vcs(rr)
    try:
        # Get latest version of reports so we are less likely to cause merge
        # conflicts.
        wr = vcs.get_working_repository()
        use_master = False
        if not need_checkin:
            url = os.path.join(
                wr.master_reporoot,
                sb.get_branch(),
                sb.get_top_component(),
                'report',
            ).replace('\\', '/')
            publish.create_branch(url, False)
            use_master = True
        wr.create_or_update_checkout(rr,
                                     sb.get_top_component(),
                                     'report',
                                     sb.get_branch(),
                                     None,
                                     use_master=use_master)
        need_checkin = vcs.folder_is_tied_to_vcs(rr)
        # Report our results.
        bi = buildinfo.BuildInfo()
        machineFolder = os.path.join(rr, bi.host).replace('\\', '/')
        summary = EvalSummary(sb.get_build_id(),
                              sb.get_sandboxtype().get_style(), bi.host,
                              state.phase, state.reason, state.start_time,
                              state.timestamps,
                              sb.get_targeted_platform_variant(), bi.os,
                              bi.bitness, bi.version)
        db = Dashboard(rr)
        db.add_summary(summary)
        if os.path.exists(os.path.join(root, 'eval-log.txt')):
            shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)
        # Check in our changes.
        if need_checkin:
            status = vcs.get_status(rr)
            if 'unknown' in status:
                vcs.add(rr)
            vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
            try:
                vcs.push(rr)
            except BzrCommandError, e:
                if 'diverged' in ("%s" % e):
                    print "\nAttemping to resolve diverged report aspect"
                    print "\nNuking report dir %s" % rr
                    if not ioutil.nuke(rr):
                        print "\nAuto resolving diverged report aspect failed!"

                    bi = BranchInfo(branchname=sb.get_branch(),
                                    componentname=sb.get_top_component(),
                                    aspectname='report')
                    aspectdir = bi.get_branchdir(wr.local_reporoot)
                    print "\nNuking report repo %s" % aspectdir
                    if not ioutil.nuke(aspectdir):
                        print "\nAuto resolving diverged report aspect failed!"

                    # Use the master because we have a problem here.
                    wr.create_local_branch(sb.get_top_component(),
                                           'report',
                                           sb.get_branch(),
                                           use_master=True)
                    wr.create_or_update_checkout(rr,
                                                 sb.get_top_component(),
                                                 'report',
                                                 sb.get_branch(),
                                                 None,
                                                 use_master=True)

                    db = Dashboard(rr)
                    db.add_summary(summary)
                    if os.path.exists(os.path.join(root, 'eval-log.txt')):
                        shutil.copy2(os.path.join(root, 'eval-log.txt'),
                                     machineFolder)

                    status = vcs.get_status(rr)
                    if 'unknown' in status:
                        vcs.add(rr)
                    vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
                    vcs.push(rr)
                    print "\nAuto resolve diverged report aspect success!"
                else:
                    raise e
    except:
        traceback.print_exc()
Пример #19
0
 def remove(self):
     '''
     Remove all evidence that a sandbox ever existed.
     '''
     ioutil.nuke(self.get_root())
Пример #20
0
 def clean(self):
     ioutil.nuke(self.path, contents_only=True)