Skip to content

[build-script] Accept --ninja-bin and sync with sourcekit's build-script-helper #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Utilities/build-script-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def get_swiftpm_options(args):
if platform.system() != 'Darwin':
swiftpm_args += [
# Dispatch headers
'-Xcxx', '-I', '-Xcxx', os.path.join(args.toolchain, 'usr', 'lib', 'swift'),
'-Xcxx', '-I', '-Xcxx',
os.path.join(args.toolchain, 'usr', 'lib', 'swift'),
]

return swiftpm_args
Expand All @@ -36,6 +37,7 @@ def main():
def add_common_args(parser):
parser.add_argument('--package-path', metavar='PATH', help='directory of the package to build', default='.')
parser.add_argument('--toolchain', required=True, metavar='PATH', help='build using the toolchain at PATH')
parser.add_argument('--ninja-bin', metavar='PATH', help='ninja binary to use for testing')
parser.add_argument('--build-path', metavar='PATH', default='.build', help='build in the given path')
parser.add_argument('--configuration', '-c', default='debug', help='build using configuration (release|debug)')
parser.add_argument('--verbose', '-v', action='store_true', help='enable verbose output')
Expand All @@ -61,12 +63,19 @@ def add_common_args(parser):

swiftpm_args = get_swiftpm_options(args)

env = os.environ
# Set the toolchain used in tests at runtime
env['INDEXSTOREDB_TOOLCHAIN_PATH'] = args.toolchain

if args.ninja_bin:
env['NINJA_BIN'] = args.ninja_bin

if args.action == 'build':
swiftpm('build', swift_exec, swiftpm_args)
swiftpm('build', swift_exec, swiftpm_args, env)
elif args.action == 'test':
swiftpm('test', swift_exec, swiftpm_args)
swiftpm('test', swift_exec, swiftpm_args, env)
else:
assert False, 'unknown action \'{}\''.format(args.action)

if __name__ == '__main__':
main()
main()