Skip to content

Commit

Permalink
Android: Use action_helpers instead of build_utils when applicable
Browse files Browse the repository at this point in the history
Bug: 1428082
Change-Id: Ie23e6c0e94a4cc637d757ba842b4142d5cc8bc9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4383307
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Sam Maier <smaier@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1124543}
  • Loading branch information
agrieve authored and Chromium LUCI CQ committed Mar 31, 2023
1 parent 0b8f00d commit 4bc50e2
Show file tree
Hide file tree
Showing 110 changed files with 443 additions and 333 deletions.
3 changes: 2 additions & 1 deletion base/android/jni_generator/jni_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
sys.path.insert(1, _BUILD_ANDROID_GYP)

from util import build_utils
import action_helpers # build_utils adds //build to sys.path.

# Match single line comments, multiline comments, character literals, and
# double-quoted strings.
Expand Down Expand Up @@ -1543,7 +1544,7 @@ def GenerateJNIHeader(input_file, output_file, options):
print(e)
sys.exit(1)
if output_file:
with build_utils.AtomicOutput(output_file, mode='w') as f:
with action_helpers.atomic_output(output_file, mode='w') as f:
f.write(content)
else:
print(content)
Expand Down
1 change: 1 addition & 0 deletions base/android/jni_generator/jni_generator.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root base/android/jni_generator --output base/android/jni_generator/jni_generator.pydeps base/android/jni_generator/jni_generator.py
../../../build/action_helpers.py
../../../build/android/gyp/util/__init__.py
../../../build/android/gyp/util/build_utils.py
../../../build/gn_helpers.py
Expand Down
13 changes: 7 additions & 6 deletions base/android/jni_generator/jni_registration_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import jni_generator
from util import build_utils
import action_helpers # build_utils adds //build to sys.path.

# All but FULL_CLASS_NAME, which is used only for sorting.
MERGEABLE_KEYS = [
Expand Down Expand Up @@ -103,10 +104,10 @@ def _Generate(options, java_file_paths):
combined_dict['HEADER_GUARD'] = header_guard
combined_dict['NAMESPACE'] = options.namespace
header_content = CreateFromDict(options, module_name, combined_dict)
with build_utils.AtomicOutput(options.header_path, mode='w') as f:
with action_helpers.atomic_output(options.header_path, mode='w') as f:
f.write(header_content)

with build_utils.AtomicOutput(options.srcjar_path) as f:
with action_helpers.atomic_output(options.srcjar_path) as f:
with zipfile.ZipFile(f, 'w') as srcjar:
for module_name, combined_dict in combined_dicts.items():

Expand Down Expand Up @@ -851,7 +852,7 @@ def _MakeProxySignature(options, proxy_native):

def main(argv):
arg_parser = argparse.ArgumentParser()
build_utils.AddDepfileOption(arg_parser)
action_helpers.add_depfile_arg(arg_parser)

arg_parser.add_argument(
'--sources-files',
Expand Down Expand Up @@ -919,7 +920,7 @@ def main(argv):
'Invalid arguments: --manual-jni-registration without --header-path. '
'Cannot manually register JNI if there is no output header file.')

sources_files = sorted(set(build_utils.ParseGnList(args.sources_files)))
sources_files = sorted(set(action_helpers.parse_gn_list(args.sources_files)))

java_file_paths = []
for f in sources_files:
Expand All @@ -931,8 +932,8 @@ def main(argv):
_Generate(args, java_file_paths)

if args.depfile:
build_utils.WriteDepfile(args.depfile, args.srcjar_path,
sources_files + java_file_paths)
action_helpers.write_depfile(args.depfile, args.srcjar_path,
sources_files + java_file_paths)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root base/android/jni_generator --output base/android/jni_generator/jni_registration_generator.pydeps base/android/jni_generator/jni_registration_generator.py
../../../build/action_helpers.py
../../../build/android/gyp/util/__init__.py
../../../build/android/gyp/util/build_utils.py
../../../build/gn_helpers.py
Expand Down
1 change: 1 addition & 0 deletions build/android/apk_operations.pydeps
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
../../third_party/markupsafe/__init__.py
../../third_party/markupsafe/_compat.py
../../third_party/markupsafe/_native.py
../action_helpers.py
../gn_helpers.py
../print_python_deps.py
adb_command_line.py
Expand Down
6 changes: 2 additions & 4 deletions build/android/gyp/aar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
import zipfile

from util import build_utils

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir)))
import action_helpers # build_utils adds //build to sys.path.
import gn_helpers


Expand Down Expand Up @@ -165,7 +163,7 @@ def main():

args = parser.parse_args()

args.resource_exclusion_globs = build_utils.ParseGnList(
args.resource_exclusion_globs = action_helpers.parse_gn_list(
args.resource_exclusion_globs)
if args.ignore_resources:
args.resource_exclusion_globs.append('res/*')
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/aar.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/aar.pydeps build/android/gyp/aar.py
../../action_helpers.py
../../gn_helpers.py
aar.py
util/__init__.py
Expand Down
11 changes: 6 additions & 5 deletions build/android/gyp/aidl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import zipfile

from util import build_utils
import action_helpers # build_utils adds //build to sys.path.


def main(argv):
Expand All @@ -23,18 +24,18 @@ def main(argv):
option_parser.add_option('--includes',
help='Directories to add as import search paths.')
option_parser.add_option('--srcjar', help='Path for srcjar output.')
build_utils.AddDepfileOption(option_parser)
action_helpers.add_depfile_arg(option_parser)
options, args = option_parser.parse_args(argv[1:])

options.includes = build_utils.ParseGnList(options.includes)
options.includes = action_helpers.parse_gn_list(options.includes)

with build_utils.TempDir() as temp_dir:
for f in args:
classname = os.path.splitext(os.path.basename(f))[0]
output = os.path.join(temp_dir, classname + '.java')
aidl_cmd = [options.aidl_path]
aidl_cmd += [
'-p' + s for s in build_utils.ParseGnList(options.imports)
'-p' + s for s in action_helpers.parse_gn_list(options.imports)
]
aidl_cmd += ['-I' + s for s in options.includes]
aidl_cmd += [
Expand All @@ -43,7 +44,7 @@ def main(argv):
]
build_utils.CheckOutput(aidl_cmd)

with build_utils.AtomicOutput(options.srcjar) as f:
with action_helpers.atomic_output(options.srcjar) as f:
with zipfile.ZipFile(f, 'w') as srcjar:
for path in build_utils.FindInDirectory(temp_dir, '*.java'):
with open(path) as fileobj:
Expand All @@ -57,7 +58,7 @@ def main(argv):
include_files = []
for include_dir in options.includes:
include_files += build_utils.FindInDirectory(include_dir, '*.java')
build_utils.WriteDepfile(options.depfile, options.srcjar, include_files)
action_helpers.write_depfile(options.depfile, options.srcjar, include_files)


if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/aidl.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/aidl.pydeps build/android/gyp/aidl.py
../../action_helpers.py
../../gn_helpers.py
aidl.py
util/__init__.py
Expand Down
3 changes: 2 additions & 1 deletion build/android/gyp/allot_native_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import sys

from util import build_utils
import action_helpers # build_utils adds //build to sys.path.


def _ModuleLibrariesPair(arg):
Expand Down Expand Up @@ -145,7 +146,7 @@ def main(args):
help='A pair of parent module name and child module name '
'(format: "<parent>:<child>"). Can be specified multiple times.')
options = parser.parse_args(build_utils.ExpandFileArgs(args))
options.libraries = [(m, build_utils.ParseGnList(l))
options.libraries = [(m, action_helpers.parse_gn_list(l))
for m, l in options.libraries]

# Parse input creating libraries and dependency tree.
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/allot_native_libraries.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/allot_native_libraries.pydeps build/android/gyp/allot_native_libraries.py
../../action_helpers.py
../../gn_helpers.py
allot_native_libraries.py
util/__init__.py
Expand Down
34 changes: 18 additions & 16 deletions build/android/gyp/apkbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from util import build_utils
from util import diff_utils
from util import zipalign
import action_helpers # build_utils adds //build to sys.path.


# Taken from aapt's Package.cpp:
Expand All @@ -33,7 +34,7 @@

def _ParseArgs(args):
parser = argparse.ArgumentParser()
build_utils.AddDepfileOption(parser)
action_helpers.add_depfile_arg(parser)
parser.add_argument('--assets',
help='GYP-list of files to add as assets in the form '
'"srcPath:zipPath", where ":zipPath" is optional.')
Expand Down Expand Up @@ -114,18 +115,18 @@ def _ParseArgs(args):
help='Treat all warnings as errors.')
diff_utils.AddCommandLineFlags(parser)
options = parser.parse_args(args)
options.assets = build_utils.ParseGnList(options.assets)
options.uncompressed_assets = build_utils.ParseGnList(
options.assets = action_helpers.parse_gn_list(options.assets)
options.uncompressed_assets = action_helpers.parse_gn_list(
options.uncompressed_assets)
options.native_lib_placeholders = build_utils.ParseGnList(
options.native_lib_placeholders = action_helpers.parse_gn_list(
options.native_lib_placeholders)
options.secondary_native_lib_placeholders = build_utils.ParseGnList(
options.secondary_native_lib_placeholders = action_helpers.parse_gn_list(
options.secondary_native_lib_placeholders)
options.java_resources = build_utils.ParseGnList(options.java_resources)
options.native_libs = build_utils.ParseGnList(options.native_libs)
options.secondary_native_libs = build_utils.ParseGnList(
options.java_resources = action_helpers.parse_gn_list(options.java_resources)
options.native_libs = action_helpers.parse_gn_list(options.native_libs)
options.secondary_native_libs = action_helpers.parse_gn_list(
options.secondary_native_libs)
options.library_always_compress = build_utils.ParseGnList(
options.library_always_compress = action_helpers.parse_gn_list(
options.library_always_compress)

if not options.android_abi and (options.native_libs or
Expand Down Expand Up @@ -386,9 +387,9 @@ def _GetAssetDetails(assets, uncompressed_assets, fast_align, allow_reads):

if options.only_verify_expectations:
if options.depfile:
build_utils.WriteDepfile(options.depfile,
options.actual_file,
inputs=depfile_deps)
action_helpers.write_depfile(options.depfile,
options.actual_file,
inputs=depfile_deps)
return

# If we are past this point, we are going to actually create the final apk so
Expand All @@ -398,7 +399,8 @@ def _GetAssetDetails(assets, uncompressed_assets, fast_align, allow_reads):
assets, uncompressed_assets, fast_align, allow_reads=True)

# Targets generally do not depend on apks, so no need for only_if_changed.
with build_utils.AtomicOutput(options.output_apk, only_if_changed=False) as f:
with action_helpers.atomic_output(options.output_apk,
only_if_changed=False) as f:
with zipfile.ZipFile(options.resource_apk) as resource_apk, \
zipfile.ZipFile(f, 'w') as out_apk:

Expand Down Expand Up @@ -522,9 +524,9 @@ def copy_resource(zipinfo, out_dir=''):
logging.debug('Moving file into place')

if options.depfile:
build_utils.WriteDepfile(options.depfile,
options.output_apk,
inputs=depfile_deps)
action_helpers.write_depfile(options.depfile,
options.output_apk,
inputs=depfile_deps)


if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/apkbuilder.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/apkbuilder.pydeps build/android/gyp/apkbuilder.py
../../action_helpers.py
../../gn_helpers.py
apkbuilder.py
finalize_apk.py
Expand Down
14 changes: 8 additions & 6 deletions build/android/gyp/bytecode_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import sys

import javac_output_processor

from util import build_utils
from util import server_utils
import action_helpers # build_utils adds //build to sys.path.


def _AddSwitch(parser, val):
Expand Down Expand Up @@ -49,13 +49,15 @@ def main(argv):
force=args.use_build_server):
return

args.sdk_classpath_jars = build_utils.ParseGnList(args.sdk_classpath_jars)
args.direct_classpath_jars = build_utils.ParseGnList(
args.sdk_classpath_jars = action_helpers.parse_gn_list(
args.sdk_classpath_jars)
args.direct_classpath_jars = action_helpers.parse_gn_list(
args.direct_classpath_jars)
args.full_classpath_jars = build_utils.ParseGnList(args.full_classpath_jars)
args.full_classpath_gn_targets = build_utils.ParseGnList(
args.full_classpath_jars = action_helpers.parse_gn_list(
args.full_classpath_jars)
args.full_classpath_gn_targets = action_helpers.parse_gn_list(
args.full_classpath_gn_targets)
args.missing_classes_allowlist = build_utils.ParseGnList(
args.missing_classes_allowlist = action_helpers.parse_gn_list(
args.missing_classes_allowlist)

verbose = '--verbose' if args.verbose else '--not-verbose'
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/bytecode_processor.pydeps
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
../../../third_party/colorama/src/colorama/win32.py
../../../third_party/colorama/src/colorama/winterm.py
../../../tools/android/modularization/convenience/lookup_dep.py
../../action_helpers.py
../../gn_helpers.py
../list_java_targets.py
../pylib/__init__.py
Expand Down
7 changes: 4 additions & 3 deletions build/android/gyp/bytecode_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import sys

from util import build_utils
import action_helpers # build_utils adds //build to sys.path.


def main(argv):
argv = build_utils.ExpandFileArgs(argv[1:])
parser = argparse.ArgumentParser()
build_utils.AddDepfileOption(parser)
action_helpers.add_depfile_arg(parser)
parser.add_argument('--script',
required=True,
help='Path to the java binary wrapper script.')
Expand All @@ -22,8 +23,8 @@ def main(argv):
parser.add_argument('--output-jar', required=True)
args = parser.parse_args(argv)

classpath = build_utils.ParseGnList(args.classpath)
build_utils.WriteDepfile(args.depfile, args.output_jar, inputs=classpath)
classpath = action_helpers.parse_gn_list(args.classpath)
action_helpers.write_depfile(args.depfile, args.output_jar, inputs=classpath)

classpath.append(args.input_jar)
cmd = [
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/bytecode_rewriter.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/bytecode_rewriter.pydeps build/android/gyp/bytecode_rewriter.py
../../action_helpers.py
../../gn_helpers.py
bytecode_rewriter.py
util/__init__.py
Expand Down
1 change: 1 addition & 0 deletions build/android/gyp/check_flag_expectations.pydeps
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/check_flag_expectations.pydeps build/android/gyp/check_flag_expectations.py
../../action_helpers.py
../../gn_helpers.py
check_flag_expectations.py
util/__init__.py
Expand Down
Loading

0 comments on commit 4bc50e2

Please sign in to comment.