Merge "Make support for rust modules from Soong."
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 9f9f6f7..7147f6d 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -878,6 +878,7 @@
 ##########################################################
 # Track module-level dependencies.
 # Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
+ifneq (,$(filter deps-license,$(MAKECMDGOALS)))
 ALL_DEPS.MODULES := $(ALL_DEPS.MODULES) $(LOCAL_MODULE)
 ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
   $(ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS) \
@@ -893,6 +894,7 @@
   $(LOCAL_JNI_SHARED_LIBRARIES))
 
 ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files))
+endif
 
 ###########################################################
 ## Take care of my_module_tags
@@ -902,7 +904,7 @@
 ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
 
 # Add this module name to the tag list of each specified tag.
-$(foreach tag,$(my_module_tags),\
+$(foreach tag,$(filter-out optional,$(my_module_tags)),\
     $(eval ALL_MODULE_NAME_TAGS.$(tag) := $$(ALL_MODULE_NAME_TAGS.$(tag)) $(my_register_name)))
 
 ###########################################################
diff --git a/core/instrumentation_test_config_template.xml b/core/instrumentation_test_config_template.xml
index afaa561..18ea676 100644
--- a/core/instrumentation_test_config_template.xml
+++ b/core/instrumentation_test_config_template.xml
@@ -22,8 +22,6 @@
         <option name="test-file-name" value="{MODULE}.apk" />
     </target_preparer>
 
-    {EXTRA_CONFIGS}
-
     <test class="com.android.tradefed.testtype.{TEST_TYPE}" >
         <option name="package" value="{PACKAGE}" />
         <option name="runner" value="{RUNNER}" />
diff --git a/core/rbe.mk b/core/rbe.mk
index fb39d51..231859b 100644
--- a/core/rbe.mk
+++ b/core/rbe.mk
@@ -21,7 +21,7 @@
   else
     rbe_dir := $(HOME)/rbe
   endif
-  RBE_WRAPPER := $(rbe_dir)/rewrapper --labels=type=compile,lang=cpp,compiler=clang
+  RBE_WRAPPER := $(rbe_dir)/rewrapper --labels=type=compile,lang=cpp,compiler=clang --env_var_whitelist=PWD
 
   # Append rewrapper to existing *_WRAPPER variables so it's possible to
   # use both ccache and rewrapper.
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 60646c3..cd98a48 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -359,6 +359,7 @@
     gdbserver \
     init-debug.rc \
     iotop \
+    iperf3 \
     iw \
     logpersist.start \
     logtagd.rc \
diff --git a/target/product/mainline_system.mk b/target/product/mainline_system.mk
index 8bcc212..1ada3c7 100644
--- a/target/product/mainline_system.mk
+++ b/target/product/mainline_system.mk
@@ -73,6 +73,8 @@
     android.hardware.radio@1.0 \
     android.hardware.radio@1.1 \
     android.hardware.radio@1.2 \
+    android.hardware.radio@1.3 \
+    android.hardware.radio@1.4 \
     android.hardware.radio.config@1.0 \
     android.hardware.radio.deprecated@1.0 \
     android.hardware.secure_element@1.0 \
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 4b94ad8..28b1b53 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -40,13 +40,21 @@
 from build_super_image import BuildSuperImage
 
 if sys.hexversion < 0x02070000:
-  print("Python 2.7 or newer is required.", file=sys.stderr)
+  print('Python 2.7 or newer is required.', file=sys.stderr)
   sys.exit(1)
 
 logger = logging.getLogger(__name__)
 
 OPTIONS = common.OPTIONS
 
+OPTIONS.bootable_only = False
+OPTIONS.put_super = None
+OPTIONS.dynamic_partition_list = None
+OPTIONS.super_device_list = None
+OPTIONS.retrofit_dap = None
+OPTIONS.build_super = None
+OPTIONS.sparse_userimages = None
+
 
 def LoadOptions(input_file):
   """Loads information from input_file to OPTIONS.
@@ -56,21 +64,21 @@
   """
   info = OPTIONS.info_dict = common.LoadInfoDict(input_file)
 
-  OPTIONS.put_super = info.get("super_image_in_update_package") == "true"
-  OPTIONS.dynamic_partition_list = info.get("dynamic_partition_list",
-                                            "").strip().split()
-  OPTIONS.super_device_list = info.get("super_block_devices",
-                                       "").strip().split()
-  OPTIONS.retrofit_dap = info.get("dynamic_partition_retrofit") == "true"
-  OPTIONS.build_super = info.get("build_super_partition") == "true"
-  OPTIONS.sparse_userimages = bool(info.get("extfs_sparse_flag"))
+  OPTIONS.put_super = info.get('super_image_in_update_package') == 'true'
+  OPTIONS.dynamic_partition_list = info.get('dynamic_partition_list',
+                                            '').strip().split()
+  OPTIONS.super_device_list = info.get('super_block_devices',
+                                       '').strip().split()
+  OPTIONS.retrofit_dap = info.get('dynamic_partition_retrofit') == 'true'
+  OPTIONS.build_super = info.get('build_super_partition') == 'true'
+  OPTIONS.sparse_userimages = bool(info.get('extfs_sparse_flag'))
 
 
 def CopyInfo(input_tmp, output_zip):
   """Copies the android-info.txt file from the input to the output."""
   common.ZipWrite(
-      output_zip, os.path.join(input_tmp, "OTA", "android-info.txt"),
-      "android-info.txt")
+      output_zip, os.path.join(input_tmp, 'OTA', 'android-info.txt'),
+      'android-info.txt')
 
 
 def CopyUserImages(input_tmp, output_zip):
@@ -80,33 +88,33 @@
     input_tmp: path to the unzipped input.
     output_zip: a ZipFile instance to write images to.
   """
-  dynamic_images = [p + ".img" for p in OPTIONS.dynamic_partition_list]
+  dynamic_images = [p + '.img' for p in OPTIONS.dynamic_partition_list]
 
   # Filter out system_other for launch DAP devices because it is in super image.
-  if not OPTIONS.retrofit_dap and "system" in OPTIONS.dynamic_partition_list:
-    dynamic_images.append("system_other.img")
+  if not OPTIONS.retrofit_dap and 'system' in OPTIONS.dynamic_partition_list:
+    dynamic_images.append('system_other.img')
 
-  images_path = os.path.join(input_tmp, "IMAGES")
+  images_path = os.path.join(input_tmp, 'IMAGES')
   # A target-files zip must contain the images since Lollipop.
   assert os.path.exists(images_path)
   for image in sorted(os.listdir(images_path)):
-    if OPTIONS.bootable_only and image not in ("boot.img", "recovery.img"):
+    if OPTIONS.bootable_only and image not in ('boot.img', 'recovery.img'):
       continue
-    if not image.endswith(".img"):
+    if not image.endswith('.img'):
       continue
     if OPTIONS.put_super:
-      if image == "super_empty.img":
+      if image == 'super_empty.img':
         continue
       if image in dynamic_images:
         continue
-    logger.info("writing %s to archive...", os.path.join("IMAGES", image))
+    logger.info('writing %s to archive...', os.path.join('IMAGES', image))
     common.ZipWrite(output_zip, os.path.join(images_path, image), image)
 
 
 def WriteSuperImages(input_tmp, output_zip):
   """Writes super images from the unzipped input into output_zip.
 
-  This is only done if super_image_in_update_package is set to "true".
+  This is only done if super_image_in_update_package is set to 'true'.
 
   - For retrofit dynamic partition devices, copy split super images from target
     files package.
@@ -122,21 +130,21 @@
 
   if OPTIONS.retrofit_dap:
     # retrofit devices already have split super images under OTA/
-    images_path = os.path.join(input_tmp, "OTA")
+    images_path = os.path.join(input_tmp, 'OTA')
     for device in OPTIONS.super_device_list:
-      image = "super_%s.img" % device
+      image = 'super_%s.img' % device
       image_path = os.path.join(images_path, image)
       assert os.path.exists(image_path)
-      logger.info("writing %s to archive...", os.path.join("OTA", image))
+      logger.info('writing %s to archive...', os.path.join('OTA', image))
       common.ZipWrite(output_zip, image_path, image)
   else:
     # super image for non-retrofit devices aren't in target files package,
     # so build it.
-    super_file = common.MakeTempFile("super_", ".img")
-    logger.info("building super image %s...", super_file)
+    super_file = common.MakeTempFile('super_', '.img')
+    logger.info('building super image %s...', super_file)
     BuildSuperImage(input_tmp, super_file)
-    logger.info("writing super.img to archive...")
-    common.ZipWrite(output_zip, super_file, "super.img")
+    logger.info('writing super.img to archive...')
+    common.ZipWrite(output_zip, super_file, 'super.img')
 
 
 def ImgFromTargetFiles(input_file, output_file):
@@ -150,9 +158,9 @@
     ValueError: On invalid input.
   """
   if not zipfile.is_zipfile(input_file):
-    raise ValueError("%s is not a valid zipfile" % input_file)
+    raise ValueError('%s is not a valid zipfile' % input_file)
 
-  logger.info("Building image zip from target files zip.")
+  logger.info('Building image zip from target files zip.')
 
   # We need files under IMAGES/, OTA/, META/ for img_from_target_files.py.
   # However, common.LoadInfoDict() may read additional files under BOOT/,
@@ -161,7 +169,7 @@
 
   LoadOptions(input_tmp)
   output_zip = zipfile.ZipFile(
-      output_file, "w", compression=zipfile.ZIP_DEFLATED,
+      output_file, 'w', compression=zipfile.ZIP_DEFLATED,
       allowZip64=not OPTIONS.sparse_userimages)
 
   try:
@@ -169,28 +177,23 @@
     CopyUserImages(input_tmp, output_zip)
     WriteSuperImages(input_tmp, output_zip)
   finally:
-    logger.info("cleaning up...")
     common.ZipClose(output_zip)
 
 
 def main(argv):
-  # This allows modifying the value from inner function.
-  bootable_only_array = [False]
 
   def option_handler(o, _):
-    if o in ("-z", "--bootable_zip"):
-      bootable_only_array[0] = True
+    if o in ('-z', '--bootable_zip'):
+      OPTIONS.bootable_only = True
     else:
       return False
     return True
 
   args = common.ParseOptions(argv, __doc__,
-                             extra_opts="z",
-                             extra_long_opts=["bootable_zip"],
+                             extra_opts='z',
+                             extra_long_opts=['bootable_zip'],
                              extra_option_handler=option_handler)
 
-  OPTIONS.bootable_only = bootable_only_array[0]
-
   if len(args) != 2:
     common.Usage(__doc__)
     sys.exit(1)
@@ -199,7 +202,7 @@
 
   ImgFromTargetFiles(args[0], args[1])
 
-  logger.info("done.")
+  logger.info('done.')
 
 
 if __name__ == '__main__':
@@ -207,7 +210,7 @@
     common.CloseInheritedPipes()
     main(sys.argv[1:])
   except common.ExternalError as e:
-    logger.exception("\n   ERROR:\n")
+    logger.exception('\n   ERROR:\n')
     sys.exit(1)
   finally:
     common.Cleanup()