xref: /aosp_15_r20/external/cronet/build/android/gyp/process_native_prebuilt.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/usr/bin/env python3
2#
3# Copyright 2020 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
7import argparse
8import os
9import shutil
10import sys
11
12from util import build_utils
13import action_helpers  # build_utils adds //build to sys.path.
14
15
16def main(args):
17  parser = argparse.ArgumentParser(args)
18  parser.add_argument('--strip-path', required=True, help='')
19  parser.add_argument('--input-path', required=True, help='')
20  parser.add_argument('--stripped-output-path', required=True, help='')
21  parser.add_argument('--unstripped-output-path', required=True, help='')
22  options = parser.parse_args(args)
23
24  # eu-strip's output keeps mode from source file which might not be writable
25  # thus it fails to override its output on the next run. AtomicOutput fixes
26  # the issue.
27  with action_helpers.atomic_output(options.stripped_output_path) as out:
28    cmd = [
29        options.strip_path,
30        options.input_path,
31        '-o',
32        out.name,
33    ]
34    build_utils.CheckOutput(cmd)
35  shutil.copyfile(options.input_path, options.unstripped_output_path)
36
37
38if __name__ == '__main__':
39  main(sys.argv[1:])
40