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

📄 siputils.py

📁 这是关于RFC3261实现sip的源代码
💻 PY
📖 第 1 页 / 共 5 页
字号:
                cxxflags_rtti = "CXXFLAGS_RTTI_OFF"            cflags.extend(self.optional_list(cflags_rtti))            cxxflags.extend(self.optional_list(cxxflags_rtti))            if win_stl:                cflags_stl = "CFLAGS_STL_ON"                cxxflags_stl = "CXXFLAGS_STL_ON"            else:                cflags_stl = "CFLAGS_STL_OFF"                cxxflags_stl = "CXXFLAGS_STL_OFF"            cflags.extend(self.optional_list(cflags_stl))            cxxflags.extend(self.optional_list(cxxflags_stl))        if self._debug:            if win_shared:                cflags_mt = "CFLAGS_MT_DLLDBG"                cxxflags_mt = "CXXFLAGS_MT_DLLDBG"            else:                cflags_mt = "CFLAGS_MT_DBG"                cxxflags_mt = "CXXFLAGS_MT_DBG"            cflags_debug = "CFLAGS_DEBUG"            cxxflags_debug = "CXXFLAGS_DEBUG"            lflags_debug = "LFLAGS_DEBUG"        else:            if win_shared:                cflags_mt = "CFLAGS_MT_DLL"                cxxflags_mt = "CXXFLAGS_MT_DLL"            else:                cflags_mt = "CFLAGS_MT"                cxxflags_mt = "CXXFLAGS_MT"            cflags_debug = "CFLAGS_RELEASE"            cxxflags_debug = "CXXFLAGS_RELEASE"            lflags_debug = "LFLAGS_RELEASE"        if self.generator in ("MSVC", "MSVC.NET", "BMAKE"):            if self._threaded:                cflags.extend(self.optional_list(cflags_mt))                cxxflags.extend(self.optional_list(cxxflags_mt))            if self.console:                cflags.extend(self.optional_list("CFLAGS_CONSOLE"))                cxxflags.extend(self.optional_list("CXXFLAGS_CONSOLE"))        cflags.extend(self.optional_list(cflags_debug))        cxxflags.extend(self.optional_list(cxxflags_debug))        lflags.extend(self.optional_list(lflags_debug))        if self._warnings:            cflags_warn = "CFLAGS_WARN_ON"            cxxflags_warn = "CXXFLAGS_WARN_ON"        else:            cflags_warn = "CFLAGS_WARN_OFF"            cxxflags_warn = "CXXFLAGS_WARN_OFF"        cflags.extend(self.optional_list(cflags_warn))        cxxflags.extend(self.optional_list(cxxflags_warn))        if self._threaded:            cflags.extend(self.optional_list("CFLAGS_THREAD"))            cxxflags.extend(self.optional_list("CXXFLAGS_THREAD"))            lflags.extend(self.optional_list("LFLAGS_THREAD"))        if self._qt:            if self.generator != "UNIX" and win_shared:                defines.append("QT_DLL")            if not self._debug:                defines.append("QT_NO_DEBUG")            if self.config.qt_version >= 0x040000:                for mod in self._qt:                    if mod == "QtCore":                        defines.append("QT_CORE_LIB")                    elif mod == "QtGui":                        defines.append("QT_GUI_LIB")                    elif mod == "QtNetwork":                        defines.append("QT_NETWORK_LIB")                    elif mod == "QtOpenGL":                        defines.append("QT_OPENGL_LIB")                    elif mod == "QtSql":                        defines.append("QT_SQL_LIB")                    elif mod == "QtXml":                        defines.append("QT_XML_LIB")            elif self._threaded:                defines.append("QT_THREAD_SUPPORT")            # Handle library directories.            libdir_qt = self.optional_list("LIBDIR_QT")            libdir.extend(libdir_qt)            rpaths.extend(libdir_qt)            if self.config.qt_version >= 0x040000:                # For Windows: the macros that define the dependencies on                # Windows libraries.                wdepmap = {                    "QtCore":       "LIBS_CORE",                    "QtGui":        "LIBS_GUI",                    "QtNetwork":    "LIBS_NETWORK",                    "QtOpenGL":     "LIBS_OPENGL"                }                # For Windows: the dependencies between Qt libraries.                qdepmap = {                    "QtAssistant":  ("QtCore", "QtGui", "QtNetwork"),                    "QtGui":        ("QtCore", ),                    "QtNetwork":    ("QtCore", ),                    "QtOpenGL":     ("QtCore", "QtGui"),                    "QtSql":        ("QtCore", ),                    "QtSvg":        ("QtCore", "QtGui", "QtXml"),                    "QtXml":        ("QtCore", )                }                # The QtSql .prl file doesn't include QtGui as a dependency (at                # least on Linux) so we explcitly set the dependency here for                # everything.                if "QtSql" in self._qt and "QtGui" not in self._qt:                    self._qt.append("QtGui")                for mod in self._qt:                    lib = self._qt4_module_to_lib(mod)                    libs.append(self.platform_lib(lib, self._is_framework(mod)))                    if sys.platform == "win32":                        # On Windows the dependent libraries seem to be in                        # qmake.conf rather than the .prl file and the                        # inter-dependencies between Qt libraries don't seem to                        # be anywhere.                        deps = _UniqueList()                        if mod in wdepmap.keys():                            deps.extend(self.optional_list(wdepmap[mod]))                        if mod in qdepmap.keys():                            for qdep in qdepmap[mod]:                                # Ignore the dependency if it is explicitly                                # linked.                                if qdep not in self._qt:                                    libs.append(self.platform_lib(self._qt4_module_to_lib(qdep)))                                    if qdep in wdepmap.keys():                                        deps.extend(self.optional_list(wdepmap[qdep]))                        libs.extend(deps.as_list())                    else:                        libs.extend(self._dependent_libs(lib))            else:                # Windows needs the version number appended if Qt is a DLL.                qt_lib = self.config.qt_lib                if self.generator in ("MSVC", "MSVC.NET", "BMAKE") and win_shared:                    qt_lib = qt_lib + string.replace(version_to_string(self.config.qt_version), ".", "")                    if self.config.qt_edition == "non-commercial":                        qt_lib = qt_lib + "nc"                libs.append(self.platform_lib(qt_lib, self.config.qt_framework))                libs.extend(self._dependent_libs(self.config.qt_lib))            # Handle header directories.            try:                specd_base = self.config.qt_data_dir            except AttributeError:                specd_base = self.config.qt_dir            specd = os.path.join(specd_base, "mkspecs", "default")            if not os.access(specd, os.F_OK):                specd = os.path.join(specd_base, "mkspecs", self.config.platform)            incdir.append(specd)            qtincdir = self.optional_list("INCDIR_QT")            if qtincdir:                incdir.extend(qtincdir)                if self.config.qt_version >= 0x040000:                    for mod in self._qt:                        if self._is_framework(mod):                            incdir.append(os.path.join(libdir_qt[0], mod + ".framework", "Headers"))                        else:                            incdir.append(os.path.join(qtincdir[0], mod))        if self._opengl:            incdir.extend(self.optional_list("INCDIR_OPENGL"))            lflags.extend(self.optional_list("LFLAGS_OPENGL"))            libdir.extend(self.optional_list("LIBDIR_OPENGL"))            libs.extend(self.optional_list("LIBS_OPENGL"))        if self._qt or self._opengl:            incdir.extend(self.optional_list("INCDIR_X11"))            libdir.extend(self.optional_list("LIBDIR_X11"))            libs.extend(self.optional_list("LIBS_X11"))        if self._threaded:            libs.extend(self.optional_list("LIBS_THREAD"))            libs.extend(self.optional_list("LIBS_RTMT"))        else:            libs.extend(self.optional_list("LIBS_RT"))        if self.console:            libs.extend(self.optional_list("LIBS_CONSOLE"))        libs.extend(self.optional_list("LIBS_WINDOWS"))        lflags.extend(self._platform_rpaths(rpaths.as_list()))        # Save the transformed values.        self.CFLAGS.set(cflags)        self.CXXFLAGS.set(cxxflags)        self.DEFINES.set(defines)        self.INCDIR.set(incdir)        self.LFLAGS.set(lflags)        self.LIBDIR.set(libdir)        self.LIBS.set(libs)        # Don't do it again because it has side effects.        self._finalised = 1    def _is_framework(self, mod):        """Return true if the given Qt module is a framework.        """        return (self.config.qt_framework and mod != "QtAssistant")    def _qt4_module_to_lib(self, mname):        """Return the name of the Qt4 library corresponding to a module.        mname is the name of the module.        """        if mname == "QtAssistant":            lib = "QtAssistantClient"        else:            lib = mname        if self._debug:            if sys.platform == "win32":                lib = lib + "d"            else:                lib = lib + "_debug"        if sys.platform == "win32" and mname in ("QtCore", "QtGui", "QtNetwork", "QtOpenGL", "QtSql", "QtSvg", "QtXml"):            lib = lib + "4"        return lib    def optional_list(self, name):        """Return an optional Makefile macro as a list.        name is the name of the macro.        """        return self.__dict__[name].as_list()    def optional_string(self, name, default=""):        """Return an optional Makefile macro as a string.        name is the name of the macro.        default is the default value        """        s = string.join(self.optional_list(name))        if not s:            s = default        return s    def required_string(self, name):        """Return a required Makefile macro as a string.        name is the name of the macro.        """        s = self.optional_string(name)        if not s:            raise ValueError, "\"%s\" must have a non-empty value" % name        return s    def _platform_rpaths(self, rpaths):        """Return a list of platform specific rpath flags.        rpaths is the cannonical list of rpaths.        """        flags = []        prefix = self.optional_string("RPATH")        if prefix:            for r in rpaths:                flags.append(_quote(prefix + r))        return flags    def platform_lib(self, clib, framework=0):        """Return a library name in platform specific form.        clib is the library name in cannonical form.        framework is set of the library is implemented as a MacOS framework.        """        if self.generator in ("MSVC", "MSVC.NET", "BMAKE"):            plib = clib + ".lib"        elif sys.platform == "darwin" and framework:            plib = "-framework " + clib        else:            plib = "-l" + clib        return plib    def _dependent_libs(self, clib):        """Return a list of additional libraries (in platform specific form)        that must be linked with a library.        clib is the library name in cannonical form.        """        prl_libs = []        if self.generator in ("MSVC", "MSVC.NET", "BMAKE"):            prl_name = os.path.join(self.config.qt_lib_dir, clib + ".prl")        else:            prl_name = os.path.join(self.config.qt_lib_dir, "lib" + clib + ".prl")        if os.access(prl_name, os.F_OK):            try:                f = open(prl_name, "r")            except IOError, detail:                error("Unable to open \"%s\": %s" % (prl_name, detail))            line = f.readline()            while line:                line = string.strip(line)                if line and line[0] != "#":                    eq = string.find(line, "=")                    if eq > 0 and string.strip(line[:eq]) == "QMAKE_PRL_LIBS":                        prl_libs = string.split(line[eq + 1:])                        break                line = f.readline()            f.close()        return prl_libs    def parse_build_file(self, filename):        """        Parse a build file and return the corresponding dictionary.        filename is the name of the build file.  If it is a dictionary instead        then its contents are validated.        """        if type(filename) is types.DictType:            bfname = "dictionary"            dict = filename        else:            if self._dir:                bfname = os.path.join(self._dir, filename)            else:                bfname = filename            dict = {}            try:                f = open(bfname, "r")            except IOError, detail:                error("Unable to open \"%s\": %s" % (bfname, detail))            line_nr = 1            line = f.readline()            while line:                line = string.strip(line)                if line and line[0] != "#":                    eq = string.find(line, "=")                    if eq <= 0:                        error("\"%s\" line %d: Line must be in the form 'name = value value...'." % (bfname, line_nr))                    dict[string.strip(line[:eq])] = string.strip(line[eq + 1:])                line_nr = line_nr + 1                line = f.readline()            f.close()        # Check the compulsory values.        for i in ("target", "sources"):            try:                dict[i]            except KeyError:                error("\"%s\" is missing from \"%s\"." % (i, bfname))        # Get the optional values.        for i in ("headers", "moc_headers"):            try:                dict[i]            except KeyError:                dict[i] = ""

⌨️ 快捷键说明

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