blob: 8af520758734a3954166a6fc1a0ee79f18ded13c [file] [log] [blame]
Alan Viverettef5cb0e62017-11-17 15:15:23 -05001#!/usr/bin/python3
Alan Viverette95f6d362017-04-06 09:40:50 -04002
Alan Viverettecd3de262017-08-14 09:51:30 -04003# This script is used to update platform SDK prebuilts, Support Library, and a variety of other
4# prebuilt libraries used by Android's Makefile builds. For details on how to use this script,
5# visit go/update-prebuilts.
Alan Viverette95f6d362017-04-06 09:40:50 -04006import os, sys, getopt, zipfile, re
Alan Viveretted4527e62017-05-11 15:03:25 -04007import argparse
Jiyong Park1d1c9632018-05-29 17:45:27 +09008import glob
Alan Viveretted4527e62017-05-11 15:03:25 -04009import subprocess
shepshaparde4127cf2019-09-03 16:08:44 -070010from shutil import copyfile, rmtree, which, move
Alan Viveretted4527e62017-05-11 15:03:25 -040011from distutils.version import LooseVersion
Alan Viverettef5cb0e62017-11-17 15:15:23 -050012from functools import reduce
Alan Viverette95f6d362017-04-06 09:40:50 -040013
Alan Viverette45837092017-05-12 14:50:53 -040014current_path = 'current'
Andy Wickhamc3c99af2020-10-26 20:47:58 +000015framework_sdk_target = 'sdk_phone_armv7-win_sdk'
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -040016androidx_dir = os.path.join(current_path, 'androidx')
Alan Viverette3e57a4a2017-08-11 15:49:47 -040017extras_dir = os.path.join(current_path, 'extras')
Alan Viverettec1c32b62017-12-20 09:40:36 -050018buildtools_dir = 'tools'
Jeff Gaston553a4372018-03-29 18:34:22 -040019jetifier_dir = os.path.join(buildtools_dir, 'jetifier', 'jetifier-standalone')
Alan Viverette95f6d362017-04-06 09:40:50 -040020
Jeff Gastona68a8d42018-03-23 14:00:13 -040021temp_dir = os.path.join(os.getcwd(), "support_tmp")
22os.chdir(os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
23git_dir = os.getcwd()
24
Alan Viverettecd3de262017-08-14 09:51:30 -040025# See go/fetch_artifact for details on this script.
Alan Viveretted4527e62017-05-11 15:03:25 -040026FETCH_ARTIFACT = '/google/data/ro/projects/android/fetch_artifact'
Jeff Sharkeyabe16df2021-05-25 10:09:03 -060027FETCH_ARTIFACT_BEYOND_CORP = '/usr/bin/fetch_artifact'
Alan Viveretted4527e62017-05-11 15:03:25 -040028
Alan Viverette95f6d362017-04-06 09:40:50 -040029maven_to_make = {
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -040030 # AndroidX
Michael Rosenfeld64b4b0e2021-05-21 17:53:36 -070031 'androidx.benchmark:benchmark-macro': {'name':'androidx.benchmark_benchmark-macro', 'path':'androidx/benchmark/benchmark-macro'},
32 'androidx.benchmark:benchmark-macro-junit4': {'name':'androidx.benchmark_benchmark-macro-junit4', 'path':'androidx/benchmark/benchmark-macro-junit4'},
Dustin Lamda15cd42020-04-01 19:06:23 -070033 'androidx.benchmark:benchmark-common': {'name':'androidx.benchmark_benchmark-common', 'path':'androidx/benchmark/benchmark-common'},
34 'androidx.benchmark:benchmark-junit4': {'name':'androidx.benchmark_benchmark-junit4', 'path':'androidx/benchmark/benchmark-junit4'},
35 'androidx.tracing:tracing': {'name':'androidx.tracing_tracing', 'path':'androidx/tracing/tracing'},
36 'androidx.tracing:tracing-ktx': {'name':'androidx.tracing_tracing-ktx', 'path':'androidx/tracing/tracing-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -040037 'androidx.slice:slice-builders': {'name':'androidx.slice_slice-builders', 'path':'androidx/slice/slice-builders'},
38 'androidx.slice:slice-core': {'name':'androidx.slice_slice-core', 'path':'androidx/slice/slice-core'},
39 'androidx.slice:slice-view': {'name':'androidx.slice_slice-view', 'path':'androidx/slice/slice-view'},
Jeff Gaston07a3cf72018-08-24 14:16:34 -040040 'androidx.remotecallback:remotecallback': {'name':'androidx.remotecallback_remotecallback', 'path':'androidx/remotecallback/remotecallback'},
41 'androidx.remotecallback:remotecallback-processor': {'name':'androidx.remotecallback_remotecallback-processor', 'path':'androidx/remotecallback/remotecallback-processor', 'host':True},
Jeff Gastona0bce602018-08-24 14:05:03 -040042 'androidx.versionedparcelable:versionedparcelable': {'name':'androidx.versionedparcelable_versionedparcelable', 'path':'androidx/versionedparcelable'},
43 'androidx.vectordrawable:vectordrawable-animated': {'name':'androidx.vectordrawable_vectordrawable-animated', 'path':'androidx/vectordrawable/vectordrawable-animated'},
Aurimas Liutikasabaa49f2018-09-18 15:30:20 -070044 'androidx.activity:activity': {'name':'androidx.activity_activity', 'path':'androidx/activity/activity'},
Nate Myren1fa47162019-11-12 11:28:06 -080045 'androidx.activity:activity-ktx': {'name':'androidx.activity_activity-ktx', 'path':'androidx/activity/activity-ktx'},
Tony Mak0f658752019-07-19 11:11:05 +010046 'androidx.annotation:annotation': {'name':'androidx.annotation_annotation', 'path':'androidx/annotation/annotation', 'host_and_device' : True},
Dustin Lamda15cd42020-04-01 19:06:23 -070047 'androidx.annotation:annotation-experimental': {'name':'androidx.annotation_annotation-experimental', 'path':'androidx/annotation/annotation-experimental'},
Jeff Gastona0bce602018-08-24 14:05:03 -040048 'androidx.asynclayoutinflater:asynclayoutinflater': {'name':'androidx.asynclayoutinflater_asynclayoutinflater', 'path':'androidx/asynclayoutinflater/asynclayoutinflater'},
Jeff Gastona0bce602018-08-24 14:05:03 -040049 'androidx.collection:collection': {'name':'androidx.collection_collection', 'path':'androidx/collection/collection'},
Nate Myren1fa47162019-11-12 11:28:06 -080050 'androidx.collection:collection-ktx': {'name':'androidx.collection_collection-ktx', 'path':'androidx/collection/collection-ktx'},
Aurimas Liutikasd9124762018-09-28 15:31:35 -070051 'androidx.concurrent:concurrent-futures': {'name':'androidx.concurrent_concurrent-futures', 'path':'androidx/concurrent/concurrent-futures'},
Aurimas Liutikas8af28d32019-06-06 14:04:01 -070052 'androidx.concurrent:concurrent-listenablefuture-callback': {'name':'androidx.concurrent_concurrent-listenablefuture-callback', 'path':'androidx/concurrent/concurrent-listenablefuture-callback'},
53 'androidx.concurrent:concurrent-listenablefuture': {'name':'androidx.concurrent_concurrent-listenablefuture', 'path':'androidx/concurrent/concurrent-listenablefuture'},
Jeff Gastona0bce602018-08-24 14:05:03 -040054 'androidx.core:core': {'name':'androidx.core_core', 'path':'androidx/core/core'},
Yvan Hsueh5efba6e2020-04-30 01:17:47 +080055 'androidx.core:core-animation': {'name':'androidx.core_core-animation', 'path':'androidx/core/core-animation'},
Nate Myren1fa47162019-11-12 11:28:06 -080056 'androidx.core:core-ktx': {'name':'androidx.core_core-ktx', 'path':'androidx/core/core-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -040057 'androidx.contentpaging:contentpaging': {'name':'androidx.contentpaging_contentpaging', 'path':'androidx/contentpaging/contentpaging'},
58 'androidx.coordinatorlayout:coordinatorlayout': {'name':'androidx.coordinatorlayout_coordinatorlayout', 'path':'androidx/coordinatorlayout/coordinatorlayout'},
59 'androidx.legacy:legacy-support-core-ui': {'name':'androidx.legacy_legacy-support-core-ui', 'path':'androidx/legacy/legacy-support-core-ui'},
60 'androidx.legacy:legacy-support-core-utils': {'name':'androidx.legacy_legacy-support-core-utils', 'path':'androidx/legacy/legacy-support-core-utils'},
61 'androidx.cursoradapter:cursoradapter': {'name':'androidx.cursoradapter_cursoradapter', 'path':'androidx/cursoradapter/cursoradapter'},
62 'androidx.browser:browser': {'name':'androidx.browser_browser', 'path':'androidx/browser/browser'},
63 'androidx.customview:customview': {'name':'androidx.customview_customview', 'path':'androidx/customview/customview'},
64 'androidx.documentfile:documentfile': {'name':'androidx.documentfile_documentfile', 'path':'androidx/documentfile/documentfile'},
65 'androidx.drawerlayout:drawerlayout': {'name':'androidx.drawerlayout_drawerlayout', 'path':'androidx/drawerlayout/drawerlayout'},
66 'androidx.dynamicanimation:dynamicanimation': {'name':'androidx.dynamicanimation_dynamicanimation', 'path':'androidx/dynamicanimation/dynamicanimation'},
67 'androidx.emoji:emoji': {'name':'androidx.emoji_emoji', 'path':'androidx/emoji/emoji'},
68 'androidx.emoji:emoji-appcompat': {'name':'androidx.emoji_emoji-appcompat', 'path':'androidx/emoji/emoji-appcompat'},
69 'androidx.emoji:emoji-bundled': {'name':'androidx.emoji_emoji-bundled', 'path':'androidx/emoji/emoji-bundled'},
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -070070 'androidx.emoji2:emoji2': {'name':'androidx.emoji2_emoji', 'path':'androidx/emoji2/emoji2'},
71 'androidx.emoji2:emoji2-views-helper': {'name':'androidx.emoji2_emoji2-views-helpe', 'path':'androidx/emoji2/emoji2-views-helper'},
Jeff Gastona0bce602018-08-24 14:05:03 -040072 'androidx.exifinterface:exifinterface': {'name':'androidx.exifinterface_exifinterface', 'path':'androidx/exifinterface/exifinterface'},
73 'androidx.fragment:fragment': {'name':'androidx.fragment_fragment', 'path':'androidx/fragment/fragment'},
Nate Myren1fa47162019-11-12 11:28:06 -080074 'androidx.fragment:fragment-ktx': {'name':'androidx.fragment_fragment-ktx', 'path':'androidx/fragment/fragment-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -040075 'androidx.heifwriter:heifwriter': {'name':'androidx.heifwriter_heifwriter', 'path':'androidx/heifwriter/heifwriter'},
76 'androidx.interpolator:interpolator': {'name':'androidx.interpolator_interpolator', 'path':'androidx/interpolator/interpolator'},
77 'androidx.loader:loader': {'name':'androidx.loader_loader', 'path':'androidx/loader/loader'},
78 'androidx.localbroadcastmanager:localbroadcastmanager': {'name':'androidx.localbroadcastmanager_localbroadcastmanager', 'path':'androidx/localbroadcastmanager/localbroadcastmanager'},
79 'androidx.media:media': {'name':'androidx.media_media', 'path':'androidx/media/media'},
Oussama Ben Abdelbaki09fffcb2019-05-13 15:11:37 -040080 'androidx.media2:media2-player': {'name':'androidx.media2_media2-player', 'path':'androidx/media2/media2-player'},
81 'androidx.media2:media2-session': {'name':'androidx.media2_media2-session', 'path':'androidx/media2/media2-session'},
82 'androidx.media2:media2-common': {'name':'androidx.media2_media2-common', 'path':'androidx/media2/media2-common'},
Jeff Gastona0bce602018-08-24 14:05:03 -040083 'androidx.media2:media2-exoplayer': {'name':'androidx.media2_media2-exoplayer', 'path':'androidx/media2/media2-exoplayer'},
Gyumin Sim1752eca2018-12-13 11:34:10 +090084 'androidx.media2:media2-widget': {'name':'androidx.media2_media2-widget', 'path':'androidx/media2/media2-widget'},
Nate Myren1fa47162019-11-12 11:28:06 -080085 'androidx.navigation:navigation-common': {'name':'androidx.navigation_navigation-common', 'path':'androidx/navigation/navigation-common'},
86 'androidx.navigation:navigation-common-ktx': {'name':'androidx.navigation_navigation-common-ktx', 'path':'androidx/navigation/navigation-common-ktx'},
87 'androidx.navigation:navigation-fragment': {'name':'androidx.navigation_navigation-fragment', 'path':'androidx/navigation/navigation-fragment'},
88 'androidx.navigation:navigation-fragment-ktx': {'name':'androidx.navigation_navigation-fragment-ktx', 'path':'androidx/navigation/navigation-fragment-ktx'},
89 'androidx.navigation:navigation-runtime': {'name':'androidx.navigation_navigation-runtime', 'path':'androidx/navigation/navigation-runtime'},
90 'androidx.navigation:navigation-runtime-ktx': {'name':'androidx.navigation_navigation-runtime-ktx', 'path':'androidx/navigation/navigation-runtime-ktx'},
91 'androidx.navigation:navigation-ui': {'name':'androidx.navigation_navigation-ui', 'path':'androidx/navigation/navigation-ui'},
92 'androidx.navigation:navigation-ui-ktx': {'name':'androidx.navigation_navigation-ui-ktx', 'path':'androidx/navigation/navigation-ui-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -040093 'androidx.percentlayout:percentlayout': {'name':'androidx.percentlayout_percentlayout', 'path':'androidx/percentlayout/percentlayout'},
94 'androidx.print:print': {'name':'androidx.print_print', 'path':'androidx/print/print'},
95 'androidx.recommendation:recommendation': {'name':'androidx.recommendation_recommendation', 'path':'androidx/recommendation/recommendation'},
96 'androidx.recyclerview:recyclerview-selection': {'name':'androidx.recyclerview_recyclerview-selection', 'path':'androidx/recyclerview/recyclerview-selection'},
Oussama Ben Abdelbaki00f9b392019-03-18 14:45:12 -040097 'androidx.savedstate:savedstate': {'name':'androidx.savedstate_savedstate', 'path':'androidx/savedstate/savedstate'},
Chang Li0a700902020-10-07 16:03:26 +010098 'androidx.savedstate:savedstate-ktx': {'name':'androidx.savedstate_savedstate-ktx', 'path':'androidx/savedstate/savedstate-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -040099 'androidx.slidingpanelayout:slidingpanelayout': {'name':'androidx.slidingpanelayout_slidingpanelayout', 'path':'androidx/slidingpanelayout/slidingpanelayout'},
100 'androidx.swiperefreshlayout:swiperefreshlayout': {'name':'androidx.swiperefreshlayout_swiperefreshlayout', 'path':'androidx/swiperefreshlayout/swiperefreshlayout'},
101 'androidx.textclassifier:textclassifier': {'name':'androidx.textclassifier_textclassifier', 'path':'androidx/textclassifier/textclassifier'},
102 'androidx.transition:transition': {'name':'androidx.transition_transition', 'path':'androidx/transition/transition'},
103 'androidx.tvprovider:tvprovider': {'name':'androidx.tvprovider_tvprovider', 'path':'androidx/tvprovider/tvprovider'},
104 'androidx.legacy:legacy-support-v13': {'name':'androidx.legacy_legacy-support-v13', 'path':'androidx/legacy/legacy-support-v13'},
105 'androidx.legacy:legacy-preference-v14': {'name':'androidx.legacy_legacy-preference-v14', 'path':'androidx/legacy/legacy-preference-v14'},
106 'androidx.leanback:leanback': {'name':'androidx.leanback_leanback', 'path':'androidx/leanback/leanback'},
107 'androidx.leanback:leanback-preference': {'name':'androidx.leanback_leanback-preference', 'path':'androidx/leanback/leanback-preference'},
108 'androidx.legacy:legacy-support-v4': {'name':'androidx.legacy_legacy-support-v4', 'path':'androidx/legacy/legacy-support-v4'},
109 'androidx.appcompat:appcompat': {'name':'androidx.appcompat_appcompat', 'path':'androidx/appcompat/appcompat'},
Oussama Ben Abdelbaki61551b82019-02-12 15:56:27 -0500110 'androidx.appcompat:appcompat-resources': {'name':'androidx.appcompat_appcompat-resources', 'path':'androidx/appcompat/appcompat-resources'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400111 'androidx.cardview:cardview': {'name':'androidx.cardview_cardview', 'path':'androidx/cardview/cardview'},
112 'androidx.gridlayout:gridlayout': {'name':'androidx.gridlayout_gridlayout', 'path':'androidx/gridlayout/gridlayout'},
113 'androidx.mediarouter:mediarouter': {'name':'androidx.mediarouter_mediarouter', 'path':'androidx/mediarouter/mediarouter'},
114 'androidx.palette:palette': {'name':'androidx.palette_palette', 'path':'androidx/palette/palette'},
115 'androidx.preference:preference': {'name':'androidx.preference_preference', 'path':'androidx/preference/preference'},
116 'androidx.recyclerview:recyclerview': {'name':'androidx.recyclerview_recyclerview', 'path':'androidx/recyclerview/recyclerview'},
117 'androidx.vectordrawable:vectordrawable': {'name':'androidx.vectordrawable_vectordrawable', 'path':'androidx/vectordrawable/vectordrawable'},
118 'androidx.viewpager:viewpager': {'name':'androidx.viewpager_viewpager', 'path':'androidx/viewpager/viewpager'},
Fabian Kozynskie514c122020-03-04 14:41:08 -0500119 'androidx.viewpager2:viewpager2': {'name':'androidx.viewpager2_viewpager2', 'path':'androidx/viewpager2/viewpager2'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400120 'androidx.wear:wear': {'name':'androidx.wear_wear', 'path':'androidx/wear/wear'},
Josh Yang7660f122021-06-11 11:14:29 -0700121 'androidx.wear:wear-ongoing': {'name':'androidx.wear_wear-ongoing', 'path':'androidx/wear/wear-ongoing'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400122 'androidx.webkit:webkit': {'name':'androidx.webkit_webkit', 'path':'androidx/webkit/webkit'},
Kevin Chynb6ae85d2018-10-02 12:12:20 -0700123 'androidx.biometric:biometric': {'name':'androidx.biometric_biometric', 'path':'androidx/biometric/biometric'},
Adam He7dec9ff2020-01-27 14:05:45 -0800124 'androidx.autofill:autofill': {'name':'androidx.autofill_autofill', 'path':'androidx/autofill/autofill'},
Alexander Dorokhine2cf37af2020-08-03 14:16:37 -0700125 'androidx.appsearch:appsearch': {'name':'androidx.appsearch_appsearch', 'path':'androidx/appsearch/appsearch'},
Winson Chunge7588602021-01-08 09:57:25 -0800126 'androidx.appsearch:appsearch-local-storage': {'name':'androidx.appsearch_appsearch_local_storage', 'path':'androidx/appsearch/appsearch/appsearch-local-storage'},
Alexander Dorokhineebb69062021-02-03 07:10:32 +0000127 'androidx.appsearch:appsearch-platform-storage': {'name':'androidx.appsearch_appsearch_platform_storage', 'path':'androidx/appsearch/appsearch/appsearch-platform-storage'},
Alexander Dorokhine2cf37af2020-08-03 14:16:37 -0700128 'androidx.appsearch:appsearch-compiler': {'name':'androidx.appsearch_appsearch-compiler', 'path':'androidx/appsearch/appsearch-compiler', 'host' : True},
Calvin Huangb7946e82021-04-01 01:02:21 +0000129 'androidx.car.app:app': {'name':'androidx.car.app_app', 'path':'androidx/car/app/app'},
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -0700130 'androidx.car.app:app-automotive': {'name':'androidx.car.app_app-automotive', 'path':'androidx/car/app/app-automotive'},
Calvin Huangb7946e82021-04-01 01:02:21 +0000131 'androidx.car.app:app-testing': {'name':'androidx.car.app_app-testing', 'path':'androidx/car/app/app-testing'},
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -0700132 'androidx.startup:startup-runtime': {'name':'androidx.startup_startup-runtime', 'path':'androidx/startup/startup-runtime'},
133 'androidx.window:window': {'name':'androidx.window_window', 'path':'androidx/window/window'},
134 'androidx.resourceinspection:resourceinspection-annotation': {'name':'androidx.resourceinspection_resourceinspection-annotation', 'path':'androidx/resourceinspection/resourceinspection-annotation'},
135 'androidx.profileinstaller:profileinstaller': {'name':'androidx.profileinstaller_profileinstaller', 'path':'androidx/profileinstaller/profileinstaller'},
136
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400137 # AndroidX for Multidex
Jeff Gastona0bce602018-08-24 14:05:03 -0400138 'androidx.multidex:multidex': {'name':'androidx-multidex_multidex', 'path':'androidx/multidex/multidex'},
139 'androidx.multidex:multidex-instrumentation': {'name':'androidx-multidex_multidex-instrumentation', 'path':'androidx/multidex/multidex-instrumentation'},
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400140
141 # AndroidX for Constraint Layout
Jeff Gastona0bce602018-08-24 14:05:03 -0400142 'androidx.constraintlayout:constraintlayout': {'name':'androidx-constraintlayout_constraintlayout', 'path':'androidx/constraintlayout/constraintlayout'},
143 'androidx.constraintlayout:constraintlayout-solver': {'name':'androidx-constraintlayout_constraintlayout-solver', 'path':'androidx/constraintlayout/constraintlayout-solver'},
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400144
145 # AndroidX for Architecture Components
Jeff Gastona0bce602018-08-24 14:05:03 -0400146 'androidx.arch.core:core-common': {'name':'androidx.arch.core_core-common', 'path':'androidx/arch/core/core-common'},
147 'androidx.arch.core:core-runtime': {'name':'androidx.arch.core_core-runtime', 'path':'androidx/arch/core/core-runtime'},
148 'androidx.lifecycle:lifecycle-common': {'name':'androidx.lifecycle_lifecycle-common', 'path':'androidx/lifecycle/lifecycle-common'},
149 'androidx.lifecycle:lifecycle-common-java8': {'name':'androidx.lifecycle_lifecycle-common-java8', 'path':'androidx/lifecycle/lifecycle-common-java8'},
150 'androidx.lifecycle:lifecycle-extensions': {'name':'androidx.lifecycle_lifecycle-extensions', 'path':'androidx/lifecycle/lifecycle-extensions'},
151 'androidx.lifecycle:lifecycle-livedata': {'name':'androidx.lifecycle_lifecycle-livedata', 'path':'androidx/lifecycle/lifecycle-livedata'},
Nate Myren1fa47162019-11-12 11:28:06 -0800152 'androidx.lifecycle:lifecycle-livedata-ktx': {'name':'androidx.lifecycle_lifecycle-livedata-ktx', 'path':'androidx/lifecycle/lifecycle-livedata-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400153 'androidx.lifecycle:lifecycle-livedata-core': {'name':'androidx.lifecycle_lifecycle-livedata-core', 'path':'androidx/lifecycle/lifecycle-livedata-core'},
Nate Myren1fa47162019-11-12 11:28:06 -0800154 'androidx.lifecycle:lifecycle-livedata-core-ktx': {'name':'androidx.lifecycle_lifecycle-livedata-core-ktx', 'path':'androidx/lifecycle/lifecycle-livedata-core-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400155 'androidx.lifecycle:lifecycle-process': {'name':'androidx.lifecycle_lifecycle-process', 'path':'androidx/lifecycle/lifecycle-process'},
156 'androidx.lifecycle:lifecycle-runtime': {'name':'androidx.lifecycle_lifecycle-runtime', 'path':'androidx/lifecycle/lifecycle-runtime'},
Nate Myren1fa47162019-11-12 11:28:06 -0800157 'androidx.lifecycle:lifecycle-runtime-ktx': {'name':'androidx.lifecycle_lifecycle-runtime-ktx', 'path':'androidx/lifecycle/lifecycle-runtime-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400158 'androidx.lifecycle:lifecycle-service': {'name':'androidx.lifecycle_lifecycle-service', 'path':'androidx/lifecycle/lifecycle-service'},
159 'androidx.lifecycle:lifecycle-viewmodel': {'name':'androidx.lifecycle_lifecycle-viewmodel', 'path':'androidx/lifecycle/lifecycle-viewmodel'},
Nate Myren1fa47162019-11-12 11:28:06 -0800160 'androidx.lifecycle:lifecycle-viewmodel-ktx': {'name':'androidx.lifecycle_lifecycle-viewmodel-ktx', 'path':'androidx/lifecycle/lifecycle-viewmodel-ktx'},
Aurimas Liutikasb5836e22019-09-06 09:00:45 -0700161 'androidx.lifecycle:lifecycle-viewmodel-savedstate': {'name':'androidx.lifecycle_lifecycle-viewmodel-savedstate', 'path':'androidx/lifecycle/lifecycle-viewmodel-savedstate'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400162 'androidx.paging:paging-common': {'name':'androidx.paging_paging-common', 'path':'androidx/paging/paging-common'},
Aurimas Liutikasb5836e22019-09-06 09:00:45 -0700163 'androidx.paging:paging-common-ktx': {'name':'androidx.paging_paging-common-ktx', 'path':'androidx/paging/paging-common-ktx'},
Jeff Gastona0bce602018-08-24 14:05:03 -0400164 'androidx.paging:paging-runtime': {'name':'androidx.paging_paging-runtime', 'path':'androidx/paging/paging-runtime'},
165 'androidx.sqlite:sqlite': {'name':'androidx.sqlite_sqlite', 'path':'androidx/sqlite/sqlite'},
166 'androidx.sqlite:sqlite-framework': {'name':'androidx.sqlite_sqlite-framework', 'path':'androidx/sqlite/sqlite-framework'},
Tony Mak0f658752019-07-19 11:11:05 +0100167 'androidx.room:room-common': {'name':'androidx.room_room-common', 'path':'androidx/room/room-common', 'host_and_device' : True},
168 'androidx.room:room-compiler': {'name':'androidx.room_room-compiler', 'path':'androidx/room/room-compiler', 'host' : True},
169 'androidx.room:room-migration': {'name':'androidx.room_room-migration', 'path':'androidx/room/room-migration', 'host_and_device' : True},
Jeff Gastona0bce602018-08-24 14:05:03 -0400170 'androidx.room:room-runtime': {'name':'androidx.room_room-runtime', 'path':'androidx/room/room-runtime'},
171 'androidx.room:room-testing': {'name':'androidx.room_room-testing', 'path':'androidx/room/room-testing'},
Ming-Shin Lu97a1dc02020-09-11 21:55:21 +0800172 'androidx.room:room-compiler-processing': {'name':'androidx.room_room-compiler-processing', 'path':'androidx/room/room-compiler-processing', 'host' : True},
Chang Li0a700902020-10-07 16:03:26 +0100173 'androidx.work:work-runtime': {'name':'androidx.work_work-runtime', 'path':'androidx/work/work-runtime'},
174 'androidx.work:work-runtime-ktx': {'name':'androidx.work_work-runtime-ktx', 'path':'androidx/work/work-runtime-ktx'},
175 'androidx.work:work-testing': {'name':'androidx.work_work-testing', 'path':'androidx/work/work-testing'},
Allenab72f012018-01-29 18:10:23 -0800176
Alan Viverette19ecd502018-01-05 13:52:16 -0500177 # Lifecycle
Alan Viverettec7e88f12018-02-13 15:29:50 -0500178 # Missing dependencies:
179 # - auto-common
180 # - javapoet
Jeff Gastona0bce602018-08-24 14:05:03 -0400181 #'android.arch.lifecycle:compiler': {'name':'android-arch-lifecycle-compiler', 'path':'arch-lifecycle/compiler'},
Alan Viverettec7e88f12018-02-13 15:29:50 -0500182 # Missing dependencies:
183 # - reactive-streams
Jeff Gastona0bce602018-08-24 14:05:03 -0400184 #'android.arch.lifecycle:reactivestreams': 'android-arch-lifecycle-reactivestreams','arch-lifecycle/reactivestreams',
Allenab72f012018-01-29 18:10:23 -0800185
Alan Viverette19ecd502018-01-05 13:52:16 -0500186 # Room
Alan Viverettec7e88f12018-02-13 15:29:50 -0500187 # Missing dependencies:
188 # - auto-common
189 # - javapoet
190 # - antlr4
191 # - kotlin-metadata
192 # - commons-codec
Jeff Gastona0bce602018-08-24 14:05:03 -0400193 #'android.arch.persistence.room:compiler': {'name':'android-arch-room-compiler', 'path':'arch-room/compiler'},
Alan Viverettec7e88f12018-02-13 15:29:50 -0500194 # Missing dependencies:
195 # - rxjava
Jeff Gastona0bce602018-08-24 14:05:03 -0400196 #'android.arch.persistence.room:rxjava2': {'name':'android-arch-room-rxjava2', 'path':'arch-room/rxjava2'},
Allenab72f012018-01-29 18:10:23 -0800197
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400198 # Third-party dependencies
Jeff Gastona0bce602018-08-24 14:05:03 -0400199 'com.google.android:flexbox': {'name':'flexbox', 'path':'flexbox'},
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400200
Jeff Gastonfa7c7e82018-04-06 13:35:48 -0400201 # Androidx Material Design Components
Jeff Gastona0bce602018-08-24 14:05:03 -0400202 'com.google.android.material:material': {'name':'com.google.android.material_material', 'path':'com/google/android/material/material'},
Alan Viverette95f6d362017-04-06 09:40:50 -0400203}
204
205# Always remove these files.
206blacklist_files = [
207 'annotations.zip',
208 'public.txt',
209 'R.txt',
Alan Viverette44ad4e42017-08-09 17:45:00 -0400210 'AndroidManifest.xml',
Alan Viverettef48d9b42017-08-17 14:45:46 -0400211 os.path.join('libs','noto-emoji-compat-java.jar')
Alan Viverette95f6d362017-04-06 09:40:50 -0400212]
213
Alan Viverette44ad4e42017-08-09 17:45:00 -0400214artifact_pattern = re.compile(r"^(.+?)-(\d+\.\d+\.\d+(?:-\w+\d+)?(?:-[\d.]+)*)\.(jar|aar)$")
Alan Viverette95f6d362017-04-06 09:40:50 -0400215
Alan Viverettec960cfb2017-12-04 13:09:22 -0500216
217class MavenLibraryInfo:
Jeff Gastonc302bb92018-03-23 13:53:48 -0400218 def __init__(self, key, group_id, artifact_id, version, dir, repo_dir, file):
Alan Viverettec960cfb2017-12-04 13:09:22 -0500219 self.key = key
220 self.group_id = group_id
221 self.artifact_id = artifact_id
222 self.version = version
Jeff Gastonc302bb92018-03-23 13:53:48 -0400223 self.dir = dir
Alan Viverettec960cfb2017-12-04 13:09:22 -0500224 self.repo_dir = repo_dir
225 self.file = file
226
227
Alan Viverettef5cb0e62017-11-17 15:15:23 -0500228def print_e(*args, **kwargs):
229 print(*args, file=sys.stderr, **kwargs)
230
Alan Viverette95f6d362017-04-06 09:40:50 -0400231
232def touch(fname, times=None):
233 with open(fname, 'a'):
234 os.utime(fname, times)
235
236
Alan Viverette45837092017-05-12 14:50:53 -0400237def path(*path_parts):
238 return reduce((lambda x, y: os.path.join(x, y)), path_parts)
239
240
Alan Viverettecd3de262017-08-14 09:51:30 -0400241def flatten(list):
242 return reduce((lambda x, y: "%s %s" % (x, y)), list)
243
244
Alan Viverette45837092017-05-12 14:50:53 -0400245def rm(path):
246 if os.path.isdir(path):
247 rmtree(path)
248 elif os.path.exists(path):
249 os.remove(path)
250
251
252def mv(src_path, dst_path):
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400253 if os.path.exists(dst_path):
Alan Viverettecd3de262017-08-14 09:51:30 -0400254 rm(dst_path)
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400255 if not os.path.exists(os.path.dirname(dst_path)):
256 os.makedirs(os.path.dirname(dst_path))
Jiyong Park1d1c9632018-05-29 17:45:27 +0900257 for f in (glob.glob(src_path)):
258 if '*' in dst_path:
259 dst = os.path.join(os.path.dirname(dst_path), os.path.basename(f))
260 else:
261 dst = dst_path
shepshaparde4127cf2019-09-03 16:08:44 -0700262 move(f, dst)
Alan Viverette45837092017-05-12 14:50:53 -0400263
264
Jeff Gastonc302bb92018-03-23 13:53:48 -0400265def detect_artifacts(maven_repo_dirs):
Alan Viveretted4527e62017-05-11 15:03:25 -0400266 maven_lib_info = {}
267
Dan Willemsen814152e2017-11-06 13:22:11 -0800268 # Find the latest revision for each artifact, remove others
Jeff Gastonc302bb92018-03-23 13:53:48 -0400269 for repo_dir in maven_repo_dirs:
Dan Willemsen814152e2017-11-06 13:22:11 -0800270 for root, dirs, files in os.walk(repo_dir):
271 for file in files:
Alan Viverettec960cfb2017-12-04 13:09:22 -0500272 if file[-4:] == ".pom":
273 # Read the POM (hack hack hack).
274 group_id = ''
275 artifact_id = ''
276 version = ''
277 file = os.path.join(root, file)
278 with open(file) as pom_file:
279 for line in pom_file:
280 if line[:11] == ' <groupId>':
281 group_id = line[11:-11]
282 elif line[:14] == ' <artifactId>':
283 artifact_id = line[14:-14]
284 elif line[:11] == ' <version>':
285 version = line[11:-11]
286 if group_id == '' or artifact_id == '' or version == '':
287 print_e('Failed to find Maven artifact data in ' + file)
288 continue
Alan Viverette95f6d362017-04-06 09:40:50 -0400289
Alan Viverettec960cfb2017-12-04 13:09:22 -0500290 # Locate the artifact.
291 artifact_file = file[:-4]
292 if os.path.exists(artifact_file + '.jar'):
293 artifact_file = artifact_file + '.jar'
294 elif os.path.exists(artifact_file + '.aar'):
295 artifact_file = artifact_file + '.aar'
296 else:
297 print_e('Failed to find artifact for ' + artifact_file)
298 continue
299
300 # Make relative to root.
301 artifact_file = artifact_file[len(root) + 1:]
302
303 # Find the mapping.
304 group_artifact = group_id + ':' + artifact_id
Jeff Gaston3e622ba2018-03-26 23:24:46 -0400305 if group_artifact in maven_to_make:
Alan Viverettec960cfb2017-12-04 13:09:22 -0500306 key = group_artifact
Jeff Gaston3e622ba2018-03-26 23:24:46 -0400307 elif artifact_id in maven_to_make:
308 key = artifact_id
Alan Viverettec960cfb2017-12-04 13:09:22 -0500309 else:
310 print_e('Failed to find artifact mapping for ' + group_artifact)
311 continue
312
313 # Store the latest version.
314 version = LooseVersion(version)
315 if key not in maven_lib_info \
316 or version > maven_lib_info[key].version:
317 maven_lib_info[key] = MavenLibraryInfo(key, group_id, artifact_id, version,
318 root, repo_dir, artifact_file)
Alan Viverette95f6d362017-04-06 09:40:50 -0400319
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400320 return maven_lib_info
321
322
Colin Cross59b59db2018-04-24 13:58:05 -0700323def transform_maven_repos(maven_repo_dirs, transformed_dir, extract_res=True, include_static_deps=True):
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400324 cwd = os.getcwd()
325
326 # Use a temporary working directory.
Jeff Gastonc302bb92018-03-23 13:53:48 -0400327 maven_lib_info = detect_artifacts(maven_repo_dirs)
Jeff Gastona68a8d42018-03-23 14:00:13 -0400328 working_dir = temp_dir
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400329
Alan Viverettec960cfb2017-12-04 13:09:22 -0500330 if not maven_lib_info:
331 print_e('Failed to detect artifacts')
332 return False
333
Jeff Gastonc302bb92018-03-23 13:53:48 -0400334 # extract some files (for example, AndroidManifest.xml) from any relevant artifacts
Alan Viveretted4527e62017-05-11 15:03:25 -0400335 for info in maven_lib_info.values():
Alan Viveretted8ce7222017-12-11 17:24:43 -0500336 transform_maven_lib(working_dir, info, extract_res)
Dan Willemsen814152e2017-11-06 13:22:11 -0800337
Colin Cross74683bc2018-04-11 17:36:18 -0700338 # generate a single Android.bp that specifies to use all of the above artifacts
339 makefile = os.path.join(working_dir, 'Android.bp')
Alan Viverette4ec9a172018-02-20 16:19:31 -0500340 with open(makefile, 'w') as f:
Anton Hanssonbd2021c2021-04-06 19:21:34 +0000341 args = ["pom2bp"]
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -0700342 args.extend(["-sdk-version", "31"])
Anton Hanssonbd2021c2021-04-06 19:21:34 +0000343 args.extend(["-default-min-sdk-version", "24"])
Jeff Gaston1cc06092018-03-28 15:51:02 -0400344 if include_static_deps:
345 args.append("-static-deps")
Jeff Gaston54868ee2018-04-25 19:43:35 -0400346 rewriteNames = sorted([name for name in maven_to_make if ":" in name] + [name for name in maven_to_make if ":" not in name])
Jeff Gastona0bce602018-08-24 14:05:03 -0400347 args.extend(["-rewrite=^" + name + "$=" + maven_to_make[name]['name'] for name in rewriteNames])
Colin Cross5542fc22021-04-14 11:36:46 -0700348 args.extend(["-rewrite=^auto-common$=auto_common"])
349 args.extend(["-rewrite=^auto-value-annotations$=auto_value_annotations"])
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -0700350 args.extend(["-rewrite=^com.google.auto.value:auto-value$=auto_value_plugin"])
Dustin Lamda15cd42020-04-01 19:06:23 -0700351 args.extend(["-rewrite=^monitor$=androidx.test.monitor"])
352 args.extend(["-rewrite=^rules$=androidx.test.rules"])
353 args.extend(["-rewrite=^runner$=androidx.test.runner"])
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -0700354 args.extend(["-rewrite=^androidx.test:core$=androidx.test.core"])
Yiqun Wu9e020fe2020-11-18 21:16:08 +0000355 args.extend(["-rewrite=^com.squareup:javapoet$=javapoet"])
Aurimas Liutikasd9124762018-09-28 15:31:35 -0700356 args.extend(["-rewrite=^com.google.guava:listenablefuture$=guava-listenablefuture-prebuilt-jar"])
Tony Mak0f658752019-07-19 11:11:05 +0100357 args.extend(["-rewrite=^sqlite-jdbc$=xerial-sqlite-jdbc"])
Tony Mak0f658752019-07-19 11:11:05 +0100358 args.extend(["-rewrite=^gson$=gson-prebuilt-jar"])
Sunny Goyal6667ddb2020-03-03 15:15:54 -0800359 args.extend(["-rewrite=^com.intellij:annotations$=jetbrains-annotations"])
Aurimas Liutikas6e87bbf2021-07-30 10:04:05 -0700360 args.extend(["-rewrite=^javax.annotation:javax.annotation-api$=javax-annotation-api-prebuilt-host-jar"])
361 args.extend(["-rewrite=^org.robolectric:robolectric$=Robolectric_all-target"])
362 args.extend(["-rewrite=^org.jetbrains.kotlinx:kotlinx-coroutines-core$=kotlinx_coroutines"])
363 args.extend(["-rewrite=^org.jetbrains.kotlinx:kotlinx-coroutines-android$=kotlinx_coroutines_android"])
364 args.extend(["-rewrite=^org.jetbrains.kotlinx:kotlinx-metadata-jvm$=kotlinx_metadata_jvm"])
Sunny Goyal6667ddb2020-03-03 15:15:54 -0800365 args.extend(["-extra-static-libs=androidx.room_room-compiler=guava-21.0"])
Jeff Gaston07a3cf72018-08-24 14:16:34 -0400366 args.extend(["-host=" + name for name in maven_to_make if maven_to_make[name].get('host')])
Tony Mak0f658752019-07-19 11:11:05 +0100367 args.extend(["-host-and-device=" + name for name in maven_to_make if maven_to_make[name].get('host_and_device')])
Colin Cross21060072018-04-24 13:52:29 -0700368 # these depend on GSON which is not in AOSP
Tony Mak0f658752019-07-19 11:11:05 +0100369 args.extend(["-exclude=android-arch-room-migration",
Colin Cross21060072018-04-24 13:52:29 -0700370 "-exclude=android-arch-room-testing"])
Jeff Gaston7ec1d8f2018-03-27 00:25:12 -0400371 args.extend(["."])
Dan Willemsen814152e2017-11-06 13:22:11 -0800372 subprocess.check_call(args, stdout=f, cwd=working_dir)
Alan Viverette95f6d362017-04-06 09:40:50 -0400373
374 # Replace the old directory.
Jeff Gastonc302bb92018-03-23 13:53:48 -0400375 output_dir = os.path.join(cwd, transformed_dir)
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400376 mv(working_dir, output_dir)
Alan Viverettec960cfb2017-12-04 13:09:22 -0500377 return True
Alan Viverette95f6d362017-04-06 09:40:50 -0400378
Jeff Gastonc302bb92018-03-23 13:53:48 -0400379# moves <artifact_info> (of type MavenLibraryInfo) into the appropriate part of <working_dir> , and possibly unpacks any necessary included files
Alan Viveretted8ce7222017-12-11 17:24:43 -0500380def transform_maven_lib(working_dir, artifact_info, extract_res):
Dan Willemsen814152e2017-11-06 13:22:11 -0800381 # Move library into working dir
Jeff Gaston9edf86c2018-04-18 13:45:23 -0400382 new_dir = os.path.normpath(os.path.join(working_dir, os.path.relpath(artifact_info.dir, artifact_info.repo_dir)))
Jeff Gastonc302bb92018-03-23 13:53:48 -0400383 mv(artifact_info.dir, new_dir)
Dan Willemsen814152e2017-11-06 13:22:11 -0800384
Alan Viverettec960cfb2017-12-04 13:09:22 -0500385 matcher = artifact_pattern.match(artifact_info.file)
386 maven_lib_name = artifact_info.key
Alan Viveretted4527e62017-05-11 15:03:25 -0400387 maven_lib_vers = matcher.group(2)
Alan Viverettec960cfb2017-12-04 13:09:22 -0500388 maven_lib_type = artifact_info.file[-3:]
Alan Viveretted4527e62017-05-11 15:03:25 -0400389
Jeff Gastona0bce602018-08-24 14:05:03 -0400390 make_lib_name = maven_to_make[artifact_info.key]['name']
391 make_dir_name = maven_to_make[artifact_info.key]['path']
Alan Viveretted4527e62017-05-11 15:03:25 -0400392
Alan Viverette129555e2018-01-30 09:57:57 -0500393 artifact_file = os.path.join(new_dir, artifact_info.file)
394
Colin Cross59b59db2018-04-24 13:58:05 -0700395 if maven_lib_type == "aar":
396 if extract_res:
397 target_dir = os.path.join(working_dir, make_dir_name)
398 if not os.path.exists(target_dir):
399 os.makedirs(target_dir)
Dan Willemsen814152e2017-11-06 13:22:11 -0800400
Alan Viverettec960cfb2017-12-04 13:09:22 -0500401 process_aar(artifact_file, target_dir)
Alan Viveretted4527e62017-05-11 15:03:25 -0400402
Colin Cross59b59db2018-04-24 13:58:05 -0700403 with zipfile.ZipFile(artifact_file) as zip:
404 manifests_dir = os.path.join(working_dir, "manifests")
405 zip.extract("AndroidManifest.xml", os.path.join(manifests_dir, make_lib_name))
Dan Willemsend677b602017-11-08 22:13:17 -0800406
Alan Viverettef5cb0e62017-11-17 15:15:23 -0500407 print(maven_lib_vers, ":", maven_lib_name, "->", make_lib_name)
Alan Viveretted4527e62017-05-11 15:03:25 -0400408
Alan Viverette95f6d362017-04-06 09:40:50 -0400409
Alan Viverettec960cfb2017-12-04 13:09:22 -0500410def process_aar(artifact_file, target_dir):
Alan Viverette95f6d362017-04-06 09:40:50 -0400411 # Extract AAR file to target_dir.
412 with zipfile.ZipFile(artifact_file) as zip:
413 zip.extractall(target_dir)
414
Dan Willemsen814152e2017-11-06 13:22:11 -0800415 # Remove classes.jar
Alan Viverette95f6d362017-04-06 09:40:50 -0400416 classes_jar = os.path.join(target_dir, "classes.jar")
417 if os.path.exists(classes_jar):
Dan Willemsen814152e2017-11-06 13:22:11 -0800418 os.remove(classes_jar)
Alan Viverette95f6d362017-04-06 09:40:50 -0400419
420 # Remove or preserve empty dirs.
421 for root, dirs, files in os.walk(target_dir):
422 for dir in dirs:
423 dir_path = os.path.join(root, dir)
424 if not os.listdir(dir_path):
425 os.rmdir(dir_path)
426
427 # Remove top-level cruft.
428 for file in blacklist_files:
429 file_path = os.path.join(target_dir, file)
430 if os.path.exists(file_path):
431 os.remove(file_path)
432
Alan Viverettef17c9402017-07-19 12:57:40 -0400433
Alan Viverettecd3de262017-08-14 09:51:30 -0400434def fetch_artifact(target, build_id, artifact_path):
Jeff Sharkeyabe16df2021-05-25 10:09:03 -0600435 global args
Jiyong Park1d1c9632018-05-29 17:45:27 +0900436 download_to = os.path.join('.', os.path.dirname(artifact_path))
437 print('Fetching %s from %s ...' % (artifact_path, target))
438 if not os.path.exists(download_to):
439 os.makedirs(download_to)
Jeff Sharkeyabe16df2021-05-25 10:09:03 -0600440 if args.beyond_corp:
441 fetch_cmd = [FETCH_ARTIFACT_BEYOND_CORP, '--use_oauth2',
442 '--bid', str(build_id), '--target', target, artifact_path, download_to]
443 else:
444 fetch_cmd = [FETCH_ARTIFACT,
445 '--bid', str(build_id), '--target', target, artifact_path, download_to]
Jeff Gaston97a9b762018-10-02 15:15:12 -0400446 print("Running: " + ' '.join(fetch_cmd))
Alan Viverette45837092017-05-12 14:50:53 -0400447 try:
Alan Viverettecd3de262017-08-14 09:51:30 -0400448 subprocess.check_output(fetch_cmd, stderr=subprocess.STDOUT)
Alan Viverette45837092017-05-12 14:50:53 -0400449 except subprocess.CalledProcessError:
Jeff Gaston13e38412018-02-06 14:45:36 -0500450 print_e('FAIL: Unable to retrieve %s artifact for build ID %s' % (artifact_path, build_id))
Alan Viverettec1c32b62017-12-20 09:40:36 -0500451 print_e('Please make sure you are authenticated for build server access!')
Alan Viverette45837092017-05-12 14:50:53 -0400452 return None
453 return artifact_path
454
455
Anton Hansson1d01a032018-04-09 10:29:37 +0100456def fetch_artifacts(target, build_id, artifact_dict):
457 for artifact, target_path in artifact_dict.items():
458 artifact_path = fetch_artifact(target, build_id.url_id, artifact)
459 if not artifact_path:
460 return False
461 mv(artifact_path, target_path)
462 return True
463
464
Alan Viverette129555e2018-01-30 09:57:57 -0500465def extract_artifact(artifact_path):
Alan Viverette45837092017-05-12 14:50:53 -0400466 # Unzip the repo archive into a separate directory.
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400467 repo_dir = os.path.basename(artifact_path)[:-4]
Alan Viverette45837092017-05-12 14:50:53 -0400468 with zipfile.ZipFile(artifact_path) as zipFile:
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400469 zipFile.extractall(repo_dir)
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400470 return repo_dir
471
472
Alan Viverette7e897e22018-03-09 15:24:10 -0500473def fetch_and_extract(target, build_id, file, artifact_path=None):
474 if not artifact_path:
475 artifact_path = fetch_artifact(target, build_id, file)
Alan Viverette129555e2018-01-30 09:57:57 -0500476 if not artifact_path:
477 return None
478 return extract_artifact(artifact_path)
479
480
Jeff Gaston08a2ee42018-05-07 18:08:41 -0400481def update_androidx(target, build_id, local_file):
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400482 if build_id:
Anthony Chenacbb4872018-07-02 11:22:48 -0700483 repo_file = 'top-of-tree-m2repository-all-%s.zip' % build_id.fs_id
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400484 repo_dir = fetch_and_extract(target, build_id.url_id, repo_file, None)
485 else:
486 repo_dir = fetch_and_extract(target, None, None, local_file)
487 if not repo_dir:
488 print_e('Failed to extract AndroidX repository')
489 return False
490
Tony Mak0f658752019-07-19 11:11:05 +0100491 # Keep JavaPlugins.bp file untounched.
492 java_plugins_bp_path = os.path.join(androidx_dir, 'JavaPlugins.bp')
493 tmp_java_plugins_bp_path = os.path.join('/tmp', 'JavaPlugins.bp')
494 mv(java_plugins_bp_path, tmp_java_plugins_bp_path)
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400495
Tony Mak0f658752019-07-19 11:11:05 +0100496 # Transform the repo archive into a Makefile-compatible format.
497 if not transform_maven_repos([repo_dir], androidx_dir, extract_res=False):
498 return False
499
500 # Import JavaPlugins.bp in Android.bp.
501 makefile = os.path.join(androidx_dir, 'Android.bp')
502 with open(makefile, "a+") as f:
503 f.write('\nbuild = ["JavaPlugins.bp"]\n')
504 mv(tmp_java_plugins_bp_path, java_plugins_bp_path)
505
506 return True
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400507
Alan Viverette6dc45752020-04-16 14:56:20 +0000508
Jeff Gaston782c3e32018-02-06 14:36:17 -0500509def update_jetifier(target, build_id):
510 repo_file = 'jetifier-standalone.zip'
511 repo_dir = fetch_and_extract(target, build_id.url_id, repo_file)
512 if not repo_dir:
513 print_e('Failed to extract Jetifier')
514 return False
515
516 rm(jetifier_dir)
Jeff Gaston553a4372018-03-29 18:34:22 -0400517 mv(os.path.join(repo_dir, 'jetifier-standalone'), jetifier_dir)
518 os.chmod(os.path.join(jetifier_dir, 'bin', 'jetifier-standalone'), 0o755)
Jeff Gaston782c3e32018-02-06 14:36:17 -0500519 return True
520
Alan Viverette7e897e22018-03-09 15:24:10 -0500521
Alan Viverette6dc45752020-04-16 14:56:20 +0000522def update_constraint(local_file):
Jeff Gaston9edf86c2018-04-18 13:45:23 -0400523 repo_dir = extract_artifact(local_file)
524 if not repo_dir:
Alan Viverette6dc45752020-04-16 14:56:20 +0000525 print_e('Failed to extract Constraint Layout')
Jeff Gaston9edf86c2018-04-18 13:45:23 -0400526 return False
527 return transform_maven_repos([repo_dir], os.path.join(extras_dir, 'constraint-layout-x'), extract_res=False)
528
Alan Viverette45837092017-05-12 14:50:53 -0400529
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400530def update_material(file):
531 design_dir = extract_artifact(file)
532 if not design_dir:
Alan Viverette6dc45752020-04-16 14:56:20 +0000533 print_e('Failed to extract Material Design Components')
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400534 return False
535
536 # Don't bother extracting resources -- this should only be used with AAPT2.
537 return transform_maven_repos([design_dir],
538 os.path.join(extras_dir, 'material-design-x'), extract_res=False)
539
540
Anton Hansson1d01a032018-04-09 10:29:37 +0100541def update_framework(build_id, sdk_dir):
Anton Hansson83f92172020-03-26 11:12:03 +0000542 api_scope_list = ['public', 'system', 'test', 'module-lib', 'system-server']
Sundong Ahn66091f22018-08-29 18:54:28 +0900543 if sdk_dir == 'current':
544 api_scope_list.append('core')
545
546 for api_scope in api_scope_list:
Jiyong Park1d1c9632018-05-29 17:45:27 +0900547 target_dir = path(sdk_dir, api_scope)
Sundong Ahn66091f22018-08-29 18:54:28 +0900548 if api_scope == 'core':
549 artifact_to_path = {'core.current.stubs.jar': path(target_dir, 'android.jar')}
550 else:
551 artifact_to_path = {'apistubs/android/' + api_scope + '/*.jar': path(target_dir, '*')}
Anton Hansson1d01a032018-04-09 10:29:37 +0100552
553 if not fetch_artifacts(framework_sdk_target, build_id, artifact_to_path):
554 return False
555
Jiyong Park1d1c9632018-05-29 17:45:27 +0900556 if api_scope == 'public':
Anton Hansson1d01a032018-04-09 10:29:37 +0100557 # Fetch a few artifacts from the public sdk.
Sundong Ahn66091f22018-08-29 18:54:28 +0900558 artifact = 'sdk-repo-linux-platforms-%s.zip' % build_id.fs_id
Anton Hansson1d01a032018-04-09 10:29:37 +0100559 artifact_path = fetch_artifact(framework_sdk_target, build_id.url_id, artifact)
Anton Hansson9709fd42018-04-03 16:52:13 +0100560 if not artifact_path:
561 return False
Anton Hansson1d01a032018-04-09 10:29:37 +0100562
563 with zipfile.ZipFile(artifact_path) as zipFile:
Colin Crossd338d702020-07-10 19:17:54 -0700564 extra_files = [
565 'android.jar',
566 'framework.aidl',
567 'uiautomator.jar',
568 'core-for-system-modules.jar',
569 'data/annotations.zip',
570 'data/api-versions.xml']
571 for filename in extra_files:
Anton Hanssona26e4812020-03-25 12:54:39 +0000572 matches = list(filter(lambda path: filename in path, zipFile.namelist()))
573 if len(matches) != 1:
574 print_e('Expected 1 file named \'%s\' in zip %s, found %d' %
575 (filename, zipFile.filename, len(matches)))
576 return False
577 zip_path = matches[0]
578 src_path = zipFile.extract(zip_path)
579 dst_path = path(target_dir, filename)
580 mv(src_path, dst_path)
Anton Hansson9709fd42018-04-03 16:52:13 +0100581
Anton Hansson73be1512021-06-24 10:56:05 +0100582 # Filtered API DB is currently only available for "public"
583 fetch_artifacts(framework_sdk_target, build_id, {'api-versions-public-filtered.xml': path(target_dir, 'data/api-versions-filtered.xml')})
584
Alan Viverettecd3de262017-08-14 09:51:30 -0400585 return True
Alan Viverette45837092017-05-12 14:50:53 -0400586
Sundong Ahncc34cc32018-07-11 15:18:47 +0900587def update_makefile(build_id):
588 template = '"%s",\n\
589 "current"'
590 makefile = os.path.join(git_dir, 'Android.bp')
591
592 with open(makefile, 'r+') as f:
593 contents = f.read().replace('"current"', template % build_id)
594 f.seek(0)
595 f.write(contents)
596
597 return True
Alan Viverette45837092017-05-12 14:50:53 -0400598
Anton Hansson1d01a032018-04-09 10:29:37 +0100599def finalize_sdk(build_id, sdk_version):
600 target_finalize_dir = '%d' % sdk_version
Anton Hansson9709fd42018-04-03 16:52:13 +0100601
Anton Hanssonaa554c02020-04-30 14:06:20 +0100602 for api_scope in ['public', 'system', 'test', 'module-lib', 'system-server']:
Sundong Ahn66091f22018-08-29 18:54:28 +0900603 artifact_to_path = {'apistubs/android/' + api_scope + '/api/*.txt':
604 path(target_finalize_dir, api_scope, 'api', '*')}
605
606 if not fetch_artifacts(framework_sdk_target, build_id, artifact_to_path):
607 return False
608
609 return update_framework(build_id, target_finalize_dir) \
Sundong Ahncc34cc32018-07-11 15:18:47 +0900610 and update_makefile(target_finalize_dir)
Anton Hansson9709fd42018-04-03 16:52:13 +0100611
Anton Hansson9709fd42018-04-03 16:52:13 +0100612
Anton Hansson1d01a032018-04-09 10:29:37 +0100613def update_framework_current(build_id):
614 return update_framework(build_id, current_path)
Anton Hansson9709fd42018-04-03 16:52:13 +0100615
616
Alan Viverettec1c32b62017-12-20 09:40:36 -0500617def update_buildtools(target, arch, build_id):
Jeff Gaston13e38412018-02-06 14:45:36 -0500618 artifact_path = fetch_and_extract(target, build_id.url_id,
619 "sdk-repo-%s-build-tools-%s.zip" % (arch, build_id.fs_id))
Alan Viverettec1c32b62017-12-20 09:40:36 -0500620 if not artifact_path:
621 return False
622
623 top_level_dir = os.listdir(artifact_path)[0]
624 src_path = os.path.join(artifact_path, top_level_dir)
625 dst_path = path(buildtools_dir, arch)
Colin Cross20648d32021-02-12 13:30:51 -0800626
627 # There are a few libraries that have been manually added to the
628 # build tools, copy them from the destination back to the source
629 # before the destination is overwritten.
630 files_to_save = (
631 'lib64/libconscrypt_openjdk_jni.dylib',
632 'lib64/libconscrypt_openjdk_jni.so',
633 'bin/lib64/libwinpthread-1.dll',
634 )
635 for file in files_to_save:
636 src_file = os.path.join(dst_path, file)
637 dst_file = os.path.join(src_path, file)
638 if os.path.exists(dst_path):
639 mv(src_file, dst_file)
640
Alan Viverettec1c32b62017-12-20 09:40:36 -0500641 mv(src_path, dst_path)
642
643 # Move all top-level files to /bin and make them executable
644 bin_path = path(dst_path, 'bin')
645 top_level_files = filter(lambda e: os.path.isfile(path(dst_path, e)), os.listdir(dst_path))
646 for file in top_level_files:
647 src_file = path(dst_path, file)
648 dst_file = path(bin_path, file)
649 mv(src_file, dst_file)
650 os.chmod(dst_file, 0o755)
651
Colin Cross6673ceb2021-02-12 13:14:14 -0800652 # Make the files under lld-bin executable
653 lld_bin_files = os.listdir(os.path.join(dst_path, 'lld-bin'))
654 for file in lld_bin_files:
655 os.chmod(os.path.join(dst_path, 'lld-bin', file), 0o755)
656
Alan Viverettec1c32b62017-12-20 09:40:36 -0500657 # Remove renderscript
658 rm(path(dst_path, 'renderscript'))
659
660 return True
661
662
Alan Viverettecd3de262017-08-14 09:51:30 -0400663def append(text, more_text):
664 if text:
665 return "%s, %s" % (text, more_text)
666 return more_text
Alan Viverette45837092017-05-12 14:50:53 -0400667
Alan Viverette95f6d362017-04-06 09:40:50 -0400668
Jeff Gaston13e38412018-02-06 14:45:36 -0500669class buildId(object):
670 def __init__(self, url_id, fs_id):
671 # id when used in build server urls
672 self.url_id = url_id
673 # id when used in build commands
674 self.fs_id = fs_id
675
Jeff Gastonb9b09052018-02-05 14:16:05 -0500676def getBuildId(args):
Jeff Gaston13e38412018-02-06 14:45:36 -0500677 # must be in the format 12345 or P12345
Jeff Gastonb9b09052018-02-05 14:16:05 -0500678 source = args.source
Jeff Gaston13e38412018-02-06 14:45:36 -0500679 number_text = source[:]
680 presubmit = False
681 if number_text.startswith("P"):
682 presubmit = True
683 number_text = number_text[1:]
684 if not number_text.isnumeric():
Alan Viverette7e897e22018-03-09 15:24:10 -0500685 return None
Jeff Gaston13e38412018-02-06 14:45:36 -0500686 url_id = source
687 fs_id = url_id
688 if presubmit:
689 fs_id = "0"
690 args.file = False
691 return buildId(url_id, fs_id)
Jeff Gastonb9b09052018-02-05 14:16:05 -0500692
Colin Cross573e1212018-02-12 14:59:52 -0800693def getFile(args):
694 source = args.source
695 if not source.isnumeric():
696 return args.source
Alan Viverette7e897e22018-03-09 15:24:10 -0500697 return None
Colin Cross573e1212018-02-12 14:59:52 -0800698
Alan Viverette4ec9a172018-02-20 16:19:31 -0500699
700def script_relative(rel_path):
Jeff Gastona68a8d42018-03-23 14:00:13 -0400701 return os.path.join(script_dir, rel_path)
Alan Viverette4ec9a172018-02-20 16:19:31 -0500702
703
Jeff Gastoncc296a82018-03-23 14:33:24 -0400704def uncommittedChangesExist():
705 try:
706 # Make sure we don't overwrite any pending changes.
707 diffCommand = "cd " + git_dir + " && git diff --quiet"
708 subprocess.check_call(diffCommand, shell=True)
709 subprocess.check_call(diffCommand + " --cached", shell=True)
710 return False
711 except subprocess.CalledProcessError:
712 return True
713
714
Jeff Gastona7fba9b2018-03-26 23:48:51 -0400715rm(temp_dir)
Alan Viveretted4527e62017-05-11 15:03:25 -0400716parser = argparse.ArgumentParser(
Alan Viverette45837092017-05-12 14:50:53 -0400717 description=('Update current prebuilts'))
Alan Viveretted4527e62017-05-11 15:03:25 -0400718parser.add_argument(
Alan Viverette129555e2018-01-30 09:57:57 -0500719 'source',
720 help='Build server build ID or local Maven ZIP file')
721parser.add_argument(
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400722 '-m', '--material', action="store_true",
Alan Viverette6dc45752020-04-16 14:56:20 +0000723 help='If specified, updates only Material Design Components')
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400724parser.add_argument(
Alan Viverette3e57a4a2017-08-11 15:49:47 -0400725 '-c', '--constraint', action="store_true",
726 help='If specified, updates only Constraint Layout')
727parser.add_argument(
Jeff Gaston782c3e32018-02-06 14:36:17 -0500728 '-j', '--jetifier', action="store_true",
729 help='If specified, updates only Jetifier')
730parser.add_argument(
Alan Viverette5bfe05b2017-06-06 14:21:29 -0400731 '-p', '--platform', action="store_true",
732 help='If specified, updates only the Android Platform')
Alan Viverettec1c32b62017-12-20 09:40:36 -0500733parser.add_argument(
Anton Hansson9709fd42018-04-03 16:52:13 +0100734 '-f', '--finalize_sdk', type=int,
735 help='If specified, imports the source build as the specified finalized SDK version')
736parser.add_argument(
Alan Viverettec1c32b62017-12-20 09:40:36 -0500737 '-b', '--buildtools', action="store_true",
738 help='If specified, updates only the Build Tools')
Jeff Gastoncc296a82018-03-23 14:33:24 -0400739parser.add_argument(
Alan Viverette6dc45752020-04-16 14:56:20 +0000740 '-x', '--androidx', action="store_true",
741 help='If specified, updates only the Jetpack (androidx) libraries excluding those covered by other arguments')
Jeff Gaston41fd5e62018-04-25 17:02:02 -0400742parser.add_argument(
Jeff Gastoncc296a82018-03-23 14:33:24 -0400743 '--commit-first', action="store_true",
744 help='If specified, then if uncommited changes exist, commit before continuing')
Jeff Sharkeyabe16df2021-05-25 10:09:03 -0600745parser.add_argument(
746 '--beyond-corp', action="store_true",
747 help='If specified, then fetch artifacts with tooling that works on BeyondCorp devices')
Alan Viveretted4527e62017-05-11 15:03:25 -0400748args = parser.parse_args()
Jeff Gaston56fe2762018-02-06 14:54:37 -0500749args.file = True
Alan Viverette129555e2018-01-30 09:57:57 -0500750if not args.source:
751 parser.error("You must specify a build ID or local Maven ZIP file")
Alan Viveretted4527e62017-05-11 15:03:25 -0400752 sys.exit(1)
Alan Viverette6dc45752020-04-16 14:56:20 +0000753if not (args.platform or args.buildtools \
754 or args.jetifier or args.androidx or args.material \
755 or args.finalize_sdk or args.constraint):
Alan Viverettec1c32b62017-12-20 09:40:36 -0500756 parser.error("You must specify at least one target to update")
Alan Viverettecd3de262017-08-14 09:51:30 -0400757 sys.exit(1)
Alan Viverette6dc45752020-04-16 14:56:20 +0000758if (args.constraint or args.material or args.androidx) \
Colin Cross74683bc2018-04-11 17:36:18 -0700759 and which('pom2bp') is None:
Louis Pullen-Freilich61bb70e2019-04-09 16:15:32 +0100760 parser.error("Cannot find pom2bp in path; please run lunch to set up build environment. You may also need to run 'm pom2bp' if it hasn't been built already.")
Alan Viverettef5cb0e62017-11-17 15:15:23 -0500761 sys.exit(1)
Alan Viveretted4527e62017-05-11 15:03:25 -0400762
Jeff Gastoncc296a82018-03-23 14:33:24 -0400763if uncommittedChangesExist():
764 if args.commit_first:
765 subprocess.check_call("cd " + git_dir + " && git add -u", shell=True)
766 subprocess.check_call("cd " + git_dir + " && git commit -m 'save working state'", shell=True)
767
768if uncommittedChangesExist():
Anton Hansson10861a02018-04-06 13:57:08 +0100769 print_e('FAIL: There are uncommitted changes here. Please commit or stash before continuing, because %s will run "git reset --hard" if execution fails' % os.path.basename(__file__))
Alan Viveretted4527e62017-05-11 15:03:25 -0400770 sys.exit(1)
771
772try:
Alan Viverettecd3de262017-08-14 09:51:30 -0400773 components = None
774 if args.constraint:
Jeff Gaston9edf86c2018-04-18 13:45:23 -0400775 if update_constraint_x(getFile(args)):
776 components = append(components, 'Constraint Layout X')
777 else:
778 print_e('Failed to update Constraint Layout X, aborting...')
Alan Viverettecd3de262017-08-14 09:51:30 -0400779 sys.exit(1)
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400780 if args.androidx:
Jeff Gaston17ccf8f2018-08-29 11:33:19 -0400781 if update_androidx('androidx', \
Jeff Gastonbbd6bfc2018-03-27 17:35:49 -0400782 getBuildId(args), getFile(args)):
783 components = append(components, 'AndroidX')
784 else:
785 print_e('Failed to update AndroidX, aborting...')
786 sys.exit(1)
Jeff Gaston782c3e32018-02-06 14:36:17 -0500787 if args.jetifier:
Jeff Gaston17ccf8f2018-08-29 11:33:19 -0400788 if update_jetifier('androidx', getBuildId(args)):
Jeff Gaston782c3e32018-02-06 14:36:17 -0500789 components = append(components, 'Jetifier')
790 else:
791 print_e('Failed to update Jetifier, aborting...')
792 sys.exit(1)
Anton Hanssonbe15e8c2018-04-26 17:35:45 +0100793 if args.platform or args.finalize_sdk:
Anton Hansson87654c42018-04-26 15:19:42 +0100794 if update_framework_current(getBuildId(args)):
Alan Viverettecd3de262017-08-14 09:51:30 -0400795 components = append(components, 'platform SDK')
796 else:
Alan Viverettef5cb0e62017-11-17 15:15:23 -0500797 print_e('Failed to update platform SDK, aborting...')
Alan Viverettecd3de262017-08-14 09:51:30 -0400798 sys.exit(1)
Anton Hansson9709fd42018-04-03 16:52:13 +0100799 if args.finalize_sdk:
Anton Hanssonbe15e8c2018-04-26 17:35:45 +0100800 n = args.finalize_sdk
801 if finalize_sdk(getBuildId(args), n):
802 # We commit the finalized dir separately from the current sdk update.
803 msg = "Import final sdk version %d from build %s" % (n, getBuildId(args).url_id)
804 subprocess.check_call(['git', 'add', '%d' % n])
Sundong Ahncc34cc32018-07-11 15:18:47 +0900805 subprocess.check_call(['git', 'add', 'Android.bp'])
Anton Hanssonbe15e8c2018-04-26 17:35:45 +0100806 subprocess.check_call(['git', 'commit', '-m', msg])
Anton Hansson9709fd42018-04-03 16:52:13 +0100807 else:
Anton Hanssonbe15e8c2018-04-26 17:35:45 +0100808 print_e('Failed to finalize SDK %d, aborting...' % n)
Anton Hansson9709fd42018-04-03 16:52:13 +0100809 sys.exit(1)
Jeff Gaston6e7e7502018-04-04 00:22:45 -0400810 if args.material:
811 if update_material(getFile(args)):
812 components = append(components, 'intermediate-AndroidX Design Library')
813 else:
814 print_e('Failed to update intermediate-AndroidX Design Library, aborting...')
Alan Viverette129555e2018-01-30 09:57:57 -0500815 sys.exit(1)
Alan Viverettec1c32b62017-12-20 09:40:36 -0500816 if args.buildtools:
Jeff Gastonb9b09052018-02-05 14:16:05 -0500817 if update_buildtools('sdk_phone_armv7-sdk_mac', 'darwin', getBuildId(args)) \
818 and update_buildtools('sdk_phone_x86_64-sdk', 'linux', getBuildId(args)) \
819 and update_buildtools('sdk_phone_armv7-win_sdk', 'windows', getBuildId(args)):
Alan Viverettec1c32b62017-12-20 09:40:36 -0500820 components = append(components, 'build tools')
821 else:
822 print_e('Failed to update build tools, aborting...')
823 sys.exit(1)
Jeff Gastonb70daa92018-03-29 20:10:22 -0400824
Jeff Gastonf12f3ce2018-03-23 16:41:24 -0400825
Alan Viveretted4527e62017-05-11 15:03:25 -0400826
Colin Cross941d9802018-05-03 21:37:57 -0700827 subprocess.check_call(['git', 'add', current_path, buildtools_dir])
Colin Cross573e1212018-02-12 14:59:52 -0800828 if not args.source.isnumeric():
Alan Viverette129555e2018-01-30 09:57:57 -0500829 src_msg = "local Maven ZIP"
830 else:
Jeff Gaston13e38412018-02-06 14:45:36 -0500831 src_msg = "build %s" % (getBuildId(args).url_id)
Alan Viverette129555e2018-01-30 09:57:57 -0500832 msg = "Import %s from %s\n\n%s" % (components, src_msg, flatten(sys.argv))
Alan Viveretted4527e62017-05-11 15:03:25 -0400833 subprocess.check_call(['git', 'commit', '-m', msg])
Anton Hanssonbe15e8c2018-04-26 17:35:45 +0100834 if args.finalize_sdk:
835 print('NOTE: Created two commits:')
836 subprocess.check_call(['git', 'log', '-2', '--oneline'])
Alan Viverettef5cb0e62017-11-17 15:15:23 -0500837 print('Remember to test this change before uploading it to Gerrit!')
Alan Viveretted4527e62017-05-11 15:03:25 -0400838
839finally:
840 # Revert all stray files, including the downloaded zip.
841 try:
842 with open(os.devnull, 'w') as bitbucket:
843 subprocess.check_call(['git', 'add', '-Af', '.'], stdout=bitbucket)
844 subprocess.check_call(
Jeff Gaston9edf86c2018-04-18 13:45:23 -0400845 ['git', 'commit', '-m', 'COMMIT TO REVERT - RESET ME!!!', '--allow-empty'], stdout=bitbucket)
Alan Viveretted4527e62017-05-11 15:03:25 -0400846 subprocess.check_call(['git', 'reset', '--hard', 'HEAD~1'], stdout=bitbucket)
847 except subprocess.CalledProcessError:
Alan Viverettef5cb0e62017-11-17 15:15:23 -0500848 print_e('ERROR: Failed cleaning up, manual cleanup required!!!')