xref: /aosp_15_r20/external/angle/build/rust/write_rustflags.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1#!/usr/bin/env vpython3
2
3# Copyright 2024 The Chromium Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Writes all command line arguments to a file, separated by newlines.
8
9import argparse
10import os
11import sys
12
13# Set up path to be able to import action_helpers
14sys.path.append(
15    os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir,
16                 os.pardir, 'build'))
17import action_helpers
18
19
20def main():
21  parser = argparse.ArgumentParser(description='Run Rust build script.')
22  parser.add_argument('--output', required=True, help='output file')
23  args, flags = parser.parse_known_args()
24  # AtomicOutput will ensure we only write to the file on disk if what we
25  # give to write() is different than what's currently on disk.
26  with action_helpers.atomic_output(args.output) as output:
27    output.write(b'\n'.join([f.encode('utf-8') for f in flags]))
28
29
30if __name__ == '__main__':
31  sys.exit(main())
32