Ejemplo n.º 1
0
    def apply_user_defaults(self, tool):
        if tool in sipbuild.Option.BUILD_TOOLS:
            if self.qmake is None:
                self.qmake = shutil.which("qmake-qt5")
                if not self.qmake:
                    self.qmake = shutil.which("qmake")

            if not self.qmake:
                raise sipbuild.UserException(
                    "Please specify a valid qmake executable")

        super().apply_user_defaults(tool)
Ejemplo n.º 2
0
    def build_project(self, target_dir, *, wheel_tag=None):
        installed = []
        sub_dirs = []

        for buildable in self.project.buildables:
            if isinstance(buildable, sipbuild.BuildableModule):
                self._gen_module_pro_file(buildable, target_dir, installed)
            elif type(buildable) is sipbuild.Buildable:
                for installable in buildable.installables:
                    installable.install(target_dir,
                                        installed,
                                        do_install=False)
            else:
                raise sipbuild.UserException(
                    "RpcApiBuilder cannot build '{0}' buildables".format(
                        type(buildable).__name__))

            sub_dirs.append(buildable.name)

        self._gen_sip_project(target_dir, sub_dirs, installed)

        self.project.progress("Generating the top-level project")

        with open(self.project.build_dir + "/" + self.project.name + ".pro",
                  "w+") as f:
            f.write("TEMPLATE = subdirs\n")
            f.write("CONFIG += ordered\n\n")
            f.write("SUBDIRS = %s\n\n" % ' '.join(sub_dirs))

            for installable in self.project.installables:
                self._install(f, installable, target_dir, installed)

            py_subdir = os.path.join(target_dir, self.project.name)
            sip_py = sipbuild.Installable("sip_py", target_subdir=py_subdir)
            py_dir = os.path.join(self.project.root_dir, "py")
            sip_py_files = [(py_dir + "/" + f) for f in os.listdir(py_dir)
                            if f.endswith(".py") and f != "__init__.py"]
            sip_py.files.extend(sip_py_files)
            self._install(f, sip_py, target_dir, installed)

            fake_root = os.path.join(self.project.build_dir, self.project.name)
            for py in sip_py.files:
                shutil.copy(py, fake_root)
            shutil.copy(os.path.join(py_dir, "__init__.py"), fake_root)

            # for distinfo
            inventory_file = self.project.build_dir + "/inventory.txt"
            with open(inventory_file, "w+") as inventory:
                inventory.write('\n'.join(installed))
                inventory.write('\n')

            distinfo = [
                "sip-distinfo", "--project-root", self.project.root_dir,
                "--generator",
                os.path.basename(sys.argv[0]), "--prefix",
                '\\"$(INSTALL_ROOT)\\"', "--inventory", inventory_file
            ]

            if wheel_tag:
                distinfo.append("--wheel-tag")
                distinfo.append(wheel_tag)

            distinfo.append(self.project.get_distinfo_dir(target_dir))

            f.write("distinfo.extra = %s\n" % ' '.join(distinfo))
            f.write("distinfo.path = %s\n" % target_dir)
            f.write("INSTALLS += distinfo\n")

        old_dir = os.getcwd()
        os.chdir(self.project.build_dir)
        self.project.run_command(
            [self.qmake, "-recursive", self.project.name + ".pro"], fatal=True)

        self.project.progress("Compiling the project")
        self._run_make()
        os.chdir(old_dir)
Ejemplo n.º 3
0
 def build_executable(self, buildable, *, fatal=True):
     raise sipbuild.UserException("RpcApiBuilder cannot build executables")