Revert "Revert "Add prebuilt bootloader var and add bootloader t..."

Revert submission 1411608-revert-1402265-cf-x86-bootloader-XGKLNEQAPF

Reason for revert: Breakage originally caused by change was fixed. Refer to tracking bug for details.
Reverted Changes:
I89e95d4a6:Revert "Add prebuilt bootloader var and add bootlo...
I8fe199351:Revert "Added bootloader binary to cf x86 based ta...

Bug: 166380489
Bug: 164917252
Test: local build and Treehugger build
Change-Id: Ia895aedd77f2ec825aefecaf74c6dfc1ce631c93
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index ab38d0d..5409194 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -58,6 +58,7 @@
 OPTIONS.additional_entries = []
 OPTIONS.bootable_only = False
 OPTIONS.put_super = None
+OPTIONS.put_bootloader = None
 OPTIONS.dynamic_partition_list = None
 OPTIONS.super_device_list = None
 OPTIONS.retrofit_dap = None
@@ -75,6 +76,7 @@
     info = OPTIONS.info_dict = common.LoadInfoDict(input_zip)
 
   OPTIONS.put_super = info.get('super_image_in_update_package') == 'true'
+  OPTIONS.put_bootloader = info.get('bootloader_in_update_package') == 'true'
   OPTIONS.dynamic_partition_list = info.get('dynamic_partition_list',
                                             '').strip().split()
   OPTIONS.super_device_list = info.get('super_block_devices',
@@ -122,9 +124,11 @@
 
   for image_path in [name for name in namelist if name.startswith('IMAGES/')]:
     image = os.path.basename(image_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', 'bootloader'):
       continue
-    if not image.endswith('.img'):
+    if not image.endswith('.img') and image != 'bootloader':
+      continue
+    if image == 'bootloader' and not OPTIONS.put_bootloader:
       continue
     # Filter out super_empty and the images that are already in super partition.
     if OPTIONS.put_super: