⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 siputils.py

📁 这是关于RFC3261实现sip的源代码
💻 PY
📖 第 1 页 / 共 5 页
字号:
        # Generate the list of objects.        if self.generator in ("MSVC", "MSVC.NET", "BMAKE"):            ext = ".obj"        else:            ext = ".o"        olist = []        for f in string.split(dict["sources"]):            root, discard = os.path.splitext(f)            olist.append(root + ext)        for f in string.split(dict["moc_headers"]):            if not self._qt:                error("\"%s\" defines \"moc_headers\" for a non-Qt module." % bfname)            root, discard = os.path.splitext(f)            olist.append("moc_" + root + ext)        dict["objects"] = string.join(olist)        return dict    def clean_build_file_objects(self, mfile, build):        """Generate the clean target.        mfile is the file object.        build is the dictionary created from the build file.        """        mfile.write("\t-%s $(TARGET)\n" % self.rm)        for f in string.split(build["objects"]):            mfile.write("\t-%s %s\n" % (self.rm, f))        for f in string.split(build["moc_headers"]):            root, discard = os.path.splitext(f)            mfile.write("\t-%s moc_%s.cpp\n" % (self.rm, root))    def ready(self):        """The Makefile is now ready to be used.        """        if not self._finalised:            self.finalise()    def generate(self):        """Generate the Makefile.        """        self.ready()        if self._dir:            mfname = os.path.join(self._dir, self._makefile)        else:            mfname = self._makefile        try:            mfile = open(mfname, "w")        except IOError, detail:            error("Unable to create \"%s\": %s" % (mfname, detail))        self.generate_macros_and_rules(mfile)        self.generate_target_default(mfile)        self.generate_target_install(mfile)        if self._installs:            if type(self._installs) != types.ListType:                self._installs = [self._installs]            for src, dst in self._installs:                self.install_file(mfile, src, dst)        self.generate_target_clean(mfile)        mfile.close()    def generate_macros_and_rules(self, mfile):        """The default implementation of the macros and rules generation.        mfile is the file object.        """        mfile.write("CC = %s\n" % self.required_string("CC"))        mfile.write("CXX = %s\n" % self.required_string("CXX"))        mfile.write("LINK = %s\n" % self.required_string("LINK"))        cppflags = []        for f in self.optional_list("DEFINES"):            cppflags.append("-D" + f)        for f in self.optional_list("INCDIR"):            cppflags.append("-I" + _quote(f))        libs = []        if self.generator in ("MSVC", "MSVC.NET"):            libdir_prefix = "/LIBPATH:"        else:            libdir_prefix = "-L"        for ld in self.optional_list("LIBDIR"):            if sys.platform == "darwin" and self.config.qt_framework:                fflag = "-F" + _quote(ld)                libs.append(fflag)                cppflags.append(fflag)            libs.append(libdir_prefix + _quote(ld))        libs.extend(self.optional_list("LIBS"))        mfile.write("CPPFLAGS = %s\n" % string.join(cppflags))        mfile.write("CFLAGS = %s\n" % self.optional_string("CFLAGS"))        mfile.write("CXXFLAGS = %s\n" % self.optional_string("CXXFLAGS"))        mfile.write("LFLAGS = %s\n" % self.optional_string("LFLAGS"))        mfile.write("LIBS = %s\n" % string.join(libs))        if self._qt:            mfile.write("MOC = %s\n" % _quote(self.required_string("MOC")))        # These probably don't matter.        if self.generator == "MINGW":            mfile.write(".SUFFIXES: .cpp .cxx .cc .C .c\n\n")        elif self.generator == "UNIX":            mfile.write(".SUFFIXES: .c .o .cpp .cc .cxx .C\n\n")        else:            mfile.write(".SUFFIXES: .c .cpp .cc .cxx .C\n\n")        if self.generator in ("MSVC", "MSVC.NET"):            mfile.write("""{.}.cpp{}.obj::\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<\t$<<<{.}.cc{}.obj::\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<\t$<<<{.}.cxx{}.obj::\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<\t$<<<{.}.C{}.obj::\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<<\t$<<<{.}.c{}.obj::\t$(CC) -c $(CFLAGS) $(CPPFLAGS) -Fo @<<\t$<<<""")        elif self.generator == "BMAKE":            mfile.write(""".cpp.obj:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $<.cc.obj:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $<.cxx.obj:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $<.C.obj:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $<.c.obj:\t$(CC) -c $(CFLAGS) $(CPPFLAGS) -o$@ $<""")        else:            mfile.write(""".cpp.o:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<.cc.o:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<.cxx.o:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<.C.o:\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<.c.o:\t$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<""")    def generate_target_default(self, mfile):        """The default implementation of the default target.        mfile is the file object.        """        mfile.write("\nall:\n")    def generate_target_install(self, mfile):        """The default implementation of the install target.        mfile is the file object.        """        mfile.write("\ninstall:\n")    def generate_target_clean(self, mfile):        """The default implementation of the clean target.        mfile is the file object.        """        mfile.write("\nclean:\n")    def install_file(self, mfile, src, dst, strip=0):        """Install one or more files in a directory.        mfile is the file object.        src is the name of a single file to install, or the list of a number of        files to install.        dst is the name of the destination directory.        strip is set if the files should be stripped after been installed.        """        # Help package builders.        if self.generator == "UNIX":            dst = "$(DESTDIR)" + dst        mfile.write("\t@%s %s " % (self.chkdir, _quote(dst)))        if self.generator == "UNIX":            mfile.write("|| ")        mfile.write("%s %s\n" % (self.mkdir, _quote(dst)))        if type(src) != types.ListType:            src = [src]        # Get the strip command if needed.        if strip:            strip_cmd = self.optional_string("STRIP")            if not strip_cmd:                strip = 0        for sf in src:            target = _quote(os.path.join(dst, os.path.basename(sf)))            mfile.write("\t%s %s %s\n" % (self.copy, _quote(sf), target))            if strip:                mfile.write("\t%s %s\n" % (strip_cmd, target))class ParentMakefile(Makefile):    """The class that represents a parent Makefile.    """    def __init__(self, configuration, subdirs, dir=None, makefile="Makefile",                 installs=None):        """Initialise an instance of a parent Makefile.        subdirs is the sequence of subdirectories.        """        Makefile.__init__(self, configuration, dir=dir, makefile=makefile, installs=installs)        self._subdirs = subdirs    def generate_macros_and_rules(self, mfile):        """Generate the macros and rules.        mfile is the file object.        """        # We don't want them.        pass    def generate_target_default(self, mfile):        """Generate the default target.        mfile is the file object.        """        self._subdir_target(mfile)    def generate_target_install(self, mfile):        """Generate the install target.        mfile is the file object.        """        self._subdir_target(mfile, "install")    def generate_target_clean(self, mfile):        """Generate the clean target.        mfile is the file object.        """        self._subdir_target(mfile, "clean")    def _subdir_target(self, mfile, target="all"):        """Create a target for a list of sub-directories.        mfile is the file object.        target is the name of the target.        """        if target == "all":            tname = ""        else:            tname = " " + target        mfile.write("\n" + target + ":\n")        for d in self._subdirs:            if self.generator == "MINGW":                mfile.write("\t@$(MAKE) -C %s%s\n" % (d, tname))            elif self.generator == "UNIX":                mfile.write("\t@(cd %s; $(MAKE)%s)\n" % (d, tname))            else:                mfile.write("\tcd %s\n" % d)                mfile.write("\t$(MAKE)%s\n" % tname)                mfile.write("\t@cd ..\n")class PythonModuleMakefile(Makefile):    """The class that represents a Python module Makefile.    """    def __init__(self, configuration, dstdir, srcdir=None, dir=None,                 makefile="Makefile", installs=None):        """Initialise an instance of a parent Makefile.        dstdir is the name of the directory where the module's Python code will        be installed.        srcdir is the name of the directory (relative to the directory in which        the Makefile will be created) containing the module's Python code.  It        defaults to the same directory.        """        Makefile.__init__(self, configuration, dir=dir, makefile=makefile, installs=installs)        if not srcdir:            srcdir = "."        if dir:            self._moddir = os.path.join(dir, srcdir)        else:            self._moddir = srcdir        self._srcdir = srcdir        self._dstdir = dstdir    def generate_macros_and_rules(self, mfile):        """Generate the macros and rules.        mfile is the file object.        """        # We don't want them.        pass    def generate_target_install(self, mfile):        """Generate the install target.        mfile is the file object.        """        Makefile.generate_target_install(self, mfile)        os.path.walk(self._moddir, self._visit, mfile)    def _visit(self, mfile, dirname, names):        """Install the files from a particular directory.        mfile is the file object.        dirname is the sub-directory.        names is the list of files to install from the sub-directory.        """        tail = dirname[len(self._moddir):]        flist = []        for f in names:            # Ignore certain files.            if f in ("Makefile", ):                continue            if os.path.isfile(os.path.join(dirname, f)):                flist.append(os.path.join(self._srcdir + tail, f))        self.install_file(mfile, flist, self._dstdir + tail)class ModuleMakefile(Makefile):    """The class that represents a Python extension module Makefile    """    def __init__(self, configuration, build_file, install_dir=None, static=0,                 console=0, qt=0, opengl=0, threaded=0, warnings=1, debug=0,                 dir=None, makefile="Makefile", installs=None, strip=1,                 export_all=0):        """Initialise an instance of a module Makefile.        build_file is the file containing the target specific information.  If        it is a dictionary instead then its contents are validated.        install_dir is the directory the target will be installed in.        static is set if the module should be built as a static library.        strip is set if the module should be stripped of unneeded symbols when        installed.  The default is 1.        export_all is set if all the module's symbols should be exported rather        than just the module's initialisation function.  Exporting all symbols        increases the size of the module and slows down module load times but        may avoid problems with modules that use exceptions.  The default is 0.        """

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -