40a3e41fdb22f75d1d8533909677c3a05f2fd759cfcd435978200d2af82301ea408b3e464e4a49ec6aa7b29a3ad8fb0042e012691199230a84667312c43022 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2012 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. from __future__ import annotations
  6. import copy
  7. import gyp.input
  8. import argparse
  9. import os.path
  10. import re
  11. import shlex
  12. import sys
  13. import traceback
  14. from gyp.common import GypError
  15. # Default debug modes for GYP
  16. debug = {}
  17. # List of "official" debug modes, but you can use anything you like.
  18. DEBUG_GENERAL = "general"
  19. DEBUG_VARIABLES = "variables"
  20. DEBUG_INCLUDES = "includes"
  21. def EscapeForCString(string: bytes | str) -> str:
  22. if isinstance(string, str):
  23. string = string.encode(encoding='utf8')
  24. backslash_or_double_quote = {ord('\\'), ord('"')}
  25. result = ''
  26. for char in string:
  27. if char in backslash_or_double_quote or not 32 <= char < 127:
  28. result += '\\%03o' % char
  29. else:
  30. result += chr(char)
  31. return result
  32. def DebugOutput(mode, message, *args):
  33. if "all" in gyp.debug or mode in gyp.debug:
  34. ctx = ("unknown", 0, "unknown")
  35. try:
  36. f = traceback.extract_stack(limit=2)
  37. if f:
  38. ctx = f[0][:3]
  39. except Exception:
  40. pass
  41. if args:
  42. message %= args
  43. print(
  44. "%s:%s:%d:%s %s"
  45. % (mode.upper(), os.path.basename(ctx[0]), ctx[1], ctx[2], message)
  46. )
  47. def FindBuildFiles():
  48. extension = ".gyp"
  49. files = os.listdir(os.getcwd())
  50. build_files = []
  51. for file in files:
  52. if file.endswith(extension):
  53. build_files.append(file)
  54. return build_files
  55. def Load(
  56. build_files,
  57. format,
  58. default_variables={},
  59. includes=[],
  60. depth=".",
  61. params=None,
  62. check=False,
  63. circular_check=True,
  64. ):
  65. """
  66. Loads one or more specified build files.
  67. default_variables and includes will be copied before use.
  68. Returns the generator for the specified format and the
  69. data returned by loading the specified build files.
  70. """
  71. if params is None:
  72. params = {}
  73. if "-" in format:
  74. format, params["flavor"] = format.split("-", 1)
  75. default_variables = copy.copy(default_variables)
  76. # Default variables provided by this program and its modules should be
  77. # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace,
  78. # avoiding collisions with user and automatic variables.
  79. default_variables["GENERATOR"] = format
  80. default_variables["GENERATOR_FLAVOR"] = params.get("flavor", "")
  81. # Format can be a custom python file, or by default the name of a module
  82. # within gyp.generator.
  83. if format.endswith(".py"):
  84. generator_name = os.path.splitext(format)[0]
  85. path, generator_name = os.path.split(generator_name)
  86. # Make sure the path to the custom generator is in sys.path
  87. # Don't worry about removing it once we are done. Keeping the path
  88. # to each generator that is used in sys.path is likely harmless and
  89. # arguably a good idea.
  90. path = os.path.abspath(path)
  91. if path not in sys.path:
  92. sys.path.insert(0, path)
  93. else:
  94. generator_name = "gyp.generator." + format
  95. # These parameters are passed in order (as opposed to by key)
  96. # because ActivePython cannot handle key parameters to __import__.
  97. generator = __import__(generator_name, globals(), locals(), generator_name)
  98. for (key, val) in generator.generator_default_variables.items():
  99. default_variables.setdefault(key, val)
  100. output_dir = params["options"].generator_output or params["options"].toplevel_dir
  101. if default_variables["GENERATOR"] == "ninja":
  102. product_dir_abs = os.path.join(
  103. output_dir, "out", default_variables.get("build_type", "default")
  104. )
  105. else:
  106. product_dir_abs = os.path.join(
  107. output_dir, default_variables["CONFIGURATION_NAME"]
  108. )
  109. default_variables.setdefault("PRODUCT_DIR_ABS", product_dir_abs)
  110. default_variables.setdefault(
  111. "PRODUCT_DIR_ABS_CSTR", EscapeForCString(product_dir_abs)
  112. )
  113. # Give the generator the opportunity to set additional variables based on
  114. # the params it will receive in the output phase.
  115. if getattr(generator, "CalculateVariables", None):
  116. generator.CalculateVariables(default_variables, params)
  117. # Give the generator the opportunity to set generator_input_info based on
  118. # the params it will receive in the output phase.
  119. if getattr(generator, "CalculateGeneratorInputInfo", None):
  120. generator.CalculateGeneratorInputInfo(params)
  121. # Fetch the generator specific info that gets fed to input, we use getattr
  122. # so we can default things and the generators only have to provide what
  123. # they need.
  124. generator_input_info = {
  125. "non_configuration_keys": getattr(
  126. generator, "generator_additional_non_configuration_keys", []
  127. ),
  128. "path_sections": getattr(generator, "generator_additional_path_sections", []),
  129. "extra_sources_for_rules": getattr(
  130. generator, "generator_extra_sources_for_rules", []
  131. ),
  132. "generator_supports_multiple_toolsets": getattr(
  133. generator, "generator_supports_multiple_toolsets", False
  134. ),
  135. "generator_wants_static_library_dependencies_adjusted": getattr(
  136. generator, "generator_wants_static_library_dependencies_adjusted", True
  137. ),
  138. "generator_wants_sorted_dependencies": getattr(
  139. generator, "generator_wants_sorted_dependencies", False
  140. ),
  141. "generator_filelist_paths": getattr(
  142. generator, "generator_filelist_paths", None
  143. ),
  144. }
  145. # Process the input specific to this generator.
  146. result = gyp.input.Load(
  147. build_files,
  148. default_variables,
  149. includes[:],
  150. depth,
  151. generator_input_info,
  152. check,
  153. circular_check,
  154. params["parallel"],
  155. params["root_targets"],
  156. )
  157. return [generator] + result
  158. def NameValueListToDict(name_value_list):
  159. """
  160. Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
  161. of the pairs. If a string is simply NAME, then the value in the dictionary
  162. is set to True. If VALUE can be converted to an integer, it is.
  163. """
  164. result = {}
  165. for item in name_value_list:
  166. tokens = item.split("=", 1)
  167. if len(tokens) == 2:
  168. # If we can make it an int, use that, otherwise, use the string.
  169. try:
  170. token_value = int(tokens[1])
  171. except ValueError:
  172. token_value = tokens[1]
  173. # Set the variable to the supplied value.
  174. result[tokens[0]] = token_value
  175. else:
  176. # No value supplied, treat it as a boolean and set it.
  177. result[tokens[0]] = True
  178. return result
  179. def ShlexEnv(env_name):
  180. flags = os.environ.get(env_name, [])
  181. if flags:
  182. flags = shlex.split(flags)
  183. return flags
  184. def FormatOpt(opt, value):
  185. if opt.startswith("--"):
  186. return f"{opt}={value}"
  187. return opt + value
  188. def RegenerateAppendFlag(flag, values, predicate, env_name, options):
  189. """Regenerate a list of command line flags, for an option of action='append'.
  190. The |env_name|, if given, is checked in the environment and used to generate
  191. an initial list of options, then the options that were specified on the
  192. command line (given in |values|) are appended. This matches the handling of
  193. environment variables and command line flags where command line flags override
  194. the environment, while not requiring the environment to be set when the flags
  195. are used again.
  196. """
  197. flags = []
  198. if options.use_environment and env_name:
  199. for flag_value in ShlexEnv(env_name):
  200. value = FormatOpt(flag, predicate(flag_value))
  201. if value in flags:
  202. flags.remove(value)
  203. flags.append(value)
  204. if values:
  205. for flag_value in values:
  206. flags.append(FormatOpt(flag, predicate(flag_value)))
  207. return flags
  208. def RegenerateFlags(options):
  209. """Given a parsed options object, and taking the environment variables into
  210. account, returns a list of flags that should regenerate an equivalent options
  211. object (even in the absence of the environment variables.)
  212. Any path options will be normalized relative to depth.
  213. The format flag is not included, as it is assumed the calling generator will
  214. set that as appropriate.
  215. """
  216. def FixPath(path):
  217. path = gyp.common.FixIfRelativePath(path, options.depth)
  218. if not path:
  219. return os.path.curdir
  220. return path
  221. def Noop(value):
  222. return value
  223. # We always want to ignore the environment when regenerating, to avoid
  224. # duplicate or changed flags in the environment at the time of regeneration.
  225. flags = ["--ignore-environment"]
  226. for name, metadata in options._regeneration_metadata.items():
  227. opt = metadata["opt"]
  228. value = getattr(options, name)
  229. value_predicate = (metadata["type"] == "path" and FixPath) or Noop
  230. action = metadata["action"]
  231. env_name = metadata["env_name"]
  232. if action == "append":
  233. flags.extend(
  234. RegenerateAppendFlag(opt, value, value_predicate, env_name, options)
  235. )
  236. elif action in ("store", None): # None is a synonym for 'store'.
  237. if value:
  238. flags.append(FormatOpt(opt, value_predicate(value)))
  239. elif options.use_environment and env_name and os.environ.get(env_name):
  240. flags.append(FormatOpt(opt, value_predicate(os.environ.get(env_name))))
  241. elif action in ("store_true", "store_false"):
  242. if (action == "store_true" and value) or (
  243. action == "store_false" and not value
  244. ):
  245. flags.append(opt)
  246. elif options.use_environment and env_name:
  247. print(
  248. "Warning: environment regeneration unimplemented "
  249. "for %s flag %r env_name %r" % (action, opt, env_name),
  250. file=sys.stderr,
  251. )
  252. else:
  253. print(
  254. "Warning: regeneration unimplemented for action %r "
  255. "flag %r" % (action, opt),
  256. file=sys.stderr,
  257. )
  258. return flags
  259. class RegeneratableOptionParser(argparse.ArgumentParser):
  260. def __init__(self, usage):
  261. self.__regeneratable_options = {}
  262. argparse.ArgumentParser.__init__(self, usage=usage)
  263. def add_argument(self, *args, **kw):
  264. """Add an option to the parser.
  265. This accepts the same arguments as ArgumentParser.add_argument, plus the
  266. following:
  267. regenerate: can be set to False to prevent this option from being included
  268. in regeneration.
  269. env_name: name of environment variable that additional values for this
  270. option come from.
  271. type: adds type='path', to tell the regenerator that the values of
  272. this option need to be made relative to options.depth
  273. """
  274. env_name = kw.pop("env_name", None)
  275. if "dest" in kw and kw.pop("regenerate", True):
  276. dest = kw["dest"]
  277. # The path type is needed for regenerating, for optparse we can just treat
  278. # it as a string.
  279. type = kw.get("type")
  280. if type == "path":
  281. kw["type"] = str
  282. self.__regeneratable_options[dest] = {
  283. "action": kw.get("action"),
  284. "type": type,
  285. "env_name": env_name,
  286. "opt": args[0],
  287. }
  288. argparse.ArgumentParser.add_argument(self, *args, **kw)
  289. def parse_args(self, *args):
  290. values, args = argparse.ArgumentParser.parse_known_args(self, *args)
  291. values._regeneration_metadata = self.__regeneratable_options
  292. return values, args
  293. def gyp_main(args):
  294. my_name = os.path.basename(sys.argv[0])
  295. usage = "usage: %(prog)s [options ...] [build_file ...]"
  296. parser = RegeneratableOptionParser(usage=usage.replace("%s", "%(prog)s"))
  297. parser.add_argument(
  298. "--build",
  299. dest="configs",
  300. action="append",
  301. help="configuration for build after project generation",
  302. )
  303. parser.add_argument(
  304. "--check", dest="check", action="store_true", help="check format of gyp files"
  305. )
  306. parser.add_argument(
  307. "--config-dir",
  308. dest="config_dir",
  309. action="store",
  310. env_name="GYP_CONFIG_DIR",
  311. default=None,
  312. help="The location for configuration files like " "include.gypi.",
  313. )
  314. parser.add_argument(
  315. "-d",
  316. "--debug",
  317. dest="debug",
  318. metavar="DEBUGMODE",
  319. action="append",
  320. default=[],
  321. help="turn on a debugging "
  322. 'mode for debugging GYP. Supported modes are "variables", '
  323. '"includes" and "general" or "all" for all of them.',
  324. )
  325. parser.add_argument(
  326. "-D",
  327. dest="defines",
  328. action="append",
  329. metavar="VAR=VAL",
  330. env_name="GYP_DEFINES",
  331. help="sets variable VAR to value VAL",
  332. )
  333. parser.add_argument(
  334. "--depth",
  335. dest="depth",
  336. metavar="PATH",
  337. type="path",
  338. help="set DEPTH gyp variable to a relative path to PATH",
  339. )
  340. parser.add_argument(
  341. "-f",
  342. "--format",
  343. dest="formats",
  344. action="append",
  345. env_name="GYP_GENERATORS",
  346. regenerate=False,
  347. help="output formats to generate",
  348. )
  349. parser.add_argument(
  350. "-G",
  351. dest="generator_flags",
  352. action="append",
  353. default=[],
  354. metavar="FLAG=VAL",
  355. env_name="GYP_GENERATOR_FLAGS",
  356. help="sets generator flag FLAG to VAL",
  357. )
  358. parser.add_argument(
  359. "--generator-output",
  360. dest="generator_output",
  361. action="store",
  362. default=None,
  363. metavar="DIR",
  364. type="path",
  365. env_name="GYP_GENERATOR_OUTPUT",
  366. help="puts generated build files under DIR",
  367. )
  368. parser.add_argument(
  369. "--ignore-environment",
  370. dest="use_environment",
  371. action="store_false",
  372. default=True,
  373. regenerate=False,
  374. help="do not read options from environment variables",
  375. )
  376. parser.add_argument(
  377. "-I",
  378. "--include",
  379. dest="includes",
  380. action="append",
  381. metavar="INCLUDE",
  382. type="path",
  383. help="files to include in all loaded .gyp files",
  384. )
  385. # --no-circular-check disables the check for circular relationships between
  386. # .gyp files. These relationships should not exist, but they've only been
  387. # observed to be harmful with the Xcode generator. Chromium's .gyp files
  388. # currently have some circular relationships on non-Mac platforms, so this
  389. # option allows the strict behavior to be used on Macs and the lenient
  390. # behavior to be used elsewhere.
  391. # TODO(mark): Remove this option when http://crbug.com/35878 is fixed.
  392. parser.add_argument(
  393. "--no-circular-check",
  394. dest="circular_check",
  395. action="store_false",
  396. default=True,
  397. regenerate=False,
  398. help="don't check for circular relationships between files",
  399. )
  400. parser.add_argument(
  401. "--no-parallel",
  402. action="store_true",
  403. default=False,
  404. help="Disable multiprocessing",
  405. )
  406. parser.add_argument(
  407. "-S",
  408. "--suffix",
  409. dest="suffix",
  410. default="",
  411. help="suffix to add to generated files",
  412. )
  413. parser.add_argument(
  414. "--toplevel-dir",
  415. dest="toplevel_dir",
  416. action="store",
  417. default=None,
  418. metavar="DIR",
  419. type="path",
  420. help="directory to use as the root of the source tree",
  421. )
  422. parser.add_argument(
  423. "-R",
  424. "--root-target",
  425. dest="root_targets",
  426. action="append",
  427. metavar="TARGET",
  428. help="include only TARGET and its deep dependencies",
  429. )
  430. parser.add_argument(
  431. "-V",
  432. "--version",
  433. dest="version",
  434. action="store_true",
  435. help="Show the version and exit.",
  436. )
  437. options, build_files_arg = parser.parse_args(args)
  438. if options.version:
  439. import pkg_resources
  440. print(f"v{pkg_resources.get_distribution('gyp-next').version}")
  441. return 0
  442. build_files = build_files_arg
  443. # Set up the configuration directory (defaults to ~/.gyp)
  444. if not options.config_dir:
  445. home = None
  446. home_dot_gyp = None
  447. if options.use_environment:
  448. home_dot_gyp = os.environ.get("GYP_CONFIG_DIR", None)
  449. if home_dot_gyp:
  450. home_dot_gyp = os.path.expanduser(home_dot_gyp)
  451. if not home_dot_gyp:
  452. home_vars = ["HOME"]
  453. if sys.platform in ("cygwin", "win32"):
  454. home_vars.append("USERPROFILE")
  455. for home_var in home_vars:
  456. home = os.getenv(home_var)
  457. if home:
  458. home_dot_gyp = os.path.join(home, ".gyp")
  459. if not os.path.exists(home_dot_gyp):
  460. home_dot_gyp = None
  461. else:
  462. break
  463. else:
  464. home_dot_gyp = os.path.expanduser(options.config_dir)
  465. if home_dot_gyp and not os.path.exists(home_dot_gyp):
  466. home_dot_gyp = None
  467. if not options.formats:
  468. # If no format was given on the command line, then check the env variable.
  469. generate_formats = []
  470. if options.use_environment:
  471. generate_formats = os.environ.get("GYP_GENERATORS", [])
  472. if generate_formats:
  473. generate_formats = re.split(r"[\s,]", generate_formats)
  474. if generate_formats:
  475. options.formats = generate_formats
  476. else:
  477. # Nothing in the variable, default based on platform.
  478. if sys.platform == "darwin":
  479. options.formats = ["xcode"]
  480. elif sys.platform in ("win32", "cygwin"):
  481. options.formats = ["msvs"]
  482. else:
  483. options.formats = ["make"]
  484. if not options.generator_output and options.use_environment:
  485. g_o = os.environ.get("GYP_GENERATOR_OUTPUT")
  486. if g_o:
  487. options.generator_output = g_o
  488. options.parallel = not options.no_parallel
  489. for mode in options.debug:
  490. gyp.debug[mode] = 1
  491. # Do an extra check to avoid work when we're not debugging.
  492. if DEBUG_GENERAL in gyp.debug:
  493. DebugOutput(DEBUG_GENERAL, "running with these options:")
  494. for option, value in sorted(options.__dict__.items()):
  495. if option[0] == "_":
  496. continue
  497. if isinstance(value, str):
  498. DebugOutput(DEBUG_GENERAL, " %s: '%s'", option, value)
  499. else:
  500. DebugOutput(DEBUG_GENERAL, " %s: %s", option, value)
  501. if not build_files:
  502. build_files = FindBuildFiles()
  503. if not build_files:
  504. raise GypError((usage + "\n\n%s: error: no build_file") % (my_name, my_name))
  505. # TODO(mark): Chromium-specific hack!
  506. # For Chromium, the gyp "depth" variable should always be a relative path
  507. # to Chromium's top-level "src" directory. If no depth variable was set
  508. # on the command line, try to find a "src" directory by looking at the
  509. # absolute path to each build file's directory. The first "src" component
  510. # found will be treated as though it were the path used for --depth.
  511. if not options.depth:
  512. for build_file in build_files:
  513. build_file_dir = os.path.abspath(os.path.dirname(build_file))
  514. build_file_dir_components = build_file_dir.split(os.path.sep)
  515. components_len = len(build_file_dir_components)
  516. for index in range(components_len - 1, -1, -1):
  517. if build_file_dir_components[index] == "src":
  518. options.depth = os.path.sep.join(build_file_dir_components)
  519. break
  520. del build_file_dir_components[index]
  521. # If the inner loop found something, break without advancing to another
  522. # build file.
  523. if options.depth:
  524. break
  525. if not options.depth:
  526. raise GypError(
  527. "Could not automatically locate src directory. This is"
  528. "a temporary Chromium feature that will be removed. Use"
  529. "--depth as a workaround."
  530. )
  531. # If toplevel-dir is not set, we assume that depth is the root of our source
  532. # tree.
  533. if not options.toplevel_dir:
  534. options.toplevel_dir = options.depth
  535. # -D on the command line sets variable defaults - D isn't just for define,
  536. # it's for default. Perhaps there should be a way to force (-F?) a
  537. # variable's value so that it can't be overridden by anything else.
  538. cmdline_default_variables = {}
  539. defines = []
  540. if options.use_environment:
  541. defines += ShlexEnv("GYP_DEFINES")
  542. if options.defines:
  543. defines += options.defines
  544. cmdline_default_variables = NameValueListToDict(defines)
  545. if DEBUG_GENERAL in gyp.debug:
  546. DebugOutput(
  547. DEBUG_GENERAL, "cmdline_default_variables: %s", cmdline_default_variables
  548. )
  549. # Set up includes.
  550. includes = []
  551. # If ~/.gyp/include.gypi exists, it'll be forcibly included into every
  552. # .gyp file that's loaded, before anything else is included.
  553. if home_dot_gyp:
  554. default_include = os.path.join(home_dot_gyp, "include.gypi")
  555. if os.path.exists(default_include):
  556. print("Using overrides found in " + default_include)
  557. includes.append(default_include)
  558. # Command-line --include files come after the default include.
  559. if options.includes:
  560. includes.extend(options.includes)
  561. # Generator flags should be prefixed with the target generator since they
  562. # are global across all generator runs.
  563. gen_flags = []
  564. if options.use_environment:
  565. gen_flags += ShlexEnv("GYP_GENERATOR_FLAGS")
  566. if options.generator_flags:
  567. gen_flags += options.generator_flags
  568. generator_flags = NameValueListToDict(gen_flags)
  569. if DEBUG_GENERAL in gyp.debug:
  570. DebugOutput(DEBUG_GENERAL, "generator_flags: %s", generator_flags)
  571. # Generate all requested formats (use a set in case we got one format request
  572. # twice)
  573. for format in set(options.formats):
  574. params = {
  575. "options": options,
  576. "build_files": build_files,
  577. "generator_flags": generator_flags,
  578. "cwd": os.getcwd(),
  579. "build_files_arg": build_files_arg,
  580. "gyp_binary": sys.argv[0],
  581. "home_dot_gyp": home_dot_gyp,
  582. "parallel": options.parallel,
  583. "root_targets": options.root_targets,
  584. "target_arch": cmdline_default_variables.get("target_arch", ""),
  585. }
  586. # Start with the default variables from the command line.
  587. [generator, flat_list, targets, data] = Load(
  588. build_files,
  589. format,
  590. cmdline_default_variables,
  591. includes,
  592. options.depth,
  593. params,
  594. options.check,
  595. options.circular_check,
  596. )
  597. # TODO(mark): Pass |data| for now because the generator needs a list of
  598. # build files that came in. In the future, maybe it should just accept
  599. # a list, and not the whole data dict.
  600. # NOTE: flat_list is the flattened dependency graph specifying the order
  601. # that targets may be built. Build systems that operate serially or that
  602. # need to have dependencies defined before dependents reference them should
  603. # generate targets in the order specified in flat_list.
  604. generator.GenerateOutput(flat_list, targets, data, params)
  605. if options.configs:
  606. valid_configs = targets[flat_list[0]]["configurations"]
  607. for conf in options.configs:
  608. if conf not in valid_configs:
  609. raise GypError("Invalid config specified via --build: %s" % conf)
  610. generator.PerformBuild(data, options.configs, params)
  611. # Done
  612. return 0
  613. def main(args):
  614. try:
  615. return gyp_main(args)
  616. except GypError as e:
  617. sys.stderr.write("gyp: %s\n" % e)
  618. return 1
  619. # NOTE: setuptools generated console_scripts calls function with no arguments
  620. def script_main():
  621. return main(sys.argv[1:])
  622. if __name__ == "__main__":
  623. sys.exit(script_main())