Example #1
0
def build_libcxxabi(toolchain: toolchains.Toolchain, build_arch: hosts.Arch) -> Path:
    # TODO: Refactor cross_compile_configs to support per-arch queries in
    # addition to being a generator.
    for (arch, llvm_triple, defines, cflags) in \
         cross_compile_configs(toolchain.path, platform=True): # pylint: disable=not-an-iterable

        # Build only the requested arch.
        if arch != build_arch:
            continue

        logger().info('Building libcxxabi for %s', arch.value)
        defines['LIBCXXABI_LIBCXX_INCLUDES'] = utils.llvm_path('libcxx', 'include')
        defines['LIBCXXABI_ENABLE_SHARED'] = 'OFF'
        defines['CMAKE_C_FLAGS'] = ' '.join(cflags)
        defines['CMAKE_CXX_FLAGS'] = ' '.join(cflags)

        out_path = utils.out_path('lib', 'libcxxabi-' + arch.value)
        if os.path.exists(out_path):
            utils.rm_tree(out_path)

        invoke_cmake(out_path=out_path,
                     defines=defines,
                     env=dict(ORIG_ENV),
                     cmake_path=utils.llvm_path('libcxxabi'),
                     install=False)
        return Path(out_path)
    raise ValueError(f"{build_arch} is not supported.")
Example #2
0
    def _handle_lib_in_libs(self, root):
        for lib in os.listdir(root):
            if not os.path.isdir(root / lib) or lib == 'Ace3':
                continue

            embeds = [
                'CallbackHandler-1.0', 'LibStub', 'LibStub-1.0',
                'HereBeDragons'
            ]
            for p in ['libs', 'lib']:
                if os.path.exists(root / lib / p):
                    embeds.append(p)
                    embeds.append(p.capitalize())
                    break

            for embed in embeds:
                rm_tree(root / lib / embed)

            if os.path.exists(root / lib / 'embeds.xml'):
                os.remove(root / lib / 'embeds.xml')
                embeds.append('embeds.xml')

            files = ['lib.xml', f'{lib}.xml', f'{lib}.toc']
            for f in files:
                for p in [root / f, root / lib / f]:
                    if os.path.exists(p):
                        self.remove_libs_in_file(p, embeds)
Example #3
0
def extract_packaged_clang(package_path):
    # Find package to extract
    tarballs = [f for f in os.listdir(package_path) if \
                    f.endswith('.tar.bz2') and 'linux' in f]
    if len(tarballs) != 1:
        raise RuntimeError('No clang packages (.tar.bz2) found in ' +
                           package_path)

    tarball = os.path.join(package_path, tarballs[0])

    # Extract package to $OUT_DIR/extracted
    extract_dir = utils.out_path('extracted')
    if os.path.exists(extract_dir):
        utils.rm_tree(extract_dir)
    build.check_create_path(extract_dir)

    args = ['tar', '-xjC', extract_dir, '-f', tarball]
    subprocess.check_call(args)

    # Find and return a singleton subdir
    extracted = os.listdir(extract_dir)
    if len(extracted) != 1:
        raise RuntimeError('Expected one file from package.  Found: ' +
                           ' '.join(extracted))

    clang_path = os.path.join(extract_dir, extracted[0])
    if not os.path.isdir(clang_path):
        raise RuntimeError('Extracted path is not a dir: ' + clang_path)

    return clang_path
Example #4
0
    def remove_libraries_all(self, addon, lib_path: Optional[str] = None):
        """Remove all embedded libraries."""
        if not lib_path:
            for p in ['libs', 'lib']:
                path = Path('Addons') / addon / p
                if os.path.exists(path):
                    lib_path = str(p)
                    break
            else:
                return

        rm_tree(Path('AddOns') / addon / lib_path)

        # Extra library that need to be removed
        libs = [
            'embeds.xml', 'Embeds.xml', 'libs.xml', 'Libs.xml',
            'LibDataBroker-1.1.lua'
        ]
        for lib in libs:
            path = Path('AddOns') / addon / lib
            if os.path.exists(path):
                os.remove(path)

        for ext in ['toc', 'xml']:
            path = Path('AddOns') / addon
            path /= '{}.{}'.format(addon.split('/')[-1], ext)
            if os.path.exists(str(path)):
                self.remove_libs_in_file(path, libs + [lib_path])
Example #5
0
def setup_sources(source_dir, build_llvm_next):
    """Setup toolchain sources into source_dir.

    Copy toolchain/llvm-project into source_dir.
    Apply patches per the specification in
    toolchain/llvm_android/patches/PATCHES.json.  The function overwrites
    source_dir only if necessary to avoid recompiles during incremental builds.
    """

    copy_from = utils.android_path('toolchain', 'llvm-project')

    # Copy llvm source tree to a temporary directory.
    tmp_source_dir = source_dir.rstrip('/') + '.tmp'
    if os.path.exists(tmp_source_dir):
        utils.rm_tree(tmp_source_dir)

    # mkdir parent of tmp_source_dir if necessary - so we can call 'cp' below.
    tmp_source_parent = os.path.dirname(tmp_source_dir)
    if not os.path.exists(tmp_source_parent):
        os.makedirs(tmp_source_parent)

    # Use 'cp' instead of shutil.copytree.  The latter uses copystat and retains
    # timestamps from the source.  We instead use rsync below to only update
    # changed files into source_dir.  Using 'cp' will ensure all changed files
    # get a newer timestamp than files in $source_dir.
    # Note: Darwin builds don't copy symlinks with -r.  Use -R instead.
    subprocess.check_call(['cp', '-Rf', copy_from, tmp_source_dir])

    # patch source tree
    patch_dir = utils.android_path('toolchain', 'llvm_android', 'patches')
    patch_json = os.path.join(patch_dir, 'PATCHES.json')
    svn_version = android_version.get_svn_revision(build_llvm_next)
    # strip the leading 'r' and letter suffix, e.g., r377782b => 377782
    svn_version = svn_version[1:].rstrip(string.ascii_lowercase)

    apply_patches(tmp_source_dir, svn_version, patch_json, patch_dir)

    # Copy tmp_source_dir to source_dir if they are different.  This avoids
    # invalidating prior build outputs.
    if not os.path.exists(source_dir):
        os.rename(tmp_source_dir, source_dir)
    else:
        # Without a trailing '/' in $SRC, rsync copies $SRC to
        # $DST/BASENAME($SRC) instead of $DST.
        tmp_source_dir = tmp_source_dir.rstrip('/') + '/'

        # rsync to update only changed files.  Use '-c' to use checksums to find
        # if files have changed instead of only modification time and size -
        # which could have inconsistencies.  Use '--delete' to ensure files not
        # in tmp_source_dir are deleted from $source_dir.
        subprocess.check_call([
            'rsync', '-r', '--delete', '--links', '-c', tmp_source_dir,
            source_dir
        ])

        utils.rm_tree(tmp_source_dir)
Example #6
0
    def handle_bagnon(self):
        rm_tree('AddOns/Bagnon/common/LibDataBroker-1.1')
        process_file(
            'AddOns/Bagnon/AddOns/main/main.xml', lambda lines:
            [line for line in lines if 'LibDataBroker' not in line])

        self.remove_libraries([
            'AceEvent-3.0', 'AceLocale-3.0', 'CallbackHandler-1.0', 'LibStub'
        ], 'AddOns/Bagnon/common/Wildpants/libs',
                              'AddOns/Bagnon/common/Wildpants/libs/libs.xml')
Example #7
0
    def remove_libraries(self, libs, root, xml_path):
        """Remove selected embedded libraries from root and xml."""
        for lib in libs:
            rm_tree(Path(root) / lib)

        process_file(
            xml_path, lambda lines: [
                line for line in lines
                if not any(lib + '\\' in line for lib in libs)
            ])
Example #8
0
def remove_sources(copy_actions, lib_path, exe_path):
    for (action, source, dest_path) in copy_actions:
        if dest_path == "lib-path":
            destination = os.path.abspath(lib_path + "/" + source)
        elif dest_path == "exe-path":
            destination = os.path.abspath(exe_path)
        else:
            destination = dest_path
        if action == "tree":
            utils.rm_tree(destination, keep_path=True, ignore=ignore_sources)
Example #9
0
    def handle_meetinghorn(self):
        self.remove_libraries([
            'AceAddon-3.0', 'AceComm-3.0', 'AceConfig-3.0', 'AceDB-3.0',
            'AceEvent-3.0', 'AceGUI-3.0', 'AceHook-3.0', 'AceLocale-3.0',
            'AceSerializer-3.0', 'AceTimer-3.0', 'CallbackHandler-1.0',
            'LibDBIcon-1.0', 'LibDataBroker-1.1', 'LibStub'
        ], 'Addons/MeetingHorn/Libs', 'Addons/MeetingHorn/Libs/Libs.xml')

        rm_tree('Addons/MeetingHorn/Libs/tdGUI/Libs')
        self.remove_libs_in_file('Addons/MeetingHorn/Libs/tdGUI/Load.xml',
                                 ['Libs'])
Example #10
0
    def handle_goodleader(self):
        self.remove_libraries([
            'AceAddon-3.0', 'AceBucket-3.0', 'AceComm-3.0', 'AceDB-3.0',
            'AceEvent-3.0', 'AceHook-3.0', 'AceLocale-3.0',
            'AceSerializer-3.0', 'AceTimer-3.0', 'CallbackHandler-1.0',
            'LibDBIcon-1.0', 'LibDataBroker-1.1', 'LibStub'
        ], 'AddOns/GoodLeader/Libs', 'AddOns/GoodLeader/Libs/Libs.xml')

        rm_tree('Addons/GoodLeader/Libs/tdGUI/Libs')
        self.remove_libs_in_file('Addons/GoodLeader/Libs/tdGUI/Load.xml',
                                 ['Libs'])
Example #11
0
    def handle_decursive(self):
        for lib in os.listdir('AddOns/Decursive/Libs'):
            if lib == 'BugGrabber':
                continue

            rm_tree(Path('AddOns/Decursive/Libs') / lib)

        process_file(
            'AddOns/Decursive/embeds.xml', lambda lines: [
                line for line in lines
                if 'Libs' not in line or 'BugGrabber' in line
            ])
Example #12
0
    def handle_tc2(self):
        path = 'Addons/ThreatClassic2/Libs/LibThreatClassic2'
        if os.path.exists(path):
            dst = 'Addons/!!Libs/LibThreatClassic2'
            rm_tree(dst)
            shutil.copytree(path, dst)
        rm_tree('AddOns/ThreatClassic2/Libs')

        def f(lines):
            return [line for line in lines if 'Libs' not in line]

        path = 'AddOns/ThreatClassic2/ThreatClassic2.xml'
        process_file(path, f)
Example #13
0
    def handle_auctioneer(self):
        addons = ['Auc-Advanced', 'BeanCounter', 'Enchantrix', 'Informant']

        for addon in addons:
            rm_tree(Path('AddOns') / addon / 'Libs' / 'LibDataBroker')
            process_file(
                Path('AddOns') / addon / 'Libs' / 'Load.xml', lambda lines:
                [line for line in lines if 'LibDataBroker' not in line])

        rm_tree('AddOns/SlideBar/Libs')
        process_file(
            'AddOns/SlideBar/Load.xml',
            lambda lines: [line for line in lines if 'Libs' not in line])
Example #14
0
    def handle_grail(self):
        for folder in os.listdir('AddOns'):
            if 'Grail' not in folder:
                continue

            if (('NPCs' in folder or 'Quests' in folder)
                    and not folder.endswith('_')
                    and ('enUS' not in folder and 'zhCN' not in folder)):
                rm_tree(Path('AddOns') / folder)

            if ((not self.is_classic and 'classic' in folder)
                    or (self.is_classic and
                        ('retail' in folder or 'Achievements' in folder))):
                rm_tree(Path('AddOns') / folder)
Example #15
0
 def remove_target_dir(self, associated_task=None):
     if not os.path.isdir(self.info.previous_target_dir):
         log.debug("Cannot find %s" % self.info.previous_target_dir)
         return
     log.debug("Deleting %s" % self.info.previous_target_dir)
     try:
         rm_tree(self.info.previous_target_dir)
     except OSError, e:
         if e.errno == 22:
             log.exception('Unable to remove the target directory.')
             # Invalid argument - likely a corrupt file.
             cmd = spawn_command(['chkdsk', '/F'])
             cmd.communicate(input='Y%s' % os.linesep)
             raise errors.WubiCorruptionError
Example #16
0
 def remove_target_dir(self, associated_task=None):
     if not os.path.isdir(self.info.previous_target_dir):
         log.debug("Cannot find %s" % self.info.previous_target_dir)
         return
     log.debug("Deleting %s" % self.info.previous_target_dir)
     try:
         rm_tree(self.info.previous_target_dir)
     except OSError, e:
         if e.errno == 22:
             log.exception('Unable to remove the target directory.')
             # Invalid argument - likely a corrupt file.
             cmd = spawn_command(['chkdsk', '/F'])
             cmd.communicate(input='Y%s' % os.linesep)
             raise errors.WubiCorruptionError
Example #17
0
    def handle_vuhdo(self):
        self.remove_libraries([
            'AceAddon-3.0', 'AceBucket-3.0', 'AceComm-3.0', 'AceConfig-3.0',
            'AceEvent-3.0', 'AceGUI-3.0', 'AceLocale-3.0', 'AceSerializer-3.0',
            'AceTimer-3.0', 'CallbackHandler-1.0', 'LibClassicDurations',
            'LibCompress', 'LibCustomGlow-1.0', 'LibDBIcon-1.0',
            'LibDataBroker-1.1', 'LibSharedMedia-3.0', 'LibStub',
            'LibThreatClassic2', 'NickTag-1.0', 'UTF8'
        ], 'Addons/VuhDo/Libs', 'Addons/VuhDo/Libs/Libs.xml')

        if self.is_classic:
            rm_tree('Addons/Vuhdo/Libs/!LibTotemInfo/LibStub')
            self.remove_libs_in_file(
                'Addons/Vuhdo/Libs/!LibTotemInfo/embeds.xml', ['LibStub'])
        rm_tree('Addons/Vuhdo/Libs/LibBase64-1.0/LibStub')

        self.change_defaults('Addons/VuhDo/VuhDoDefaults.lua',
                             '	["SHOW_MINIMAP"] = false,')
Example #18
0
    def handle_ufp(self):
        if self.is_classic:
            rm_tree('AddOns/UnitFramesPlus_MobHealth')

            self.remove_libraries_all('UnitFramesPlus_Cooldown')

        def f(lines):
            ret = []
            minimap = False
            for line in lines:
                if 'minimap = {' in line:
                    minimap = True

                if minimap and 'button' in line:
                    ret.append('        button = 0,\n')
                    minimap = False
                else:
                    ret.append(line)
            return ret

        process_file('Addons/UnitFramesPlus/UnitFramesPlus.lua', f)
Example #19
0
    def handle_tsm(self):
        rm_tree('AddOns/TradeSkillMaster/External/EmbeddedLibs/')

        process_file(
            'AddOns/TradeSkillMaster/TradeSkillMaster.toc', lambda lines:
            [line for line in lines if 'EmbeddedLibs' not in line])
Example #20
0
 def remove_target_dir(self, associated_task=None):
     if not os.path.isdir(self.info.previous_target_dir):
         log.debug("Cannot find %s" % self.info.previous_target_dir)
         return
     log.debug("Deleting %s" % self.info.previous_target_dir)
     rm_tree(self.info.previous_target_dir)
Example #21
0
 def handle_prat(self):
     rm_tree('AddOns/Prat-3.0_Libraries')
Example #22
0
 def _rm_cmake_cache(cache_dir: Path):
     for dirpath, dirs, files in os.walk(cache_dir):
         if 'CMakeCache.txt' in files:
             os.remove(os.path.join(dirpath, 'CMakeCache.txt'))
         if 'CMakeFiles' in dirs:
             utils.rm_tree(os.path.join(dirpath, 'CMakeFiles'))
Example #23
0
def rm_cmake_cache(cacheDir):
    for dirpath, dirs, files in os.walk(cacheDir): # pylint: disable=not-an-iterable
        if 'CMakeCache.txt' in files:
            os.remove(os.path.join(dirpath, 'CMakeCache.txt'))
        if 'CMakeFiles' in dirs:
            utils.rm_tree(os.path.join(dirpath, 'CMakeFiles'))