| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 import copy | 3 import copy |
| 4 import gyp.input | 4 import gyp.input |
| 5 import optparse | 5 import optparse |
| 6 import os.path | 6 import os.path |
| 7 import sets |
| 7 import shlex | 8 import shlex |
| 8 import sys | 9 import sys |
| 9 | 10 |
| 11 # Default debug modes for GYP |
| 12 debug = sets.Set([]) |
| 13 |
| 14 # List of "official" debug modes, but you can use anything you like. |
| 15 DEBUG_GENERAL = 'general' |
| 16 DEBUG_VARIABLES = 'variables' |
| 17 |
| 18 def DebugOutput(mode, message): |
| 19 if mode in gyp.debug: |
| 20 print "%s: %s" % (mode.upper(), message) |
| 10 | 21 |
| 11 def FindBuildFiles(): | 22 def FindBuildFiles(): |
| 12 extension = '.gyp' | 23 extension = '.gyp' |
| 13 files = os.listdir(os.getcwd()) | 24 files = os.listdir(os.getcwd()) |
| 14 build_files = [] | 25 build_files = [] |
| 15 for file in files: | 26 for file in files: |
| 16 if file[-len(extension):] == extension: | 27 if file[-len(extension):] == extension: |
| 17 build_files.append(file) | 28 build_files.append(file) |
| 18 return build_files | 29 return build_files |
| 19 | 30 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 help='sets variable VAR to value VAL') | 102 help='sets variable VAR to value VAL') |
| 92 parser.add_option('-f', '--format', dest='formats', action='append', | 103 parser.add_option('-f', '--format', dest='formats', action='append', |
| 93 help='output formats to generate') | 104 help='output formats to generate') |
| 94 parser.add_option('--msvs-version', dest='msvs_version', | 105 parser.add_option('--msvs-version', dest='msvs_version', |
| 95 help='Deprecated; use -G msvs_version=MSVS_VERSION instead') | 106 help='Deprecated; use -G msvs_version=MSVS_VERSION instead') |
| 96 parser.add_option('-I', '--include', dest='includes', action='append', | 107 parser.add_option('-I', '--include', dest='includes', action='append', |
| 97 metavar='INCLUDE', | 108 metavar='INCLUDE', |
| 98 help='files to include in all loaded .gyp files') | 109 help='files to include in all loaded .gyp files') |
| 99 parser.add_option('--depth', dest='depth', metavar='PATH', | 110 parser.add_option('--depth', dest='depth', metavar='PATH', |
| 100 help='set DEPTH gyp variable to a relative path to PATH') | 111 help='set DEPTH gyp variable to a relative path to PATH') |
| 112 parser.add_option('-d', '--debug', dest='debug', metavar='DEBUGMODE', |
| 113 action='append', default=[], help='turn on a debugging ' |
| 114 'mode for debugging GYP. Supported modes are "variables" ' |
| 115 'and "general"') |
| 101 parser.add_option('-S', '--suffix', dest='suffix', default='', | 116 parser.add_option('-S', '--suffix', dest='suffix', default='', |
| 102 help='suffix to add to generated files') | 117 help='suffix to add to generated files') |
| 103 parser.add_option('-G', dest='generator_flags', action='append', default=[], | 118 parser.add_option('-G', dest='generator_flags', action='append', default=[], |
| 104 metavar='FLAG=VAL', help='sets generator flag FLAG to VAL') | 119 metavar='FLAG=VAL', help='sets generator flag FLAG to VAL') |
| 105 | 120 |
| 106 # We read a few things from ~/.gyp, so set up a var for that. | 121 # We read a few things from ~/.gyp, so set up a var for that. |
| 107 home_vars = ['HOME'] | 122 home_vars = ['HOME'] |
| 108 if sys.platform in ('cygwin', 'win32'): | 123 if sys.platform in ('cygwin', 'win32'): |
| 109 home_vars.append('USERPROFILE') | 124 home_vars.append('USERPROFILE') |
| 110 home = None | 125 home = None |
| 111 for home_var in home_vars: | 126 for home_var in home_vars: |
| 112 home = os.getenv(home_var) | 127 home = os.getenv(home_var) |
| 113 if home != None: | 128 if home != None: |
| 114 break | 129 break |
| 115 home_dot_gyp = None | 130 home_dot_gyp = None |
| 116 if home != None: | 131 if home != None: |
| 117 home_dot_gyp = os.path.join(home, '.gyp') | 132 home_dot_gyp = os.path.join(home, '.gyp') |
| 118 if not os.path.exists(home_dot_gyp): | 133 if not os.path.exists(home_dot_gyp): |
| 119 home_dot_gyp = None | 134 home_dot_gyp = None |
| 120 | 135 |
| 121 # TODO(thomasvl): add support for ~/.gyp/defaults | 136 # TODO(thomasvl): add support for ~/.gyp/defaults |
| 122 | 137 |
| 123 (options, build_files) = parser.parse_args(args) | 138 (options, build_files) = parser.parse_args(args) |
| 124 | 139 |
| 140 gyp.debug = sets.Set(options.debug) |
| 141 |
| 142 # Do an extra check to avoid work when we're not debugging. |
| 143 if DEBUG_GENERAL in gyp.debug: |
| 144 DebugOutput(DEBUG_GENERAL, 'running with these options:') |
| 145 for (option, value) in options.__dict__.items(): |
| 146 if isinstance(value, basestring): |
| 147 DebugOutput(DEBUG_GENERAL, " %s: '%s'" % (option, value)) |
| 148 else: |
| 149 DebugOutput(DEBUG_GENERAL, " %s: %s" % (option, str(value))) |
| 150 |
| 125 if not options.formats: | 151 if not options.formats: |
| 126 # If no format was given on the command line, then check the env variable. | 152 # If no format was given on the command line, then check the env variable. |
| 127 generate_formats = os.environ.get('GYP_GENERATORS', []) | 153 generate_formats = os.environ.get('GYP_GENERATORS', []) |
| 128 if generate_formats: | 154 if generate_formats: |
| 129 generate_formats = shlex.split(generate_formats) | 155 generate_formats = shlex.split(generate_formats) |
| 130 if generate_formats: | 156 if generate_formats: |
| 131 options.formats = generate_formats | 157 options.formats = generate_formats |
| 132 else: | 158 else: |
| 133 # Nothing in the variable, default based on platform. | 159 # Nothing in the variable, default based on platform. |
| 134 options.formats = [ {'darwin': 'xcode', | 160 options.formats = [ {'darwin': 'xcode', |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 includes.extend(options.includes) | 225 includes.extend(options.includes) |
| 200 | 226 |
| 201 # Generator flags should be prefixed with the target generator since they | 227 # Generator flags should be prefixed with the target generator since they |
| 202 # are global across all generator runs. | 228 # are global across all generator runs. |
| 203 gen_flags = os.environ.get('GYP_GENERATOR_FLAGS', []) | 229 gen_flags = os.environ.get('GYP_GENERATOR_FLAGS', []) |
| 204 if gen_flags: | 230 if gen_flags: |
| 205 gen_flags = shlex.split(gen_flags) | 231 gen_flags = shlex.split(gen_flags) |
| 206 if options.generator_flags: | 232 if options.generator_flags: |
| 207 gen_flags += options.generator_flags | 233 gen_flags += options.generator_flags |
| 208 generator_flags = NameValueListToDict(gen_flags) | 234 generator_flags = NameValueListToDict(gen_flags) |
| 209 | 235 |
| 210 # TODO: Remove this and the option after we've gotten folks to move to the | 236 # TODO: Remove this and the option after we've gotten folks to move to the |
| 211 # generator flag. | 237 # generator flag. |
| 212 if options.msvs_version: | 238 if options.msvs_version: |
| 213 print >>sys.stderr, \ | 239 print >>sys.stderr, \ |
| 214 'DEPRECATED: Use generator flag (-G msvs_version=' + \ | 240 'DEPRECATED: Use generator flag (-G msvs_version=' + \ |
| 215 options.msvs_version + ') instead of --msvs-version=' + \ | 241 options.msvs_version + ') instead of --msvs-version=' + \ |
| 216 options.msvs_version | 242 options.msvs_version |
| 217 generator_flags['msvs_version'] = options.msvs_version | 243 generator_flags['msvs_version'] = options.msvs_version |
| 218 | 244 |
| 219 # Generate all requested formats (use a set in case we got one format request | 245 # Generate all requested formats (use a set in case we got one format request |
| (...skipping 17 matching lines...) Expand all Loading... |
| 237 # need to have dependencies defined before dependents reference them should | 263 # need to have dependencies defined before dependents reference them should |
| 238 # generate targets in the order specified in flat_list. | 264 # generate targets in the order specified in flat_list. |
| 239 generator.GenerateOutput(flat_list, targets, data, params) | 265 generator.GenerateOutput(flat_list, targets, data, params) |
| 240 | 266 |
| 241 # Done | 267 # Done |
| 242 return 0 | 268 return 0 |
| 243 | 269 |
| 244 | 270 |
| 245 if __name__ == '__main__': | 271 if __name__ == '__main__': |
| 246 sys.exit(main(sys.argv[1:])) | 272 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |