|
20 | 20 | INCR_TRANSFER_ROUNDTRIP_EXEC = \
|
21 | 21 | WORKSPACE_DIR + '/swift/utils/incrparse/incr_transfer_round_trip.py'
|
22 | 22 |
|
| 23 | +GYB_EXEC = os.path.join(WORKSPACE_DIR, 'swift', 'utils', 'gyb') |
| 24 | + |
23 | 25 | LIT_EXEC = WORKSPACE_DIR + '/llvm-project/llvm/utils/lit/lit.py'
|
24 | 26 |
|
25 | 27 | GROUP_INFO_PATH = PACKAGE_DIR + '/utils/group.json'
|
@@ -448,108 +450,155 @@ def install(build_dir, dylib_dir, swiftmodule_base_name, stdlib_rpath):
|
448 | 450 |
|
449 | 451 |
|
450 | 452 | # -----------------------------------------------------------------------------
|
| 453 | +# Arugment Parsing |
451 | 454 |
|
452 |
| -def main(): |
453 |
| - parser = argparse.ArgumentParser( |
454 |
| - formatter_class=argparse.RawDescriptionHelpFormatter, |
455 |
| - description=''' |
| 455 | +_DESCRIPTION = """ |
456 | 456 | Build and test script for SwiftSyntax.
|
457 | 457 |
|
458 | 458 | Build SwiftSyntax by generating all necessary files form the corresponding
|
459 | 459 | .swift.gyb files first. For this, SwiftSyntax needs to be check out alongside
|
460 | 460 | the main swift repo (http://github.com/apple/swift/) in the following structure
|
| 461 | +
|
461 | 462 | - (containing directory)
|
462 | 463 | - swift
|
463 | 464 | - swift-syntax
|
| 465 | +
|
464 | 466 | It is not necessary to build the compiler project.
|
465 | 467 |
|
466 | 468 | The build script can also drive the test suite included in the SwiftSyntax
|
467 | 469 | repo. This requires a custom build of the compiler project since it accesses
|
468 | 470 | test utilities that are not shipped as part of the toolchains. See the Testing
|
469 | 471 | section for arguments that need to be specified for this.
|
470 |
| -''') |
| 472 | +""" |
| 473 | + |
| 474 | + |
| 475 | +_SWIFTMODULE_BASE_NAME_HELP = """ |
| 476 | +The name under which the Swift module should be installed. A .swiftdoc and |
| 477 | +.swiftmodule file extension will be added to this path and the corresponding |
| 478 | +files will be copied there. |
| 479 | +
|
| 480 | +Example /path/to/SwiftSyntax.swiftmodule/x86_64 copies files to |
| 481 | +/path/to/SwiftSyntax.swiftmodule/x86_64.swiftmodule and |
| 482 | +/path/to/SwiftSyntax.swiftmodule/x86_64.swiftdoc |
| 483 | +""" |
| 484 | + |
| 485 | + |
| 486 | +def parse_args(): |
| 487 | + parser = argparse.ArgumentParser( |
| 488 | + formatter_class=argparse.RawDescriptionHelpFormatter, |
| 489 | + description=_DESCRIPTION) |
| 490 | + |
| 491 | + # ------------------------------------------------------------------------- |
| 492 | + |
| 493 | + parser.add_argument( |
| 494 | + '-v', '--verbose', |
| 495 | + action='store_true', |
| 496 | + help='Enable verbose logging.') |
| 497 | + |
| 498 | + # ------------------------------------------------------------------------- |
| 499 | + xcode_project_group = parser.add_argument_group('Xcode Project') |
| 500 | + |
| 501 | + xcode_project_group.add_argument( |
| 502 | + '--generate-xcodeproj', |
| 503 | + action='store_true', |
| 504 | + help='Generate an Xcode project for SwiftSyntax.') |
471 | 505 |
|
472 |
| - default_gyb_exec = WORKSPACE_DIR + '/swift/utils/gyb' |
473 |
| - |
474 |
| - basic_group = parser.add_argument_group('Basic') |
475 |
| - |
476 |
| - basic_group.add_argument('--build-dir', default=None, help=''' |
477 |
| - The directory in which build products shall be put. If omitted a |
478 |
| - directory named '.build' will be put in the swift-syntax directory. |
479 |
| - ''') |
480 |
| - basic_group.add_argument('-v', '--verbose', action='store_true', help=''' |
481 |
| - Enable extensive logging of executed steps. |
482 |
| - ''') |
483 |
| - basic_group.add_argument('-r', '--release', action='store_true', help=''' |
484 |
| - Build as a release build. |
485 |
| - ''') |
486 |
| - basic_group.add_argument('--add-source-locations', action='store_true', |
487 |
| - help=''' |
488 |
| - Insert ###sourceLocation comments in generated code for line-directive. |
489 |
| - ''') |
490 |
| - basic_group.add_argument('--install', action='store_true', |
491 |
| - help=''' |
492 |
| - Install the build artifact to a specified toolchain directory. |
493 |
| - ''') |
494 |
| - basic_group.add_argument('--generate-xcodeproj', action='store_true', |
495 |
| - help=''' |
496 |
| - Generate an Xcode project for SwiftSyntax. |
497 |
| - ''') |
498 |
| - basic_group.add_argument('--xcconfig-path', |
499 |
| - help=''' |
500 |
| - The path to an xcconfig file for generating Xcode projct. |
501 |
| - ''') |
502 |
| - basic_group.add_argument('--dylib-dir', |
503 |
| - help=''' |
504 |
| - The directory to where the .dylib should be installed. |
505 |
| - ''') |
506 |
| - basic_group.add_argument('--swiftmodule-base-name', |
507 |
| - help=''' |
508 |
| - The name under which the Swift module should be installed. A .swiftdoc |
509 |
| - and .swiftmodule file extension will be added to this path and the |
510 |
| - corresponding files will be copied there. |
511 |
| - Example /path/to/SwiftSyntax.swiftmodule/x86_64 copies files to |
512 |
| - /path/to/SwiftSyntax.swiftmodule/x86_64.swiftmodule and |
513 |
| - /path/to/SwiftSyntax.swiftmodule/x86_64.swiftdoc |
514 |
| - ''') |
515 |
| - basic_group.add_argument('--toolchain', help=''' |
516 |
| - The path to the toolchain that shall be used to build SwiftSyntax. |
517 |
| - ''') |
| 506 | + xcode_project_group.add_argument( |
| 507 | + '--xcconfig-path', |
| 508 | + help='The path to an xcconfig file for generating Xcode projct.') |
518 | 509 |
|
| 510 | + # ------------------------------------------------------------------------- |
519 | 511 | build_group = parser.add_argument_group('Build')
|
520 |
| - build_group.add_argument('--disable-sandbox', |
521 |
| - action='store_true', |
522 |
| - help='Disable sandboxes when building with ' |
523 |
| - 'Swift PM') |
524 |
| - |
525 |
| - build_group.add_argument('--degyb-only', |
526 |
| - action='store_true', |
527 |
| - help='The script only generates swift files from ' |
528 |
| - 'gyb and skips the rest of the build') |
529 |
| - |
530 |
| - build_group.add_argument('--multiroot-data-file', |
531 |
| - help='Path to an Xcode workspace to create a ' |
532 |
| - 'unified build of SwiftSyntax with other ' |
533 |
| - 'projects.') |
534 |
| - |
535 |
| - testing_group = parser.add_argument_group('Testing') |
536 |
| - testing_group.add_argument('-t', '--test', action='store_true', |
537 |
| - help='Run tests') |
538 |
| - |
539 |
| - testing_group.add_argument('--filecheck-exec', default=None, help=''' |
540 |
| - Path to the FileCheck executable that was built as part of the LLVM |
541 |
| - repository. If not specified, it will be looked up from PATH. |
542 |
| - ''') |
543 |
| - testing_group.add_argument('--gyb-exec', default=default_gyb_exec, help=''' |
544 |
| - Path to the gyb tool. (default: '%s'). |
545 |
| - ''' % (default_gyb_exec)) |
546 |
| - testing_group.add_argument('--verify-generated-files', action='store_true', |
547 |
| - help=''' |
548 |
| - Instead of generating files using gyb, verify that the files which |
549 |
| - already exist match the ones that would be generated by this script. |
550 |
| - ''') |
551 |
| - |
552 |
| - args = parser.parse_args(sys.argv[1:]) |
| 512 | + |
| 513 | + build_group.add_argument( |
| 514 | + '-r', '--release', |
| 515 | + action='store_true', |
| 516 | + help='Build in release mode.') |
| 517 | + |
| 518 | + build_group.add_argument( |
| 519 | + '--build-dir', |
| 520 | + default=None, |
| 521 | + help='The directory in which build products shall be put. If omitted ' |
| 522 | + 'a directory named ".build" will be put in the swift-syntax ' |
| 523 | + 'directory.') |
| 524 | + |
| 525 | + build_group.add_argument( |
| 526 | + '--add-source-locations', |
| 527 | + action='store_true', |
| 528 | + help='Insert ###sourceLocation comments in generated code for ' |
| 529 | + 'line-directive.') |
| 530 | + |
| 531 | + build_group.add_argument( |
| 532 | + '--degyb-only', |
| 533 | + action='store_true', |
| 534 | + help='The script only generates swift files from gyb and skips the ' |
| 535 | + 'rest of the build') |
| 536 | + |
| 537 | + build_group.add_argument( |
| 538 | + '--disable-sandbox', |
| 539 | + action='store_true', |
| 540 | + help='Disable sandboxes when building with SwiftPM') |
| 541 | + |
| 542 | + build_group.add_argument( |
| 543 | + '--multiroot-data-file', |
| 544 | + help='Path to an Xcode workspace to create a unified build of ' |
| 545 | + 'SwiftSyntax with other projects.') |
| 546 | + |
| 547 | + build_group.add_argument( |
| 548 | + '--toolchain', |
| 549 | + help='The path to the toolchain that shall be used to build ' |
| 550 | + 'SwiftSyntax.') |
| 551 | + |
| 552 | + # ------------------------------------------------------------------------- |
| 553 | + install_group = parser.add_argument_group('Install') |
| 554 | + |
| 555 | + install_group.add_argument( |
| 556 | + '-i', '--install', |
| 557 | + action='store_true', |
| 558 | + help='Install the build artifact to a specified toolchain directory.') |
| 559 | + |
| 560 | + install_group.add_argument( |
| 561 | + '--dylib-dir', |
| 562 | + help='The directory to where the .dylib should be installed.') |
| 563 | + |
| 564 | + install_group.add_argument( |
| 565 | + '--swiftmodule-base-name', |
| 566 | + help=_SWIFTMODULE_BASE_NAME_HELP) |
| 567 | + |
| 568 | + # ------------------------------------------------------------------------- |
| 569 | + test_group = parser.add_argument_group('Test') |
| 570 | + |
| 571 | + test_group.add_argument( |
| 572 | + '-t', '--test', |
| 573 | + action='store_true', |
| 574 | + help='Run tests') |
| 575 | + |
| 576 | + test_group.add_argument( |
| 577 | + '--filecheck-exec', |
| 578 | + default=None, |
| 579 | + help='Path to the FileCheck executable that was built as part of the ' |
| 580 | + 'LLVM repository. If not specified, it will be looked up from ' |
| 581 | + 'PATH.') |
| 582 | + |
| 583 | + test_group.add_argument( |
| 584 | + '--gyb-exec', |
| 585 | + default=GYB_EXEC, |
| 586 | + help='Path to the gyb tool (default: %(default)s).') |
| 587 | + |
| 588 | + test_group.add_argument( |
| 589 | + '--verify-generated-files', |
| 590 | + action='store_true', |
| 591 | + help='Instead of generating files using gyb, verify that the files ' |
| 592 | + 'which already exist match the ones that would be generated by ' |
| 593 | + 'this script.') |
| 594 | + |
| 595 | + return parser.parse_args() |
| 596 | + |
| 597 | + |
| 598 | +# ----------------------------------------------------------------------------- |
| 599 | + |
| 600 | +def main(): |
| 601 | + args = parse_args() |
553 | 602 |
|
554 | 603 | if args.install:
|
555 | 604 | if not args.dylib_dir:
|
|
0 commit comments