ATest: Support user customize OUT_DIR_COMMON_BASE
When using OUT_DIR_COMMON_BASE to define a customized out directory,
ATest will fail to build module-info.json since it passed a reletive
path to the build system. This patch is to fix the issue that ATest
can always build successfully no matter OUT_DIR_COMMON_BASE is set
or not.
Bug:123555460
Test: m atest
atest hello_world_test
export OUT_DIR_COMMON_BASE=/usr/loca/tmp/out/
atest atest_unittests
Change-Id: I8b41fcad36f73095bdf4f7df0f4128efb76f867c
diff --git a/atest/module_info.py b/atest/module_info.py
index 838f19c..e239214 100644
--- a/atest/module_info.py
+++ b/atest/module_info.py
@@ -60,19 +60,20 @@
"""
module_info_target = None
root_dir = os.environ.get(constants.ANDROID_BUILD_TOP, '/')
- out_dir = os.environ.get(constants.ANDROID_OUT, root_dir)
+ out_dir = os.environ.get(constants.ANDROID_PRODUCT_OUT, root_dir)
module_file_path = os.path.join(out_dir, _MODULE_INFO)
- # Check for custom out dir.
- out_dir_base = os.environ.get(constants.ANDROID_OUT_DIR)
- if out_dir_base is None or not os.path.isabs(out_dir_base):
+ # Check if the user set a custom out directory by comparing the out_dir
+ # to the root_dir.
+ if out_dir.find(root_dir) == 0:
# Make target is simply file path relative to root
module_info_target = os.path.relpath(module_file_path, root_dir)
else:
- # Chances are a custom absolute out dir is used, use
- # ANDROID_PRODUCT_OUT instead.
+ # If the user has set a custom out directory, generate an absolute
+ # path for module info targets.
+ logging.debug('User customized out dir!')
module_file_path = os.path.join(
- os.environ.get('ANDROID_PRODUCT_OUT'), _MODULE_INFO)
+ os.environ.get(constants.ANDROID_PRODUCT_OUT), _MODULE_INFO)
module_info_target = module_file_path
if not os.path.isfile(module_file_path) or force_build:
logging.debug('Generating %s - this is required for '