xref: /aosp_15_r20/external/cronet/build/ios/presubmit_support.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4"""Presubmit helpers for ios
5
6See https://www.chromium.org/developers/how-tos/depottools/presubmit-scripts
7for more details about the presubmit API built into depot_tools.
8"""
9
10from . import update_bundle_filelist
11
12
13def CheckBundleData(input_api, output_api, base, globroot='//'):
14  root = input_api.change.RepositoryRoot()
15  filelist = input_api.os_path.join(input_api.PresubmitLocalPath(),
16                                    base + '.filelist')
17  globlist = input_api.os_path.join(input_api.PresubmitLocalPath(),
18                                    base + '.globlist')
19  if globroot.startswith('//'):
20    globroot = input_api.os_path.join(input_api.change.RepositoryRoot(),
21                                      globroot[2:])
22  else:
23    globroot = input_api.os_path.join(input_api.PresubmitLocalPath(), globroot)
24  if update_bundle_filelist.process_filelist(filelist,
25                                             globlist,
26                                             globroot,
27                                             check=True,
28                                             verbose=input_api.verbose) == 0:
29    return []
30  else:
31    script = input_api.os_path.join(input_api.change.RepositoryRoot(), 'build',
32                                    'ios', 'update_bundle_filelist.py')
33
34    return [
35        output_api.PresubmitError(
36            'Filelist needs to be re-generated. Please run \'python3 %s %s %s '
37            '%s\' and include the changes in this CL' %
38            (script, filelist, globlist, globroot))
39    ]
40