Skip to content

[4.2] Merge pull request #7 from allevato/remove-line-directives #13

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
18 changes: 15 additions & 3 deletions build-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def check_rsync():
fatal_error('Error: Could not find rsync.')


def generate_gyb_files(verbose):
def generate_gyb_files(verbose, add_source_locations):
print('** Generating gyb Files **')

check_gyb_exec()
Expand All @@ -102,10 +102,17 @@ def generate_gyb_files(verbose):
# Slice off the '.gyb' to get the name for the output file
output_file_name = gyb_file[:-4]

# Source locations are added by default by gyb, and cleared by passing
# `--line-directive=` (nothing following the `=`) to the generator. Our
# flag is the reverse; we don't want them by default, only if requested.
line_directive_flags = [] if add_source_locations \
else ['--line-directive=']

# Generate the new file
check_call([GYB_EXEC] +
[swiftsyntax_sources_dir + '/' + gyb_file] +
['-o', temp_files_dir + '/' + output_file_name],
['-o', temp_files_dir + '/' + output_file_name] +
line_directive_flags,
verbose=verbose)

# Copy the file if different from the file already present in
Expand Down Expand Up @@ -223,6 +230,10 @@ def main():
basic_group.add_argument('-r', '--release', action='store_true', help='''
Build as a release build.
''')
basic_group.add_argument('--add-source-locations', action='store_true',
help='''
Insert ###sourceLocation comments in generated code for line-directive.
''')

testing_group = parser.add_argument_group('Testing')
testing_group.add_argument('-t', '--test', action='store_true',
Expand Down Expand Up @@ -256,7 +267,8 @@ def main():


try:
generate_gyb_files(args.verbose)
generate_gyb_files(verbose=args.verbose,
add_source_locations=args.add_source_locations)
except subprocess.CalledProcessError as e:
printerr('Error: Generating .gyb files failed')
printerr('Executing: %s' % ' '.join(e.cmd))
Expand Down