main.py

来自「编译工具」· Python 代码 · 共 517 行 · 第 1/2 页

PY
517
字号
#!/usr/bin/env python# -*- python -*-#                           Package   : omniidl# main.py                   Created on: 1999/11/05#			    Author    : Duncan Grisby (dpg1)##    Copyright (C) 1999 AT&T Laboratories Cambridge##  This file is part of omniidl.##  omniidl is free software; you can redistribute it and/or modify it#  under the terms of the GNU General Public License as published by#  the Free Software Foundation; either version 2 of the License, or#  (at your option) any later version.##  This program is distributed in the hope that it will be useful,#  but WITHOUT ANY WARRANTY; without even the implied warranty of#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU#  General Public License for more details.##  You should have received a copy of the GNU General Public License#  along with this program; if not, write to the Free Software#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA#  02111-1307, USA.## Description:#   #   IDL compiler main function# $Id: main.py,v 1.17.2.15 2004/10/17 20:14:35 dgrisby Exp $# $Log: main.py,v $# Revision 1.17.2.15  2004/10/17 20:14:35  dgrisby# Updated support for OpenVMS. Many thanks to Bruce Visscher.## Revision 1.17.2.14  2004/07/01 19:17:42  dgrisby# Cope with spaces in -I arguments.## Revision 1.17.2.13  2002/12/19 13:55:14  dgrisby# Don't try to delete non-existent file when no preprocessor.## Revision 1.17.2.12  2002/10/28 12:20:45  dgrisby# Editing mishap.## Revision 1.17.2.11  2002/10/28 11:56:50  dgrisby# Work around VC++ 7 problem with FILE* change.## Revision 1.17.2.10  2002/06/05 22:26:32  dgrisby# Cope with spaces in paths to IDL files.## Revision 1.17.2.9  2002/04/25 23:12:44  dgrisby# Bug with invalid omniidl option reporting.## Revision 1.17.2.8  2002/04/25 20:33:20  dgrisby# Better job of looking for omnicpp.## Revision 1.17.2.7  2002/03/13 17:41:42  dpg1# omniidl had problems finding omnicpp on Windows.## Revision 1.17.2.6  2002/02/18 11:59:23  dpg1# Full autoconf support.## Revision 1.17.2.5  2001/11/14 17:13:44  dpg1# Long double support.## Revision 1.17.2.4  2001/10/17 16:48:35  dpg1# Minor error message tweaks## Revision 1.17.2.3  2000/12/05 17:45:22  dpg1# omniidl case sensitivity updates from omni3_develop.## Revision 1.17.2.2  2000/10/10 10:18:54  dpg1# Update omniidl front-end from omni3_develop.## Revision 1.15.2.17  2000/09/11 14:36:50  dpg1# New -T option to work around Win98 pipe problems.## Revision 1.15.2.16  2000/09/06 11:20:50  dpg1# Support for Python 1.6 and 2.0b1.## [...truncated...]#"""IDL Compiler front-end main function"""import sysif sys.hexversion < 0x10502f0:    sys.stderr.write("\n\n")    sys.stderr.write("omniidl: WARNING!!\n\n")    sys.stderr.write("omniidl: Python version 1.5.2 or later is required.\n")    sys.stderr.write("omniidl: " + sys.executable + " is version " + \                     sys.version + "\n")    sys.stderr.write("omniidl: Execution is likely to fail.\n")    sys.stderr.write("\n\n\n")    sys.stderr.flush()import _omniidlimport getopt, os, os.path, stringimport idlast, idltypecmdname = "omniidl"StringType = type("")def version():    print "omniidl version 1.0"def usage():    global backends    print "\nUsage:", cmdname, "-b<back_end> [flags] file1 file2 ..."    print """The supported flags are:  -Dname[=value]  Define name for preprocessor  -Uname          Undefine name for preprocessor  -Idir           Include dir in search path for preprocessor  -E              Run preprocessor only, print on stdout  -Ycmd           Set command for the preprocessor  -N              Do not run preprocessor  -P              Add defines relevant to platform dependencies (internal use)  -T              Use a temporary file, not a pipe, for preprocessor output  -Wparg[,arg...] Send args to the preprocessor  -bback_end      Select a back-end to be used. More than one permitted  -Wbarg[,arg...] Send args to the back-end  -nf             Do not warn about unresolved forward declarations  -nc             Do not treat identifiers differing only in case as an error  -k              Comments after declarations are kept for the back-ends  -K              Comments before declarations are kept for the back-ends  -Cdir           Change directory to dir before writing output  -d              Dump the parsed IDL then exit  -i              Enter interactive mode after parsing the IDL  -pdir           Path to omniidl back-ends ($TOP/lib/python)  -V              Print version info then exit  -u              Print this usage message and exit  -v              Trace compilation stages"""    if backends == []:        print """You must select a target back-end with -b. For C++, use -bcxx:  omniidl -bcxx file.idlTo see options specific to C++, use:  omniidl -bcxx -u"""preprocessor_name = "omnicpp"preprocessor_args = []preprocessor_only = 0if sys.platform == "win32":    exe_suffix = ".exe"else:    exe_suffix = ""if sys.platform != "OpenVMS":    preprocessor_paths = []    if hasattr(_omniidl, "__file__"):        preprocessor_paths.append(os.path.dirname(_omniidl.__file__))    preprocessor_paths.append(os.path.dirname(sys.argv[0]))    preprocessor = preprocessor_name    for preprocessor_path in preprocessor_paths:        if os.path.isfile(os.path.join(preprocessor_path,                                       preprocessor_name + exe_suffix)):            preprocessor = os.path.join(preprocessor_path, preprocessor_name)            break    preprocessor_cmd  = preprocessor + " -lang-c++ -undef -D__OMNIIDL__=" + \			_omniidl.versionelse:    if hasattr(_omniidl, "__file__"):        preprocessor_path = os.path.dirname(_omniidl.__file__)    else:        preprocessor_path = os.path.dirname(sys.argv[0])    names = string.split(preprocessor_path, "/")    preprocessor_cmd = \ 	'''mcr %s:[%s]omnicpp -lang-c++ -undef "-D__OMNIIDL__=%s"'''\ 	% (names[1], string.join(names[2:],"."), _omniidl.version)no_preprocessor   = 0backends          = []backends_args     = []dump_only         = 0cd_to             = Noneverbose           = 0quiet             = 0print_usage       = 0interactive       = 0temp_file         = Nonedef parseArgs(args):    global preprocessor_args, preprocessor_only, preprocessor_cmd    global no_preprocessor, backend, backend_args, dump_only, cd_to    global verbose, quiet, print_usage, interactive, temp_file    paths = []    try:        opts,files = getopt.getopt(args, "D:I:U:EY:NW:b:n:kKC:dVuhvqp:iTP")    except getopt.error, e:        sys.stderr.write("Error in arguments: -" + e.opt + "\n")        sys.stderr.write("Use '" + cmdname + " -u' for usage\n")        sys.exit(1)    for opt in opts:        o,a = opt        if o == "-D":            preprocessor_args.append("-D" + a)        elif o == "-I":            if sys.platform != "OpenVMS":                preprocessor_args.append('-I "%s"' % a)            else:                # It would be stupid, rude, and evil to put spaces in                # a dirname on VMS                preprocessor_args.append('-I%s' % a)        elif o == "-U":            preprocessor_args.append("-U" + a)        elif o == "-E":            preprocessor_only = 1        elif o == "-Y":            preprocessor_cmd = a        elif o == "-N":            no_preprocessor = 1        elif o == "-W":            if a[0] == "p":              preprocessor_args.extend(string.split(a[1:], ","))            elif a[0] == "b":                if len(backends) == 0:                    if not quiet:                        sys.stderr.write(cmdname + ": Error in arguments: "                                         "no back-ends selected\n")                    sys.exit(1)                backends_args[-1].extend(string.split(a[1:], ","))            else:                if not quiet:                    sys.stderr.write("Error in arguments: option " + o + \                                     " not recognized\n")                    sys.stderr.write("Use " + cmdname + " -u for usage\n")                sys.exit(1)        elif o == "-C":            if not os.path.isdir(a):                if not quiet:                    sys.stderr.write(cmdname + ": '" + a + \                                     "' is not a directory\n")                sys.exit(1)            cd_to = a

⌨️ 快捷键说明

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