示例#1
0
    def co_init_cache(self):
        if self.qvc is not None:
            print("Multiple QVC initialization " + self.src_path)
            self.qvc = None

        qvc_path = self.qvc_path = join(self.build_path, self.qvc_file_name)

        qemu_heuristic_hash = calculate_qh_hash()

        yield True

        if not isfile(qvc_path):
            self.qvc = QemuVersionCache()

            # Check out Qemu source to a temporary directory and analyze it
            # there. This avoids problems with user changes in main working
            # directory.

            print("Checking out temporary source tree...")

            # Note. Alternatively, checking out can be performed without
            # cloning. Instead, a magic might be casted on GIT_DIR and
            # GIT_WORK_TREE environment variables. But, this approach resets
            # staged files in src_path repository which can be inconvenient
            # for a user.
            tmp_repo = fast_repo_clone(self.repo, self.commit_sha, "qdt-qemu")
            tmp_work_dir = tmp_repo.working_tree_dir

            print("Temporary source tree: %s" % tmp_work_dir)

            # make new QVC active and begin construction
            prev_qvc = self.qvc.use()
            for path, recursive in self.include_paths:
                yield Header.co_build_inclusions(join(tmp_work_dir, path),
                                                 recursive)

            self.qvc.list_headers = self.qvc.stc.create_header_db()

            rmtree(tmp_work_dir)

            yield self.co_init_device_tree()

            yield self.co_gen_known_targets()

            # gen version description
            yield self.qvc.co_computing_parameters(self.repo, self.commit_sha)
            self.qvc.version_desc[QVD_QH_HASH] = qemu_heuristic_hash

            # Search for PCI Ids
            PCIClassification.build()

            yield True

            pythonize(self.qvc, qvc_path)
        else:
            self.load_cache()
            # make just loaded QVC active
            prev_qvc = self.qvc.use()

            if self.qvc.list_headers is not None:
                yield True

                yield self.qvc.stc.co_load_header_db(self.qvc.list_headers)

            yield True

            # verify that the version_desc is not outdated
            is_outdated = False
            try:
                checksum = self.qvc.version_desc[QVD_QH_HASH]
            except KeyError:
                is_outdated = True
            else:
                if not checksum == qemu_heuristic_hash:
                    is_outdated = True
            if is_outdated:
                yield self.qvc.co_computing_parameters(self.repo,
                                                       self.commit_sha)
                self.qvc.version_desc[QVD_QH_HASH] = qemu_heuristic_hash

            dt = self.qvc.device_tree
            if dt:
                # Targets to be added to the cache
                new_targets = self.softmmu_targets - dt.arches
                has_new_target = len(new_targets) > 0
            else:
                new_targets = self.softmmu_targets
                has_new_target = True

            if has_new_target:
                yield self.co_init_device_tree(new_targets)

            if is_outdated or has_new_target:
                pythonize(self.qvc, qvc_path)

        yield True

        # set Qemu version heuristics according to current version
        initialize_version(self.qvc.version_desc)

        yield True

        # initialize Qemu types in QVC
        get_vp()["qemu types definer"]()
        get_vp()["msi_init type definer"]()

        if prev_qvc is not None:
            prev_qvc.use()

        self.qvc_is_ready = True
示例#2
0
    def co_init_cache(self):
        if self.qvc is not None:
            raise MultipleQVCInitialization(self.src_path)

        qvc_file_name = u"qvc_" + self.commit_sha + u".py"
        qvc_path = self.qvc_path = join(self.build_path, qvc_file_name)

        qemu_heuristic_hash = calculate_qh_hash()

        yield True

        if not isfile(qvc_path):
            yield self.co_check_untracked_files()

            self.qvc = QemuVersionCache()

            # make new QVC active and begin construction
            prev_qvc = self.qvc.use()
            for path in self.include_paths:
                yield Header.co_build_inclusions(path)

            self.qvc.list_headers = self.qvc.stc.create_header_db()

            yield self.co_check_modified_files()

            yield self.co_gen_device_tree()

            # gen version description
            yield self.qvc.co_computing_parameters(self.repo)
            self.qvc.version_desc[QVD_QH_HASH] = qemu_heuristic_hash

            # Search for PCI Ids
            PCIClassification.build()

            yield True

            PyGenerator().serialize(open(qvc_path, "wb"), self.qvc)
        else:
            self.load_cache()
            # make just loaded QVC active
            prev_qvc = self.qvc.use()

            if self.qvc.list_headers is not None:
                yield True

                self.qvc.stc.load_header_db(self.qvc.list_headers)

            yield True

            # verify that the version_desc is not outdated
            is_outdated = False
            try:
                checksum = self.qvc.version_desc[QVD_QH_HASH]
            except KeyError:
                is_outdated = True
            else:
                if not checksum == qemu_heuristic_hash:
                    is_outdated = True
            if is_outdated:
                remove_file(qvc_path)
                yield self.qvc.co_computing_parameters(self.repo)
                self.qvc.version_desc[QVD_QH_HASH] = qemu_heuristic_hash
                PyGenerator().serialize(open(qvc_path, "wb"), self.qvc)

        yield True

        # set Qemu version heuristics according to current version
        initialize_version(self.qvc.version_desc)

        yield True

        # initialize Qemu types in QVC
        get_vp()["qemu types definer"]()
        get_vp()["msi_init type definer"]()

        if prev_qvc is not None:
            prev_qvc.use()

        self.qvc_is_ready = True