diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp index 90adcaa9e5..d8e34b7b33 100644 --- a/tools/releasetools/Android.bp +++ b/tools/releasetools/Android.bp @@ -439,46 +439,6 @@ python_binary_host { ], } -python_binary_host { - name: "merge_builds", - defaults: ["releasetools_binary_defaults"], - srcs: [ - "merge_builds.py", - ], - libs: [ - "releasetools_build_super_image", - "releasetools_common", - ], -} - -python_binary_host { - name: "merge_target_files", - defaults: ["releasetools_binary_defaults"], - srcs: [ - "merge_target_files.py", - ], - libs: [ - "releasetools_add_img_to_target_files", - "releasetools_build_super_image", - "releasetools_check_target_files_vintf", - "releasetools_common", - "releasetools_find_shareduid_violation", - "releasetools_img_from_target_files", - "releasetools_ota_from_target_files", - ], - required: [ - "checkvintf", - "host_init_verifier", - "secilc", - ], - target: { - darwin: { - // libs dep "releasetools_ota_from_target_files" is disabled on darwin - enabled: false, - }, - }, -} - python_binary_host { name: "ota_from_target_files", defaults: [ @@ -597,11 +557,12 @@ python_defaults { "check_partition_sizes.py", "check_target_files_signatures.py", "make_recovery_patch.py", - "merge_target_files.py", "ota_package_parser.py", "sign_apex.py", "sign_target_files_apks.py", "validate_target_files.py", + ":releasetools_merge_sources", + ":releasetools_merge_tests", "test_*.py", ], diff --git a/tools/releasetools/OWNERS b/tools/releasetools/OWNERS index 4ceb6ff07f..59235e0c12 100644 --- a/tools/releasetools/OWNERS +++ b/tools/releasetools/OWNERS @@ -1,6 +1,3 @@ elsk@google.com nhdo@google.com zhangkelvin@google.com - -per-file *merge_*.py = danielnorman@google.com, jgalmes@google.com, rseymour@google.com - diff --git a/tools/releasetools/merge/Android.bp b/tools/releasetools/merge/Android.bp new file mode 100644 index 0000000000..c07d8ee16b --- /dev/null +++ b/tools/releasetools/merge/Android.bp @@ -0,0 +1,69 @@ +// Copyright (C) 2022 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +filegroup { + name: "releasetools_merge_sources", + srcs: [ + "merge_target_files.py", + ], +} + +filegroup { + name: "releasetools_merge_tests", + srcs: [ + "test_merge_target_files.py", + ], +} + +python_binary_host { + name: "merge_target_files", + defaults: ["releasetools_binary_defaults"], + srcs: [":releasetools_merge_sources"], + libs: [ + "releasetools_add_img_to_target_files", + "releasetools_build_super_image", + "releasetools_check_target_files_vintf", + "releasetools_common", + "releasetools_find_shareduid_violation", + "releasetools_img_from_target_files", + "releasetools_ota_from_target_files", + ], + required: [ + "checkvintf", + "host_init_verifier", + "secilc", + ], + target: { + darwin: { + // libs dep "releasetools_ota_from_target_files" is disabled on darwin + enabled: false, + }, + }, +} + +python_binary_host { + name: "merge_builds", + defaults: ["releasetools_binary_defaults"], + srcs: [ + "merge_builds.py", + ], + libs: [ + "releasetools_build_super_image", + "releasetools_common", + ], +} diff --git a/tools/releasetools/merge/OWNERS b/tools/releasetools/merge/OWNERS new file mode 100644 index 0000000000..9012e3ad26 --- /dev/null +++ b/tools/releasetools/merge/OWNERS @@ -0,0 +1,3 @@ +danielnorman@google.com +jgalmes@google.com +rseymour@google.com diff --git a/tools/releasetools/merge_builds.py b/tools/releasetools/merge/merge_builds.py similarity index 100% rename from tools/releasetools/merge_builds.py rename to tools/releasetools/merge/merge_builds.py diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge/merge_target_files.py similarity index 100% rename from tools/releasetools/merge_target_files.py rename to tools/releasetools/merge/merge_target_files.py diff --git a/tools/releasetools/test_merge_target_files.py b/tools/releasetools/merge/test_merge_target_files.py similarity index 100% rename from tools/releasetools/test_merge_target_files.py rename to tools/releasetools/merge/test_merge_target_files.py diff --git a/tools/releasetools/test_utils.py b/tools/releasetools/test_utils.py index 808b392015..e30d2b98e3 100755 --- a/tools/releasetools/test_utils.py +++ b/tools/releasetools/test_utils.py @@ -33,6 +33,8 @@ import common # Some test runner doesn't like outputs from stderr. logging.basicConfig(stream=sys.stdout) +ALLOWED_TEST_SUBDIRS = ('merge',) + # Use ANDROID_BUILD_TOP as an indicator to tell if the needed tools (e.g. # avbtool, mke2fs) are available while running the tests, unless # FORCE_RUN_RELEASETOOLS is set to '1'. Not having the required vars means we @@ -244,9 +246,12 @@ if __name__ == '__main__': # os walk and load them manually. test_modules = [] base_path = os.path.dirname(os.path.realpath(__file__)) + test_dirs = [base_path] + [ + os.path.join(base_path, subdir) for subdir in ALLOWED_TEST_SUBDIRS + ] for dirpath, _, files in os.walk(base_path): for fn in files: - if dirpath == base_path and re.match('test_.*\\.py$', fn): + if dirpath in test_dirs and re.match('test_.*\\.py$', fn): test_modules.append(fn[:-3]) test_suite = unittest.TestLoader().loadTestsFromNames(test_modules)