示例#1
0
    def countValidLibraryBinaries(self, buildfolder, arch, stdlib):
        filesfound = 0

        for lib in self.buildconfig.staticliblink:
            filepath = os.path.join(buildfolder, f'lib{lib}.a')
            if os.path.exists(filepath):
                bininfo = BinaryInfo(self.logger, buildfolder, filepath)
                cxxinfo = bininfo.cxx_info_from_binary()
                if (stdlib == "") or (stdlib == "libc++"
                                      and not cxxinfo['has_maybecxx11abi']):
                    if arch == "":
                        filesfound += 1
                    if arch == "x86" and 'ELF32' in bininfo.readelf_header_details:
                        filesfound += 1
                    elif arch == "x86_64" and 'ELF64' in bininfo.readelf_header_details:
                        filesfound += 1
            else:
                self.logger.debug(f'lib{lib}.a not found')

        for lib in self.buildconfig.sharedliblink:
            filepath = os.path.join(buildfolder, f'lib{lib}.so')
            bininfo = BinaryInfo(self.logger, buildfolder, filepath)
            if (stdlib == "" and 'libstdc++.so' in bininfo.ldd_details) or (
                    stdlib != "" and f'{stdlib}.so' in bininfo.ldd_details):
                if arch == "":
                    filesfound += 1
                elif arch == "x86" and 'ELF32' in bininfo.readelf_header_details:
                    filesfound += 1
                elif arch == "x86_64" and 'ELF64' in bininfo.readelf_header_details:
                    filesfound += 1

        return filesfound
示例#2
0
    def executeconanscript(self, buildfolder, arch, stdlib):
        filesfound = 0

        for lib in self.buildconfig.staticliblink:
            filepath = os.path.join(buildfolder, f'lib{lib}.a')
            if os.path.exists(filepath):
                bininfo = BinaryInfo(self.logger, buildfolder, filepath)
                cxxinfo = bininfo.cxx_info_from_binary()
                if (stdlib == "") or (stdlib == "libc++"
                                      and not cxxinfo['has_maybecxx11abi']):
                    if arch == "":
                        filesfound += 1
                    if arch == "x86" and 'ELF32' in bininfo.readelf_header_details:
                        filesfound += 1
                    elif arch == "x86_64" and 'ELF64' in bininfo.readelf_header_details:
                        filesfound += 1
            else:
                self.logger.debug(f'lib{lib}.a not found')

        for lib in self.buildconfig.sharedliblink:
            filepath = os.path.join(buildfolder, f'lib{lib}.so')
            bininfo = BinaryInfo(self.logger, buildfolder, filepath)
            if (stdlib == "" and 'libstdc++.so' in bininfo.ldd_details) or (
                    stdlib != "" and f'{stdlib}.so' in bininfo.ldd_details):
                if arch == "":
                    filesfound += 1
                elif arch == "x86" and 'ELF32' in bininfo.readelf_header_details:
                    filesfound += 1
                elif arch == "x86_64" and 'ELF64' in bininfo.readelf_header_details:
                    filesfound += 1

        if filesfound != 0:
            if subprocess.call(['./conanexport.sh'], cwd=buildfolder) == 0:
                self.logger.info('Export succesful')
                return BuildStatus.Ok
            else:
                return BuildStatus.Failed
        else:
            self.logger.info('No binaries found to export')
            return BuildStatus.Failed
示例#3
0
    def set_as_uploaded(self, buildfolder):
        conanhash = self.get_conan_hash(buildfolder)
        if conanhash is None:
            raise RuntimeError(
                f'Error determining conan hash in {buildfolder}')

        self.logger.info(f'commithash: {conanhash}')

        annotations = self.get_build_annotations(buildfolder)
        if 'commithash' not in annotations:
            self.upload_builds()
        annotations['commithash'] = self.get_commit_hash()

        for lib in itertools.chain(self.buildconfig.staticliblink,
                                   self.buildconfig.sharedliblink):
            # TODO - this is the same as the original code but I wonder if this needs to be *.so for shared?
            if os.path.exists(os.path.join(buildfolder, f'lib{lib}.a')):
                bininfo = BinaryInfo(self.logger, buildfolder,
                                     os.path.join(buildfolder, f'lib{lib}.a'))
                libinfo = bininfo.cxx_info_from_binary()
                archinfo = bininfo.arch_info_from_binary()
                annotations['cxx11'] = libinfo['has_maybecxx11abi']
                annotations['machine'] = archinfo['elf_machine']
                annotations['osabi'] = archinfo['elf_osabi']

        self.logger.info(annotations)

        headers = {
            "Content-Type": "application/json",
            "Authorization": "Bearer " + self.conanserverproxy_token
        }

        url = f'{conanserver_url}/annotations/{self.libname}/{self.target_name}/{conanhash}'
        request = requests.post(url,
                                data=json.dumps(annotations),
                                headers=headers)
        if not request.ok:
            raise RuntimeError(f'Post failure for {url}: {request}')