Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 1 | #!/usr/bin/python3 |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 2 | |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 3 | # 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 Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 6 | import os, sys, getopt, zipfile, re |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 7 | import argparse |
Jiyong Park | 1d1c963 | 2018-05-29 17:45:27 +0900 | [diff] [blame] | 8 | import glob |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 9 | import subprocess |
shepshapard | e4127cf | 2019-09-03 16:08:44 -0700 | [diff] [blame] | 10 | from shutil import copyfile, rmtree, which, move |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 11 | from distutils.version import LooseVersion |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 12 | from functools import reduce |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 13 | |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 14 | current_path = 'current' |
Oussama Ben Abdelbaki | 66db0a4 | 2019-05-08 16:41:15 -0400 | [diff] [blame] | 15 | framework_sdk_target = 'sdk_phone_armv7-win_sdk' |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 16 | support_dir = os.path.join(current_path, 'support') |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 17 | androidx_dir = os.path.join(current_path, 'androidx') |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 18 | extras_dir = os.path.join(current_path, 'extras') |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 19 | buildtools_dir = 'tools' |
Jeff Gaston | 553a437 | 2018-03-29 18:34:22 -0400 | [diff] [blame] | 20 | jetifier_dir = os.path.join(buildtools_dir, 'jetifier', 'jetifier-standalone') |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 21 | |
Jeff Gaston | a68a8d4 | 2018-03-23 14:00:13 -0400 | [diff] [blame] | 22 | temp_dir = os.path.join(os.getcwd(), "support_tmp") |
| 23 | os.chdir(os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))) |
| 24 | git_dir = os.getcwd() |
| 25 | |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 26 | # See go/fetch_artifact for details on this script. |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 27 | FETCH_ARTIFACT = '/google/data/ro/projects/android/fetch_artifact' |
| 28 | |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 29 | maven_to_make = { |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 30 | # Support Library |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 31 | 'com.android.support:animated-vector-drawable': {'name':'android-support-animatedvectordrawable', 'path':'graphics/drawable'}, |
| 32 | 'com.android.support:appcompat-v7': {'name':'android-support-v7-appcompat', 'path':'v7/appcompat'}, |
| 33 | 'com.android.support:cardview-v7': {'name':'android-support-v7-cardview', 'path':'v7/cardview'}, |
| 34 | 'com.android.support:collections': {'name':'android-support-collections', 'path':'collections'}, |
| 35 | 'com.android.support:customtabs': {'name':'android-support-customtabs', 'path':'customtabs'}, |
| 36 | 'com.android.support:exifinterface': {'name':'android-support-exifinterface', 'path':'exifinterface'}, |
| 37 | 'com.android.support:gridlayout-v7': {'name':'android-support-v7-gridlayout', 'path':'v7/gridlayout'}, |
| 38 | 'com.android.support:leanback-v17': {'name':'android-support-v17-leanback', 'path':'v17/leanback'}, |
| 39 | 'com.android.support:mediarouter-v7': {'name':'android-support-v7-mediarouter', 'path':'v7/mediarouter'}, |
| 40 | 'com.android.support:palette-v7': {'name':'android-support-v7-palette', 'path':'v7/palette'}, |
| 41 | 'com.android.support:percent': {'name':'android-support-percent', 'path':'percent'}, |
| 42 | 'com.android.support:preference-leanback-v17': {'name':'android-support-v17-preference-leanback', 'path':'v17/preference-leanback'}, |
| 43 | 'com.android.support:preference-v14': {'name':'android-support-v14-preference', 'path':'v14/preference'}, |
| 44 | 'com.android.support:preference-v7': {'name':'android-support-v7-preference', 'path':'v7/preference'}, |
| 45 | 'com.android.support:recommendation': {'name':'android-support-recommendation', 'path':'recommendation'}, |
| 46 | 'com.android.support:recyclerview-v7': {'name':'android-support-v7-recyclerview', 'path':'v7/recyclerview'}, |
| 47 | 'com.android.support:support-annotations': {'name':'android-support-annotations', 'path':'annotations'}, |
| 48 | 'com.android.support:support-compat': {'name':'android-support-compat', 'path':'compat'}, |
| 49 | 'com.android.support:support-core-ui': {'name':'android-support-core-ui', 'path':'core-ui'}, |
| 50 | 'com.android.support:support-core-utils': {'name':'android-support-core-utils', 'path':'core-utils'}, |
| 51 | 'com.android.support:support-dynamic-animation': {'name':'android-support-dynamic-animation', 'path':'dynamic-animation'}, |
| 52 | 'com.android.support:support-emoji-appcompat': {'name':'android-support-emoji-appcompat', 'path':'emoji-appcompat'}, |
| 53 | 'com.android.support:support-emoji-bundled': {'name':'android-support-emoji-bundled', 'path':'emoji-bundled'}, |
| 54 | 'com.android.support:support-emoji': {'name':'android-support-emoji', 'path':'emoji'}, |
| 55 | 'com.android.support:support-fragment': {'name':'android-support-fragment', 'path':'fragment'}, |
| 56 | 'com.android.support:support-media-compat': {'name':'android-support-media-compat', 'path':'media-compat'}, |
| 57 | 'com.android.support:support-tv-provider': {'name':'android-support-tv-provider', 'path':'tv-provider'}, |
| 58 | 'com.android.support:support-v13': {'name':'android-support-v13', 'path':'v13'}, |
| 59 | 'com.android.support:support-v4': {'name':'android-support-v4', 'path':'v4'}, |
| 60 | 'com.android.support:support-vector-drawable': {'name':'android-support-vectordrawable', 'path':'graphics/drawable'}, |
| 61 | 'com.android.support:transition': {'name':'android-support-transition', 'path':'transition'}, |
| 62 | 'com.android.support:wear': {'name':'android-support-wear', 'path':'wear'}, |
Alan Viverette | 7bb86da | 2018-02-21 18:29:02 -0500 | [diff] [blame] | 63 | |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 64 | # Support Library (28.0.0 splits + new modules) |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 65 | 'com.android.support:heifwriter': {'name':'android-support-heifwriter', 'path':'heifwriter'}, |
| 66 | 'com.android.support:webkit': {'name':'android-support-webkit', 'path':'webkit'}, |
| 67 | 'com.android.support:customview': {'name':'android-support-customview', 'path':'customview'}, |
| 68 | 'com.android.support:textclassifier': {'name':'android-support-textclassifier', 'path':'textclassifier'}, |
| 69 | 'com.android.support:swiperefreshlayout': {'name':'android-support-swiperefreshlayout', 'path':'swiperefreshlayout'}, |
| 70 | 'com.android.support:viewpager': {'name':'android-support-viewpager', 'path':'viewpager'}, |
| 71 | 'com.android.support:coordinatorlayout': {'name':'android-support-coordinatorlayout', 'path':'coordinatorlayout'}, |
| 72 | 'com.android.support:asynclayoutinflater': {'name':'android-support-asynclayoutinflater', 'path':'asynclayoutinflater'}, |
| 73 | 'com.android.support:support-content': {'name':'android-support-support-content', 'path':'support-content'}, |
| 74 | 'com.android.support:documentfile': {'name':'android-support-documentfile', 'path':'documentfile'}, |
| 75 | 'com.android.support:drawerlayout': {'name':'android-support-drawerlayout', 'path':'drawerlayout'}, |
| 76 | 'com.android.support:localbroadcastmanager': {'name':'android-support-localbroadcastmanager', 'path':'localbroadcastmanager'}, |
| 77 | 'com.android.support:print': {'name':'android-support-print', 'path':'print'}, |
| 78 | 'com.android.support:slidingpanelayout': {'name':'android-support-slidingpanelayout', 'path':'slidingpanelayout'}, |
| 79 | 'com.android.support:interpolator': {'name':'android-support-interpolator', 'path':'interpolator'}, |
| 80 | 'com.android.support:cursoradapter': {'name':'android-support-cursoradapter', 'path':'cursoradapter'}, |
| 81 | 'com.android.support:loader': {'name':'android-support-loader', 'path':'loader'}, |
| 82 | 'com.android.support:contentpaging': {'name':'android-support-contentpaging', 'path':'contentpaging'}, |
| 83 | 'com.android.support:recyclerview-selection': {'name':'android-support-recyclerview-selection', 'path':'recyclerview-selection'}, |
| 84 | 'com.android.support:car': {'name':'android-support-car', 'path':'car'}, |
| 85 | 'com.android.support:slices-core': {'name':'android-slices-core', 'path':'slices-core'}, |
| 86 | 'com.android.support:slices-view': {'name':'android-slices-view', 'path':'slices-view'}, |
| 87 | 'com.android.support:slices-builders': {'name':'android-slices-builders', 'path':'slices-builders'}, |
| 88 | 'com.android.support:versionedparcelable': {'name':'android-versionedparcelable', 'path':'versionedparcelable'}, |
Alan Viverette | 19ecd50 | 2018-01-05 13:52:16 -0500 | [diff] [blame] | 89 | |
| 90 | # Multidex |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 91 | 'com.android.support:multidex': {'name':'android-support-multidex', 'path':'multidex/library'}, |
| 92 | 'com.android.support:multidex-instrumentation': {'name':'android-support-multidex-instrumentation', 'path':'multidex/instrumentation'}, |
Alan Viverette | 19ecd50 | 2018-01-05 13:52:16 -0500 | [diff] [blame] | 93 | |
| 94 | # Constraint Layout |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 95 | 'com.android.support.constraint:constraint-layout': {'name':'android-support-constraint-layout', 'path':'constraint-layout'}, |
| 96 | 'com.android.support.constraint:constraint-layout-solver': {'name':'android-support-constraint-layout-solver', 'path':'constraint-layout-solver'}, |
Alan Viverette | 19ecd50 | 2018-01-05 13:52:16 -0500 | [diff] [blame] | 97 | |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 98 | # Architecture Components |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 99 | 'android.arch.core:runtime': {'name':'android-arch-core-runtime', 'path':'arch-core/runtime'}, |
| 100 | 'android.arch.core:common': {'name':'android-arch-core-common', 'path':'arch-core/common'}, |
| 101 | 'android.arch.lifecycle:common': {'name':'android-arch-lifecycle-common', 'path':'arch-lifecycle/common'}, |
| 102 | 'android.arch.lifecycle:common-java8': {'name':'android-arch-lifecycle-common-java8', 'path':'arch-lifecycle/common-java8'}, |
| 103 | 'android.arch.lifecycle:extensions': {'name':'android-arch-lifecycle-extensions', 'path':'arch-lifecycle/extensions'}, |
| 104 | 'android.arch.lifecycle:livedata': {'name':'android-arch-lifecycle-livedata', 'path':'arch-lifecycle/livedata'}, |
| 105 | 'android.arch.lifecycle:livedata-core': {'name':'android-arch-lifecycle-livedata-core', 'path':'arch-lifecycle/livedata-core'}, |
| 106 | 'android.arch.lifecycle:process': {'name':'android-arch-lifecycle-process', 'path':'arch-lifecycle/process'}, |
| 107 | 'android.arch.lifecycle:runtime': {'name':'android-arch-lifecycle-runtime', 'path':'arch-lifecycle/runtime'}, |
| 108 | 'android.arch.lifecycle:service': {'name':'android-arch-lifecycle-service', 'path':'arch-lifecycle/service'}, |
| 109 | 'android.arch.lifecycle:viewmodel': {'name':'android-arch-lifecycle-viewmodel', 'path':'arch-lifecycle/viewmodel'}, |
| 110 | 'android.arch.paging:common': {'name':'android-arch-paging-common', 'path':'arch-paging/common'}, |
| 111 | 'android.arch.paging:runtime': {'name':'android-arch-paging-runtime', 'path':'arch-paging/runtime'}, |
| 112 | 'android.arch.persistence:db': {'name':'android-arch-persistence-db', 'path':'arch-persistence/db'}, |
| 113 | 'android.arch.persistence:db-framework': {'name':'android-arch-persistence-db-framework', 'path':'arch-persistence/db-framework'}, |
| 114 | 'android.arch.persistence.room:common': {'name':'android-arch-room-common', 'path':'arch-room/common'}, |
| 115 | 'android.arch.persistence.room:migration': {'name':'android-arch-room-migration', 'path':'arch-room/migration'}, |
| 116 | 'android.arch.persistence.room:runtime': {'name':'android-arch-room-runtime', 'path':'arch-room/runtime'}, |
| 117 | 'android.arch.persistence.room:testing': {'name':'android-arch-room-testing', 'path':'arch-room/testing'}, |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 118 | |
| 119 | # AndroidX |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 120 | 'androidx.slice:slice-builders': {'name':'androidx.slice_slice-builders', 'path':'androidx/slice/slice-builders'}, |
| 121 | 'androidx.slice:slice-core': {'name':'androidx.slice_slice-core', 'path':'androidx/slice/slice-core'}, |
| 122 | 'androidx.slice:slice-view': {'name':'androidx.slice_slice-view', 'path':'androidx/slice/slice-view'}, |
Jeff Gaston | 07a3cf7 | 2018-08-24 14:16:34 -0400 | [diff] [blame] | 123 | 'androidx.remotecallback:remotecallback': {'name':'androidx.remotecallback_remotecallback', 'path':'androidx/remotecallback/remotecallback'}, |
| 124 | 'androidx.remotecallback:remotecallback-processor': {'name':'androidx.remotecallback_remotecallback-processor', 'path':'androidx/remotecallback/remotecallback-processor', 'host':True}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 125 | 'androidx.versionedparcelable:versionedparcelable': {'name':'androidx.versionedparcelable_versionedparcelable', 'path':'androidx/versionedparcelable'}, |
| 126 | 'androidx.vectordrawable:vectordrawable-animated': {'name':'androidx.vectordrawable_vectordrawable-animated', 'path':'androidx/vectordrawable/vectordrawable-animated'}, |
Aurimas Liutikas | abaa49f | 2018-09-18 15:30:20 -0700 | [diff] [blame] | 127 | 'androidx.activity:activity': {'name':'androidx.activity_activity', 'path':'androidx/activity/activity'}, |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 128 | 'androidx.annotation:annotation': {'name':'androidx.annotation_annotation', 'path':'androidx/annotation/annotation', 'host_and_device' : True}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 129 | 'androidx.asynclayoutinflater:asynclayoutinflater': {'name':'androidx.asynclayoutinflater_asynclayoutinflater', 'path':'androidx/asynclayoutinflater/asynclayoutinflater'}, |
| 130 | 'androidx.car:car': {'name':'androidx.car_car', 'path':'androidx/car/car'}, |
Roberto Perez | 804fbb4 | 2018-09-10 17:58:11 -0700 | [diff] [blame] | 131 | 'androidx.car:car-cluster': {'name':'androidx.car_car-cluster', 'path':'androidx/car/car-cluster'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 132 | 'androidx.collection:collection': {'name':'androidx.collection_collection', 'path':'androidx/collection/collection'}, |
Aurimas Liutikas | d912476 | 2018-09-28 15:31:35 -0700 | [diff] [blame] | 133 | 'androidx.concurrent:concurrent-futures': {'name':'androidx.concurrent_concurrent-futures', 'path':'androidx/concurrent/concurrent-futures'}, |
Aurimas Liutikas | 8af28d3 | 2019-06-06 14:04:01 -0700 | [diff] [blame] | 134 | 'androidx.concurrent:concurrent-listenablefuture-callback': {'name':'androidx.concurrent_concurrent-listenablefuture-callback', 'path':'androidx/concurrent/concurrent-listenablefuture-callback'}, |
| 135 | 'androidx.concurrent:concurrent-listenablefuture': {'name':'androidx.concurrent_concurrent-listenablefuture', 'path':'androidx/concurrent/concurrent-listenablefuture'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 136 | 'androidx.core:core': {'name':'androidx.core_core', 'path':'androidx/core/core'}, |
| 137 | 'androidx.contentpaging:contentpaging': {'name':'androidx.contentpaging_contentpaging', 'path':'androidx/contentpaging/contentpaging'}, |
| 138 | 'androidx.coordinatorlayout:coordinatorlayout': {'name':'androidx.coordinatorlayout_coordinatorlayout', 'path':'androidx/coordinatorlayout/coordinatorlayout'}, |
| 139 | 'androidx.legacy:legacy-support-core-ui': {'name':'androidx.legacy_legacy-support-core-ui', 'path':'androidx/legacy/legacy-support-core-ui'}, |
| 140 | 'androidx.legacy:legacy-support-core-utils': {'name':'androidx.legacy_legacy-support-core-utils', 'path':'androidx/legacy/legacy-support-core-utils'}, |
| 141 | 'androidx.cursoradapter:cursoradapter': {'name':'androidx.cursoradapter_cursoradapter', 'path':'androidx/cursoradapter/cursoradapter'}, |
| 142 | 'androidx.browser:browser': {'name':'androidx.browser_browser', 'path':'androidx/browser/browser'}, |
| 143 | 'androidx.customview:customview': {'name':'androidx.customview_customview', 'path':'androidx/customview/customview'}, |
| 144 | 'androidx.documentfile:documentfile': {'name':'androidx.documentfile_documentfile', 'path':'androidx/documentfile/documentfile'}, |
| 145 | 'androidx.drawerlayout:drawerlayout': {'name':'androidx.drawerlayout_drawerlayout', 'path':'androidx/drawerlayout/drawerlayout'}, |
| 146 | 'androidx.dynamicanimation:dynamicanimation': {'name':'androidx.dynamicanimation_dynamicanimation', 'path':'androidx/dynamicanimation/dynamicanimation'}, |
| 147 | 'androidx.emoji:emoji': {'name':'androidx.emoji_emoji', 'path':'androidx/emoji/emoji'}, |
| 148 | 'androidx.emoji:emoji-appcompat': {'name':'androidx.emoji_emoji-appcompat', 'path':'androidx/emoji/emoji-appcompat'}, |
| 149 | 'androidx.emoji:emoji-bundled': {'name':'androidx.emoji_emoji-bundled', 'path':'androidx/emoji/emoji-bundled'}, |
| 150 | 'androidx.exifinterface:exifinterface': {'name':'androidx.exifinterface_exifinterface', 'path':'androidx/exifinterface/exifinterface'}, |
| 151 | 'androidx.fragment:fragment': {'name':'androidx.fragment_fragment', 'path':'androidx/fragment/fragment'}, |
| 152 | 'androidx.heifwriter:heifwriter': {'name':'androidx.heifwriter_heifwriter', 'path':'androidx/heifwriter/heifwriter'}, |
| 153 | 'androidx.interpolator:interpolator': {'name':'androidx.interpolator_interpolator', 'path':'androidx/interpolator/interpolator'}, |
| 154 | 'androidx.loader:loader': {'name':'androidx.loader_loader', 'path':'androidx/loader/loader'}, |
| 155 | 'androidx.localbroadcastmanager:localbroadcastmanager': {'name':'androidx.localbroadcastmanager_localbroadcastmanager', 'path':'androidx/localbroadcastmanager/localbroadcastmanager'}, |
| 156 | 'androidx.media:media': {'name':'androidx.media_media', 'path':'androidx/media/media'}, |
Oussama Ben Abdelbaki | 09fffcb | 2019-05-13 15:11:37 -0400 | [diff] [blame] | 157 | 'androidx.media2:media2-player': {'name':'androidx.media2_media2-player', 'path':'androidx/media2/media2-player'}, |
| 158 | 'androidx.media2:media2-session': {'name':'androidx.media2_media2-session', 'path':'androidx/media2/media2-session'}, |
| 159 | 'androidx.media2:media2-common': {'name':'androidx.media2_media2-common', 'path':'androidx/media2/media2-common'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 160 | 'androidx.media2:media2-exoplayer': {'name':'androidx.media2_media2-exoplayer', 'path':'androidx/media2/media2-exoplayer'}, |
Gyumin Sim | 1752eca | 2018-12-13 11:34:10 +0900 | [diff] [blame] | 161 | 'androidx.media2:media2-widget': {'name':'androidx.media2_media2-widget', 'path':'androidx/media2/media2-widget'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 162 | 'androidx.percentlayout:percentlayout': {'name':'androidx.percentlayout_percentlayout', 'path':'androidx/percentlayout/percentlayout'}, |
| 163 | 'androidx.print:print': {'name':'androidx.print_print', 'path':'androidx/print/print'}, |
| 164 | 'androidx.recommendation:recommendation': {'name':'androidx.recommendation_recommendation', 'path':'androidx/recommendation/recommendation'}, |
| 165 | 'androidx.recyclerview:recyclerview-selection': {'name':'androidx.recyclerview_recyclerview-selection', 'path':'androidx/recyclerview/recyclerview-selection'}, |
Oussama Ben Abdelbaki | 00f9b39 | 2019-03-18 14:45:12 -0400 | [diff] [blame] | 166 | 'androidx.savedstate:savedstate': {'name':'androidx.savedstate_savedstate', 'path':'androidx/savedstate/savedstate'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 167 | 'androidx.slidingpanelayout:slidingpanelayout': {'name':'androidx.slidingpanelayout_slidingpanelayout', 'path':'androidx/slidingpanelayout/slidingpanelayout'}, |
| 168 | 'androidx.swiperefreshlayout:swiperefreshlayout': {'name':'androidx.swiperefreshlayout_swiperefreshlayout', 'path':'androidx/swiperefreshlayout/swiperefreshlayout'}, |
| 169 | 'androidx.textclassifier:textclassifier': {'name':'androidx.textclassifier_textclassifier', 'path':'androidx/textclassifier/textclassifier'}, |
| 170 | 'androidx.transition:transition': {'name':'androidx.transition_transition', 'path':'androidx/transition/transition'}, |
| 171 | 'androidx.tvprovider:tvprovider': {'name':'androidx.tvprovider_tvprovider', 'path':'androidx/tvprovider/tvprovider'}, |
| 172 | 'androidx.legacy:legacy-support-v13': {'name':'androidx.legacy_legacy-support-v13', 'path':'androidx/legacy/legacy-support-v13'}, |
| 173 | 'androidx.legacy:legacy-preference-v14': {'name':'androidx.legacy_legacy-preference-v14', 'path':'androidx/legacy/legacy-preference-v14'}, |
| 174 | 'androidx.leanback:leanback': {'name':'androidx.leanback_leanback', 'path':'androidx/leanback/leanback'}, |
| 175 | 'androidx.leanback:leanback-preference': {'name':'androidx.leanback_leanback-preference', 'path':'androidx/leanback/leanback-preference'}, |
| 176 | 'androidx.legacy:legacy-support-v4': {'name':'androidx.legacy_legacy-support-v4', 'path':'androidx/legacy/legacy-support-v4'}, |
| 177 | 'androidx.appcompat:appcompat': {'name':'androidx.appcompat_appcompat', 'path':'androidx/appcompat/appcompat'}, |
Oussama Ben Abdelbaki | 61551b8 | 2019-02-12 15:56:27 -0500 | [diff] [blame] | 178 | 'androidx.appcompat:appcompat-resources': {'name':'androidx.appcompat_appcompat-resources', 'path':'androidx/appcompat/appcompat-resources'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 179 | 'androidx.cardview:cardview': {'name':'androidx.cardview_cardview', 'path':'androidx/cardview/cardview'}, |
| 180 | 'androidx.gridlayout:gridlayout': {'name':'androidx.gridlayout_gridlayout', 'path':'androidx/gridlayout/gridlayout'}, |
| 181 | 'androidx.mediarouter:mediarouter': {'name':'androidx.mediarouter_mediarouter', 'path':'androidx/mediarouter/mediarouter'}, |
| 182 | 'androidx.palette:palette': {'name':'androidx.palette_palette', 'path':'androidx/palette/palette'}, |
| 183 | 'androidx.preference:preference': {'name':'androidx.preference_preference', 'path':'androidx/preference/preference'}, |
| 184 | 'androidx.recyclerview:recyclerview': {'name':'androidx.recyclerview_recyclerview', 'path':'androidx/recyclerview/recyclerview'}, |
| 185 | 'androidx.vectordrawable:vectordrawable': {'name':'androidx.vectordrawable_vectordrawable', 'path':'androidx/vectordrawable/vectordrawable'}, |
| 186 | 'androidx.viewpager:viewpager': {'name':'androidx.viewpager_viewpager', 'path':'androidx/viewpager/viewpager'}, |
| 187 | 'androidx.wear:wear': {'name':'androidx.wear_wear', 'path':'androidx/wear/wear'}, |
| 188 | 'androidx.webkit:webkit': {'name':'androidx.webkit_webkit', 'path':'androidx/webkit/webkit'}, |
Kevin Chyn | b6ae85d | 2018-10-02 12:12:20 -0700 | [diff] [blame] | 189 | 'androidx.biometric:biometric': {'name':'androidx.biometric_biometric', 'path':'androidx/biometric/biometric'}, |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 190 | |
| 191 | # AndroidX for Multidex |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 192 | 'androidx.multidex:multidex': {'name':'androidx-multidex_multidex', 'path':'androidx/multidex/multidex'}, |
| 193 | 'androidx.multidex:multidex-instrumentation': {'name':'androidx-multidex_multidex-instrumentation', 'path':'androidx/multidex/multidex-instrumentation'}, |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 194 | |
| 195 | # AndroidX for Constraint Layout |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 196 | 'androidx.constraintlayout:constraintlayout': {'name':'androidx-constraintlayout_constraintlayout', 'path':'androidx/constraintlayout/constraintlayout'}, |
| 197 | 'androidx.constraintlayout:constraintlayout-solver': {'name':'androidx-constraintlayout_constraintlayout-solver', 'path':'androidx/constraintlayout/constraintlayout-solver'}, |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 198 | |
| 199 | # AndroidX for Architecture Components |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 200 | 'androidx.arch.core:core-common': {'name':'androidx.arch.core_core-common', 'path':'androidx/arch/core/core-common'}, |
| 201 | 'androidx.arch.core:core-runtime': {'name':'androidx.arch.core_core-runtime', 'path':'androidx/arch/core/core-runtime'}, |
| 202 | 'androidx.lifecycle:lifecycle-common': {'name':'androidx.lifecycle_lifecycle-common', 'path':'androidx/lifecycle/lifecycle-common'}, |
| 203 | 'androidx.lifecycle:lifecycle-common-java8': {'name':'androidx.lifecycle_lifecycle-common-java8', 'path':'androidx/lifecycle/lifecycle-common-java8'}, |
| 204 | 'androidx.lifecycle:lifecycle-extensions': {'name':'androidx.lifecycle_lifecycle-extensions', 'path':'androidx/lifecycle/lifecycle-extensions'}, |
| 205 | 'androidx.lifecycle:lifecycle-livedata': {'name':'androidx.lifecycle_lifecycle-livedata', 'path':'androidx/lifecycle/lifecycle-livedata'}, |
| 206 | 'androidx.lifecycle:lifecycle-livedata-core': {'name':'androidx.lifecycle_lifecycle-livedata-core', 'path':'androidx/lifecycle/lifecycle-livedata-core'}, |
| 207 | 'androidx.lifecycle:lifecycle-process': {'name':'androidx.lifecycle_lifecycle-process', 'path':'androidx/lifecycle/lifecycle-process'}, |
| 208 | 'androidx.lifecycle:lifecycle-runtime': {'name':'androidx.lifecycle_lifecycle-runtime', 'path':'androidx/lifecycle/lifecycle-runtime'}, |
| 209 | 'androidx.lifecycle:lifecycle-service': {'name':'androidx.lifecycle_lifecycle-service', 'path':'androidx/lifecycle/lifecycle-service'}, |
| 210 | 'androidx.lifecycle:lifecycle-viewmodel': {'name':'androidx.lifecycle_lifecycle-viewmodel', 'path':'androidx/lifecycle/lifecycle-viewmodel'}, |
Aurimas Liutikas | b5836e2 | 2019-09-06 09:00:45 -0700 | [diff] [blame^] | 211 | 'androidx.lifecycle:lifecycle-viewmodel-savedstate': {'name':'androidx.lifecycle_lifecycle-viewmodel-savedstate', 'path':'androidx/lifecycle/lifecycle-viewmodel-savedstate'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 212 | 'androidx.paging:paging-common': {'name':'androidx.paging_paging-common', 'path':'androidx/paging/paging-common'}, |
Aurimas Liutikas | b5836e2 | 2019-09-06 09:00:45 -0700 | [diff] [blame^] | 213 | 'androidx.paging:paging-common-ktx': {'name':'androidx.paging_paging-common-ktx', 'path':'androidx/paging/paging-common-ktx'}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 214 | 'androidx.paging:paging-runtime': {'name':'androidx.paging_paging-runtime', 'path':'androidx/paging/paging-runtime'}, |
| 215 | 'androidx.sqlite:sqlite': {'name':'androidx.sqlite_sqlite', 'path':'androidx/sqlite/sqlite'}, |
| 216 | 'androidx.sqlite:sqlite-framework': {'name':'androidx.sqlite_sqlite-framework', 'path':'androidx/sqlite/sqlite-framework'}, |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 217 | 'androidx.room:room-common': {'name':'androidx.room_room-common', 'path':'androidx/room/room-common', 'host_and_device' : True}, |
| 218 | 'androidx.room:room-compiler': {'name':'androidx.room_room-compiler', 'path':'androidx/room/room-compiler', 'host' : True}, |
| 219 | 'androidx.room:room-migration': {'name':'androidx.room_room-migration', 'path':'androidx/room/room-migration', 'host_and_device' : True}, |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 220 | 'androidx.room:room-runtime': {'name':'androidx.room_room-runtime', 'path':'androidx/room/room-runtime'}, |
| 221 | 'androidx.room:room-testing': {'name':'androidx.room_room-testing', 'path':'androidx/room/room-testing'}, |
Allen | ab72f01 | 2018-01-29 18:10:23 -0800 | [diff] [blame] | 222 | |
Alan Viverette | 19ecd50 | 2018-01-05 13:52:16 -0500 | [diff] [blame] | 223 | # Lifecycle |
Alan Viverette | c7e88f1 | 2018-02-13 15:29:50 -0500 | [diff] [blame] | 224 | # Missing dependencies: |
| 225 | # - auto-common |
| 226 | # - javapoet |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 227 | #'android.arch.lifecycle:compiler': {'name':'android-arch-lifecycle-compiler', 'path':'arch-lifecycle/compiler'}, |
Alan Viverette | c7e88f1 | 2018-02-13 15:29:50 -0500 | [diff] [blame] | 228 | # Missing dependencies: |
| 229 | # - reactive-streams |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 230 | #'android.arch.lifecycle:reactivestreams': 'android-arch-lifecycle-reactivestreams','arch-lifecycle/reactivestreams', |
Allen | ab72f01 | 2018-01-29 18:10:23 -0800 | [diff] [blame] | 231 | |
Alan Viverette | 19ecd50 | 2018-01-05 13:52:16 -0500 | [diff] [blame] | 232 | # Room |
Alan Viverette | c7e88f1 | 2018-02-13 15:29:50 -0500 | [diff] [blame] | 233 | # Missing dependencies: |
| 234 | # - auto-common |
| 235 | # - javapoet |
| 236 | # - antlr4 |
| 237 | # - kotlin-metadata |
| 238 | # - commons-codec |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 239 | #'android.arch.persistence.room:compiler': {'name':'android-arch-room-compiler', 'path':'arch-room/compiler'}, |
Alan Viverette | c7e88f1 | 2018-02-13 15:29:50 -0500 | [diff] [blame] | 240 | # Missing dependencies: |
| 241 | # - rxjava |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 242 | #'android.arch.persistence.room:rxjava2': {'name':'android-arch-room-rxjava2', 'path':'arch-room/rxjava2'}, |
Allen | ab72f01 | 2018-01-29 18:10:23 -0800 | [diff] [blame] | 243 | |
Jeff Gaston | 6e7e750 | 2018-04-04 00:22:45 -0400 | [diff] [blame] | 244 | # Third-party dependencies |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 245 | 'com.google.android:flexbox': {'name':'flexbox', 'path':'flexbox'}, |
Jeff Gaston | 6e7e750 | 2018-04-04 00:22:45 -0400 | [diff] [blame] | 246 | |
| 247 | # Support Library Material Design Components |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 248 | 'com.android.support:design': {'name':'android-support-design', 'path':'design'}, |
| 249 | 'com.android.support:design-animation': {'name':'android-support-design-animation', 'path':'design-animation'}, |
| 250 | 'com.android.support:design-bottomnavigation': {'name':'android-support-design-bottomnavigation', 'path':'design-bottomnavigation'}, |
| 251 | 'com.android.support:design-bottomsheet': {'name':'android-support-design-bottomsheet', 'path':'design-bottomsheet'}, |
| 252 | 'com.android.support:design-button': {'name':'android-support-design-button', 'path':'design-button'}, |
| 253 | 'com.android.support:design-canvas': {'name':'android-support-design-canvas', 'path':'design-canvas'}, |
| 254 | 'com.android.support:design-card': {'name':'android-support-design-card', 'path':'design-card'}, |
| 255 | 'com.android.support:design-chip': {'name':'android-support-design-chip', 'path':'design-chip'}, |
| 256 | 'com.android.support:design-circularreveal': {'name':'android-support-design-circularreveal', 'path':'design-circularreveal'}, |
| 257 | 'com.android.support:design-circularreveal-cardview': {'name':'android-support-design-circularreveal-cardview', 'path':'design-circularreveal-cardview'}, |
| 258 | 'com.android.support:design-circularreveal-coordinatorlayout': {'name':'android-support-design-circularreveal-coordinatorlayout', 'path':'design-circularreveal-coordinatorlayout'}, |
| 259 | 'com.android.support:design-color': {'name':'android-support-design-color', 'path':'design-color'}, |
| 260 | 'com.android.support:design-dialog': {'name':'android-support-design-dialog', 'path':'design-dialog'}, |
| 261 | 'com.android.support:design-drawable': {'name':'android-support-design-drawable', 'path':'design-drawable'}, |
| 262 | 'com.android.support:design-expandable': {'name':'android-support-design-expandable', 'path':'design-expandable'}, |
| 263 | 'com.android.support:design-floatingactionbutton': {'name':'android-support-design-floatingactionbutton', 'path':'design-floatingactionbutton'}, |
| 264 | 'com.android.support:design-internal': {'name':'android-support-design-internal', 'path':'design-internal'}, |
| 265 | 'com.android.support:design-math': {'name':'android-support-design-math', 'path':'design-math'}, |
| 266 | 'com.android.support:design-resources': {'name':'android-support-design-resources', 'path':'design-resources'}, |
| 267 | 'com.android.support:design-ripple': {'name':'android-support-design-ripple', 'path':'design-ripple'}, |
| 268 | 'com.android.support:design-snackbar': {'name':'android-support-design-snackbar', 'path':'design-snackbar'}, |
| 269 | 'com.android.support:design-stateful': {'name':'android-support-design-stateful', 'path':'design-stateful'}, |
| 270 | 'com.android.support:design-textfield': {'name':'android-support-design-textfield', 'path':'design-textfield'}, |
| 271 | 'com.android.support:design-theme': {'name':'android-support-design-theme', 'path':'design-theme'}, |
| 272 | 'com.android.support:design-transformation': {'name':'android-support-design-transformation', 'path':'design-transformation'}, |
| 273 | 'com.android.support:design-typography': {'name':'android-support-design-typography', 'path':'design-typography'}, |
| 274 | 'com.android.support:design-widget': {'name':'android-support-design-widget', 'path':'design-widget'}, |
| 275 | 'com.android.support:design-navigation': {'name':'android-support-design-navigation', 'path':'design-navigation'}, |
| 276 | 'com.android.support:design-tabs': {'name':'android-support-design-tabs', 'path':'design-tabs'}, |
| 277 | 'com.android.support:design-bottomappbar': {'name':'android-support-design-bottomappbar', 'path':'design-bottomappbar'}, |
| 278 | 'com.android.support:design-shape': {'name':'android-support-design-shape', 'path':'design-shape'}, |
Alan Viverette | a59082b | 2018-02-22 10:27:46 -0500 | [diff] [blame] | 279 | |
Jeff Gaston | fa7c7e8 | 2018-04-06 13:35:48 -0400 | [diff] [blame] | 280 | # Androidx Material Design Components |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 281 | 'com.google.android.material:material': {'name':'com.google.android.material_material', 'path':'com/google/android/material/material'}, |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | # Always remove these files. |
| 285 | blacklist_files = [ |
| 286 | 'annotations.zip', |
| 287 | 'public.txt', |
| 288 | 'R.txt', |
Alan Viverette | 44ad4e4 | 2017-08-09 17:45:00 -0400 | [diff] [blame] | 289 | 'AndroidManifest.xml', |
Alan Viverette | f48d9b4 | 2017-08-17 14:45:46 -0400 | [diff] [blame] | 290 | os.path.join('libs','noto-emoji-compat-java.jar') |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 291 | ] |
| 292 | |
Alan Viverette | 44ad4e4 | 2017-08-09 17:45:00 -0400 | [diff] [blame] | 293 | artifact_pattern = re.compile(r"^(.+?)-(\d+\.\d+\.\d+(?:-\w+\d+)?(?:-[\d.]+)*)\.(jar|aar)$") |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 294 | |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 295 | |
| 296 | class MavenLibraryInfo: |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 297 | def __init__(self, key, group_id, artifact_id, version, dir, repo_dir, file): |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 298 | self.key = key |
| 299 | self.group_id = group_id |
| 300 | self.artifact_id = artifact_id |
| 301 | self.version = version |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 302 | self.dir = dir |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 303 | self.repo_dir = repo_dir |
| 304 | self.file = file |
| 305 | |
| 306 | |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 307 | def print_e(*args, **kwargs): |
| 308 | print(*args, file=sys.stderr, **kwargs) |
| 309 | |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 310 | |
| 311 | def touch(fname, times=None): |
| 312 | with open(fname, 'a'): |
| 313 | os.utime(fname, times) |
| 314 | |
| 315 | |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 316 | def path(*path_parts): |
| 317 | return reduce((lambda x, y: os.path.join(x, y)), path_parts) |
| 318 | |
| 319 | |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 320 | def flatten(list): |
| 321 | return reduce((lambda x, y: "%s %s" % (x, y)), list) |
| 322 | |
| 323 | |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 324 | def rm(path): |
| 325 | if os.path.isdir(path): |
| 326 | rmtree(path) |
| 327 | elif os.path.exists(path): |
| 328 | os.remove(path) |
| 329 | |
| 330 | |
| 331 | def mv(src_path, dst_path): |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 332 | if os.path.exists(dst_path): |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 333 | rm(dst_path) |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 334 | if not os.path.exists(os.path.dirname(dst_path)): |
| 335 | os.makedirs(os.path.dirname(dst_path)) |
Jiyong Park | 1d1c963 | 2018-05-29 17:45:27 +0900 | [diff] [blame] | 336 | for f in (glob.glob(src_path)): |
| 337 | if '*' in dst_path: |
| 338 | dst = os.path.join(os.path.dirname(dst_path), os.path.basename(f)) |
| 339 | else: |
| 340 | dst = dst_path |
shepshapard | e4127cf | 2019-09-03 16:08:44 -0700 | [diff] [blame] | 341 | move(f, dst) |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 342 | |
| 343 | |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 344 | def detect_artifacts(maven_repo_dirs): |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 345 | maven_lib_info = {} |
| 346 | |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 347 | # Find the latest revision for each artifact, remove others |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 348 | for repo_dir in maven_repo_dirs: |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 349 | for root, dirs, files in os.walk(repo_dir): |
| 350 | for file in files: |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 351 | if file[-4:] == ".pom": |
| 352 | # Read the POM (hack hack hack). |
| 353 | group_id = '' |
| 354 | artifact_id = '' |
| 355 | version = '' |
| 356 | file = os.path.join(root, file) |
| 357 | with open(file) as pom_file: |
| 358 | for line in pom_file: |
| 359 | if line[:11] == ' <groupId>': |
| 360 | group_id = line[11:-11] |
| 361 | elif line[:14] == ' <artifactId>': |
| 362 | artifact_id = line[14:-14] |
| 363 | elif line[:11] == ' <version>': |
| 364 | version = line[11:-11] |
| 365 | if group_id == '' or artifact_id == '' or version == '': |
| 366 | print_e('Failed to find Maven artifact data in ' + file) |
| 367 | continue |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 368 | |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 369 | # Locate the artifact. |
| 370 | artifact_file = file[:-4] |
| 371 | if os.path.exists(artifact_file + '.jar'): |
| 372 | artifact_file = artifact_file + '.jar' |
| 373 | elif os.path.exists(artifact_file + '.aar'): |
| 374 | artifact_file = artifact_file + '.aar' |
| 375 | else: |
| 376 | print_e('Failed to find artifact for ' + artifact_file) |
| 377 | continue |
| 378 | |
| 379 | # Make relative to root. |
| 380 | artifact_file = artifact_file[len(root) + 1:] |
| 381 | |
| 382 | # Find the mapping. |
| 383 | group_artifact = group_id + ':' + artifact_id |
Jeff Gaston | 3e622ba | 2018-03-26 23:24:46 -0400 | [diff] [blame] | 384 | if group_artifact in maven_to_make: |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 385 | key = group_artifact |
Jeff Gaston | 3e622ba | 2018-03-26 23:24:46 -0400 | [diff] [blame] | 386 | elif artifact_id in maven_to_make: |
| 387 | key = artifact_id |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 388 | else: |
| 389 | print_e('Failed to find artifact mapping for ' + group_artifact) |
| 390 | continue |
| 391 | |
| 392 | # Store the latest version. |
| 393 | version = LooseVersion(version) |
| 394 | if key not in maven_lib_info \ |
| 395 | or version > maven_lib_info[key].version: |
| 396 | maven_lib_info[key] = MavenLibraryInfo(key, group_id, artifact_id, version, |
| 397 | root, repo_dir, artifact_file) |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 398 | |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 399 | return maven_lib_info |
| 400 | |
| 401 | |
Colin Cross | 59b59db | 2018-04-24 13:58:05 -0700 | [diff] [blame] | 402 | def transform_maven_repos(maven_repo_dirs, transformed_dir, extract_res=True, include_static_deps=True): |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 403 | cwd = os.getcwd() |
| 404 | |
| 405 | # Use a temporary working directory. |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 406 | maven_lib_info = detect_artifacts(maven_repo_dirs) |
Jeff Gaston | a68a8d4 | 2018-03-23 14:00:13 -0400 | [diff] [blame] | 407 | working_dir = temp_dir |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 408 | |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 409 | if not maven_lib_info: |
| 410 | print_e('Failed to detect artifacts') |
| 411 | return False |
| 412 | |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 413 | # extract some files (for example, AndroidManifest.xml) from any relevant artifacts |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 414 | for info in maven_lib_info.values(): |
Alan Viverette | d8ce722 | 2017-12-11 17:24:43 -0500 | [diff] [blame] | 415 | transform_maven_lib(working_dir, info, extract_res) |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 416 | |
Colin Cross | 74683bc | 2018-04-11 17:36:18 -0700 | [diff] [blame] | 417 | # generate a single Android.bp that specifies to use all of the above artifacts |
| 418 | makefile = os.path.join(working_dir, 'Android.bp') |
Alan Viverette | 4ec9a17 | 2018-02-20 16:19:31 -0500 | [diff] [blame] | 419 | with open(makefile, 'w') as f: |
Colin Cross | 74683bc | 2018-04-11 17:36:18 -0700 | [diff] [blame] | 420 | args = ["pom2bp", "-sdk-version", "current"] |
Jeff Gaston | 1cc0609 | 2018-03-28 15:51:02 -0400 | [diff] [blame] | 421 | if include_static_deps: |
| 422 | args.append("-static-deps") |
Jeff Gaston | 54868ee | 2018-04-25 19:43:35 -0400 | [diff] [blame] | 423 | rewriteNames = sorted([name for name in maven_to_make if ":" in name] + [name for name in maven_to_make if ":" not in name]) |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 424 | args.extend(["-rewrite=^" + name + "$=" + maven_to_make[name]['name'] for name in rewriteNames]) |
Jeff Gaston | 07a3cf7 | 2018-08-24 14:16:34 -0400 | [diff] [blame] | 425 | args.extend(["-rewrite=^com.squareup:javapoet$=javapoet-prebuilt-jar"]) |
Aurimas Liutikas | d912476 | 2018-09-28 15:31:35 -0700 | [diff] [blame] | 426 | args.extend(["-rewrite=^com.google.guava:listenablefuture$=guava-listenablefuture-prebuilt-jar"]) |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 427 | args.extend(["-rewrite=^sqlite-jdbc$=xerial-sqlite-jdbc"]) |
| 428 | args.extend(["-rewrite=^kotlinx-metadata-jvm$=kotlin-metadata"]) |
| 429 | args.extend(["-rewrite=^gson$=gson-prebuilt-jar"]) |
Paul Duffin | 44e033b | 2019-04-16 11:28:13 +0100 | [diff] [blame] | 430 | args.extend(["-extra-static-libs=android-support-car=prebuilt-android.car-stubs"]) |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 431 | args.extend(["-extra-static-libs=androidx.room_room-compiler=guava-21.0"]) |
Jeff Gaston | 07a3cf7 | 2018-08-24 14:16:34 -0400 | [diff] [blame] | 432 | args.extend(["-host=" + name for name in maven_to_make if maven_to_make[name].get('host')]) |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 433 | args.extend(["-host-and-device=" + name for name in maven_to_make if maven_to_make[name].get('host_and_device')]) |
Colin Cross | 2106007 | 2018-04-24 13:52:29 -0700 | [diff] [blame] | 434 | # these depend on GSON which is not in AOSP |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 435 | args.extend(["-exclude=android-arch-room-migration", |
Colin Cross | 2106007 | 2018-04-24 13:52:29 -0700 | [diff] [blame] | 436 | "-exclude=android-arch-room-testing"]) |
Jeff Gaston | 7ec1d8f | 2018-03-27 00:25:12 -0400 | [diff] [blame] | 437 | args.extend(["."]) |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 438 | subprocess.check_call(args, stdout=f, cwd=working_dir) |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 439 | |
| 440 | # Replace the old directory. |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 441 | output_dir = os.path.join(cwd, transformed_dir) |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 442 | mv(working_dir, output_dir) |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 443 | return True |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 444 | |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 445 | # moves <artifact_info> (of type MavenLibraryInfo) into the appropriate part of <working_dir> , and possibly unpacks any necessary included files |
Alan Viverette | d8ce722 | 2017-12-11 17:24:43 -0500 | [diff] [blame] | 446 | def transform_maven_lib(working_dir, artifact_info, extract_res): |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 447 | # Move library into working dir |
Jeff Gaston | 9edf86c | 2018-04-18 13:45:23 -0400 | [diff] [blame] | 448 | new_dir = os.path.normpath(os.path.join(working_dir, os.path.relpath(artifact_info.dir, artifact_info.repo_dir))) |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 449 | mv(artifact_info.dir, new_dir) |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 450 | |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 451 | matcher = artifact_pattern.match(artifact_info.file) |
| 452 | maven_lib_name = artifact_info.key |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 453 | maven_lib_vers = matcher.group(2) |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 454 | maven_lib_type = artifact_info.file[-3:] |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 455 | |
Jeff Gaston | a0bce60 | 2018-08-24 14:05:03 -0400 | [diff] [blame] | 456 | make_lib_name = maven_to_make[artifact_info.key]['name'] |
| 457 | make_dir_name = maven_to_make[artifact_info.key]['path'] |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 458 | |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 459 | artifact_file = os.path.join(new_dir, artifact_info.file) |
| 460 | |
Colin Cross | 59b59db | 2018-04-24 13:58:05 -0700 | [diff] [blame] | 461 | if maven_lib_type == "aar": |
| 462 | if extract_res: |
| 463 | target_dir = os.path.join(working_dir, make_dir_name) |
| 464 | if not os.path.exists(target_dir): |
| 465 | os.makedirs(target_dir) |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 466 | |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 467 | process_aar(artifact_file, target_dir) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 468 | |
Colin Cross | 59b59db | 2018-04-24 13:58:05 -0700 | [diff] [blame] | 469 | with zipfile.ZipFile(artifact_file) as zip: |
| 470 | manifests_dir = os.path.join(working_dir, "manifests") |
| 471 | zip.extract("AndroidManifest.xml", os.path.join(manifests_dir, make_lib_name)) |
Dan Willemsen | d677b60 | 2017-11-08 22:13:17 -0800 | [diff] [blame] | 472 | |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 473 | print(maven_lib_vers, ":", maven_lib_name, "->", make_lib_name) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 474 | |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 475 | |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 476 | def process_aar(artifact_file, target_dir): |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 477 | # Extract AAR file to target_dir. |
| 478 | with zipfile.ZipFile(artifact_file) as zip: |
| 479 | zip.extractall(target_dir) |
| 480 | |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 481 | # Remove classes.jar |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 482 | classes_jar = os.path.join(target_dir, "classes.jar") |
| 483 | if os.path.exists(classes_jar): |
Dan Willemsen | 814152e | 2017-11-06 13:22:11 -0800 | [diff] [blame] | 484 | os.remove(classes_jar) |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 485 | |
| 486 | # Remove or preserve empty dirs. |
| 487 | for root, dirs, files in os.walk(target_dir): |
| 488 | for dir in dirs: |
| 489 | dir_path = os.path.join(root, dir) |
| 490 | if not os.listdir(dir_path): |
| 491 | os.rmdir(dir_path) |
| 492 | |
| 493 | # Remove top-level cruft. |
| 494 | for file in blacklist_files: |
| 495 | file_path = os.path.join(target_dir, file) |
| 496 | if os.path.exists(file_path): |
| 497 | os.remove(file_path) |
| 498 | |
Alan Viverette | f17c940 | 2017-07-19 12:57:40 -0400 | [diff] [blame] | 499 | |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 500 | def fetch_artifact(target, build_id, artifact_path): |
Jiyong Park | 1d1c963 | 2018-05-29 17:45:27 +0900 | [diff] [blame] | 501 | download_to = os.path.join('.', os.path.dirname(artifact_path)) |
| 502 | print('Fetching %s from %s ...' % (artifact_path, target)) |
| 503 | if not os.path.exists(download_to): |
| 504 | os.makedirs(download_to) |
| 505 | fetch_cmd = [FETCH_ARTIFACT, '--bid', str(build_id), '--target', target, artifact_path, |
| 506 | download_to] |
Jeff Gaston | 97a9b76 | 2018-10-02 15:15:12 -0400 | [diff] [blame] | 507 | print("Running: " + ' '.join(fetch_cmd)) |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 508 | try: |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 509 | subprocess.check_output(fetch_cmd, stderr=subprocess.STDOUT) |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 510 | except subprocess.CalledProcessError: |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 511 | print_e('FAIL: Unable to retrieve %s artifact for build ID %s' % (artifact_path, build_id)) |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 512 | print_e('Please make sure you are authenticated for build server access!') |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 513 | return None |
| 514 | return artifact_path |
| 515 | |
| 516 | |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 517 | def fetch_artifacts(target, build_id, artifact_dict): |
| 518 | for artifact, target_path in artifact_dict.items(): |
| 519 | artifact_path = fetch_artifact(target, build_id.url_id, artifact) |
| 520 | if not artifact_path: |
| 521 | return False |
| 522 | mv(artifact_path, target_path) |
| 523 | return True |
| 524 | |
| 525 | |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 526 | def extract_artifact(artifact_path): |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 527 | # Unzip the repo archive into a separate directory. |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 528 | repo_dir = os.path.basename(artifact_path)[:-4] |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 529 | with zipfile.ZipFile(artifact_path) as zipFile: |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 530 | zipFile.extractall(repo_dir) |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 531 | return repo_dir |
| 532 | |
| 533 | |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 534 | def fetch_and_extract(target, build_id, file, artifact_path=None): |
| 535 | if not artifact_path: |
| 536 | artifact_path = fetch_artifact(target, build_id, file) |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 537 | if not artifact_path: |
| 538 | return None |
| 539 | return extract_artifact(artifact_path) |
| 540 | |
| 541 | |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 542 | def update_support(target, build_id, local_file): |
| 543 | if build_id: |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 544 | repo_file = 'top-of-tree-m2repository-dejetified-%s.zip' % build_id.fs_id |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 545 | repo_dir = fetch_and_extract(target, build_id.url_id, repo_file, None) |
| 546 | else: |
| 547 | repo_dir = fetch_and_extract(target, None, None, local_file) |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 548 | if not repo_dir: |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 549 | print_e('Failed to extract Support Library repository') |
Alan Viverette | f48d9b4 | 2017-08-17 14:45:46 -0400 | [diff] [blame] | 550 | return False |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 551 | |
| 552 | # Transform the repo archive into a Makefile-compatible format. |
Colin Cross | 59b59db | 2018-04-24 13:58:05 -0700 | [diff] [blame] | 553 | return transform_maven_repos([repo_dir], support_dir, extract_res=True) |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 554 | |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 555 | |
Jeff Gaston | 08a2ee4 | 2018-05-07 18:08:41 -0400 | [diff] [blame] | 556 | def update_androidx(target, build_id, local_file): |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 557 | if build_id: |
Anthony Chen | acbb487 | 2018-07-02 11:22:48 -0700 | [diff] [blame] | 558 | repo_file = 'top-of-tree-m2repository-all-%s.zip' % build_id.fs_id |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 559 | repo_dir = fetch_and_extract(target, build_id.url_id, repo_file, None) |
| 560 | else: |
| 561 | repo_dir = fetch_and_extract(target, None, None, local_file) |
| 562 | if not repo_dir: |
| 563 | print_e('Failed to extract AndroidX repository') |
| 564 | return False |
| 565 | |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 566 | # Keep JavaPlugins.bp file untounched. |
| 567 | java_plugins_bp_path = os.path.join(androidx_dir, 'JavaPlugins.bp') |
| 568 | tmp_java_plugins_bp_path = os.path.join('/tmp', 'JavaPlugins.bp') |
| 569 | mv(java_plugins_bp_path, tmp_java_plugins_bp_path) |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 570 | |
Tony Mak | 0f65875 | 2019-07-19 11:11:05 +0100 | [diff] [blame] | 571 | # Transform the repo archive into a Makefile-compatible format. |
| 572 | if not transform_maven_repos([repo_dir], androidx_dir, extract_res=False): |
| 573 | return False |
| 574 | |
| 575 | # Import JavaPlugins.bp in Android.bp. |
| 576 | makefile = os.path.join(androidx_dir, 'Android.bp') |
| 577 | with open(makefile, "a+") as f: |
| 578 | f.write('\nbuild = ["JavaPlugins.bp"]\n') |
| 579 | mv(tmp_java_plugins_bp_path, java_plugins_bp_path) |
| 580 | |
| 581 | return True |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 582 | |
Jeff Gaston | 782c3e3 | 2018-02-06 14:36:17 -0500 | [diff] [blame] | 583 | def update_jetifier(target, build_id): |
| 584 | repo_file = 'jetifier-standalone.zip' |
| 585 | repo_dir = fetch_and_extract(target, build_id.url_id, repo_file) |
| 586 | if not repo_dir: |
| 587 | print_e('Failed to extract Jetifier') |
| 588 | return False |
| 589 | |
| 590 | rm(jetifier_dir) |
Jeff Gaston | 553a437 | 2018-03-29 18:34:22 -0400 | [diff] [blame] | 591 | mv(os.path.join(repo_dir, 'jetifier-standalone'), jetifier_dir) |
| 592 | os.chmod(os.path.join(jetifier_dir, 'bin', 'jetifier-standalone'), 0o755) |
Jeff Gaston | 782c3e3 | 2018-02-06 14:36:17 -0500 | [diff] [blame] | 593 | return True |
| 594 | |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 595 | |
Jeff Gaston | db739a2 | 2018-06-26 14:12:22 -0400 | [diff] [blame] | 596 | def update_constraint(target, build_id, local_file): |
| 597 | if build_id: |
| 598 | layout_dir = fetch_and_extract(target, build_id.url_id, |
| 599 | 'com.android.support.constraint-constraint-layout-%s.zip' % build_id.fs_id) |
| 600 | solver_dir = fetch_and_extract(target, build_id.url_id, |
| 601 | 'com.android.support.constraint-constraint-layout-solver-%s.zip' % build_id.fs_id) |
| 602 | if not layout_dir or not solver_dir: |
| 603 | print_e('Failed to extract Constraint Layout repositories') |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 604 | return False |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 605 | |
Jeff Gaston | db739a2 | 2018-06-26 14:12:22 -0400 | [diff] [blame] | 606 | dirs = [layout_dir, solver_dir] |
| 607 | else: |
| 608 | repo_dir = extract_artifact(local_file) |
| 609 | if not repo_dir: |
| 610 | print_e('Failed to extract Constraint Layout') |
| 611 | return False |
| 612 | dirs = [repo_dir] |
| 613 | |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 614 | # Passing False here is an inelegant solution, but it means we can replace |
| 615 | # the top-level directory without worrying about other child directories. |
Jeff Gaston | db739a2 | 2018-06-26 14:12:22 -0400 | [diff] [blame] | 616 | return transform_maven_repos(dirs, |
Alan Viverette | c960cfb | 2017-12-04 13:09:22 -0500 | [diff] [blame] | 617 | os.path.join(extras_dir, 'constraint-layout'), extract_res=False) |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 618 | |
Jeff Gaston | 9edf86c | 2018-04-18 13:45:23 -0400 | [diff] [blame] | 619 | def update_constraint_x(local_file): |
| 620 | repo_dir = extract_artifact(local_file) |
| 621 | if not repo_dir: |
| 622 | print_e('Failed to extract Constraint Layout X') |
| 623 | return False |
| 624 | return transform_maven_repos([repo_dir], os.path.join(extras_dir, 'constraint-layout-x'), extract_res=False) |
| 625 | |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 626 | |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 627 | def update_design(file): |
| 628 | design_dir = extract_artifact(file) |
| 629 | if not design_dir: |
| 630 | print_e('Failed to extract Design Library repositories') |
| 631 | return False |
| 632 | |
| 633 | # Don't bother extracting resources -- this should only be used with AAPT2. |
Jeff Gaston | c302bb9 | 2018-03-23 13:53:48 -0400 | [diff] [blame] | 634 | return transform_maven_repos([design_dir], |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 635 | os.path.join(extras_dir, 'material-design'), extract_res=False) |
| 636 | |
| 637 | |
Jeff Gaston | 6e7e750 | 2018-04-04 00:22:45 -0400 | [diff] [blame] | 638 | def update_material(file): |
| 639 | design_dir = extract_artifact(file) |
| 640 | if not design_dir: |
| 641 | print_e('Failed to extract intermediate-AndroidX Design Library repositories') |
| 642 | return False |
| 643 | |
| 644 | # Don't bother extracting resources -- this should only be used with AAPT2. |
| 645 | return transform_maven_repos([design_dir], |
| 646 | os.path.join(extras_dir, 'material-design-x'), extract_res=False) |
| 647 | |
| 648 | |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 649 | def extract_to(zip_file, filename, parent_path): |
| 650 | zip_path = next(filter(lambda path: filename in path, zip_file.namelist())) |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 651 | src_path = zip_file.extract(zip_path) |
| 652 | dst_path = path(parent_path, filename) |
| 653 | mv(src_path, dst_path) |
| 654 | |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 655 | def update_framework(build_id, sdk_dir): |
Sundong Ahn | 66091f2 | 2018-08-29 18:54:28 +0900 | [diff] [blame] | 656 | api_scope_list = ['public', 'system', 'test'] |
| 657 | if sdk_dir == 'current': |
| 658 | api_scope_list.append('core') |
| 659 | |
| 660 | for api_scope in api_scope_list: |
Jiyong Park | 1d1c963 | 2018-05-29 17:45:27 +0900 | [diff] [blame] | 661 | target_dir = path(sdk_dir, api_scope) |
Sundong Ahn | 66091f2 | 2018-08-29 18:54:28 +0900 | [diff] [blame] | 662 | if api_scope == 'core': |
| 663 | artifact_to_path = {'core.current.stubs.jar': path(target_dir, 'android.jar')} |
| 664 | else: |
| 665 | artifact_to_path = {'apistubs/android/' + api_scope + '/*.jar': path(target_dir, '*')} |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 666 | |
| 667 | if not fetch_artifacts(framework_sdk_target, build_id, artifact_to_path): |
| 668 | return False |
| 669 | |
Jiyong Park | 1d1c963 | 2018-05-29 17:45:27 +0900 | [diff] [blame] | 670 | if api_scope == 'public': |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 671 | # Fetch a few artifacts from the public sdk. |
Sundong Ahn | 66091f2 | 2018-08-29 18:54:28 +0900 | [diff] [blame] | 672 | artifact = 'sdk-repo-linux-platforms-%s.zip' % build_id.fs_id |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 673 | artifact_path = fetch_artifact(framework_sdk_target, build_id.url_id, artifact) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 674 | if not artifact_path: |
| 675 | return False |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 676 | |
| 677 | with zipfile.ZipFile(artifact_path) as zipFile: |
| 678 | for filename in ['android.jar', 'framework.aidl', 'uiautomator.jar']: |
| 679 | extract_to(zipFile, filename, target_dir) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 680 | |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 681 | return True |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 682 | |
Sundong Ahn | cc34cc3 | 2018-07-11 15:18:47 +0900 | [diff] [blame] | 683 | def update_makefile(build_id): |
| 684 | template = '"%s",\n\ |
| 685 | "current"' |
| 686 | makefile = os.path.join(git_dir, 'Android.bp') |
| 687 | |
| 688 | with open(makefile, 'r+') as f: |
| 689 | contents = f.read().replace('"current"', template % build_id) |
| 690 | f.seek(0) |
| 691 | f.write(contents) |
| 692 | |
| 693 | return True |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 694 | |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 695 | def finalize_sdk(build_id, sdk_version): |
| 696 | target_finalize_dir = '%d' % sdk_version |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 697 | |
Sundong Ahn | 66091f2 | 2018-08-29 18:54:28 +0900 | [diff] [blame] | 698 | for api_scope in ['public', 'system', 'test']: |
| 699 | artifact_to_path = {'apistubs/android/' + api_scope + '/api/*.txt': |
| 700 | path(target_finalize_dir, api_scope, 'api', '*')} |
| 701 | |
| 702 | if not fetch_artifacts(framework_sdk_target, build_id, artifact_to_path): |
| 703 | return False |
| 704 | |
| 705 | return update_framework(build_id, target_finalize_dir) \ |
Sundong Ahn | cc34cc3 | 2018-07-11 15:18:47 +0900 | [diff] [blame] | 706 | and update_makefile(target_finalize_dir) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 707 | |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 708 | |
Anton Hansson | 1d01a03 | 2018-04-09 10:29:37 +0100 | [diff] [blame] | 709 | def update_framework_current(build_id): |
| 710 | return update_framework(build_id, current_path) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 711 | |
| 712 | |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 713 | def update_buildtools(target, arch, build_id): |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 714 | artifact_path = fetch_and_extract(target, build_id.url_id, |
| 715 | "sdk-repo-%s-build-tools-%s.zip" % (arch, build_id.fs_id)) |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 716 | if not artifact_path: |
| 717 | return False |
| 718 | |
| 719 | top_level_dir = os.listdir(artifact_path)[0] |
| 720 | src_path = os.path.join(artifact_path, top_level_dir) |
| 721 | dst_path = path(buildtools_dir, arch) |
| 722 | mv(src_path, dst_path) |
| 723 | |
| 724 | # Move all top-level files to /bin and make them executable |
| 725 | bin_path = path(dst_path, 'bin') |
| 726 | top_level_files = filter(lambda e: os.path.isfile(path(dst_path, e)), os.listdir(dst_path)) |
| 727 | for file in top_level_files: |
| 728 | src_file = path(dst_path, file) |
| 729 | dst_file = path(bin_path, file) |
| 730 | mv(src_file, dst_file) |
| 731 | os.chmod(dst_file, 0o755) |
| 732 | |
| 733 | # Remove renderscript |
| 734 | rm(path(dst_path, 'renderscript')) |
| 735 | |
| 736 | return True |
| 737 | |
| 738 | |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 739 | def append(text, more_text): |
| 740 | if text: |
| 741 | return "%s, %s" % (text, more_text) |
| 742 | return more_text |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 743 | |
Alan Viverette | 95f6d36 | 2017-04-06 09:40:50 -0400 | [diff] [blame] | 744 | |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 745 | class buildId(object): |
| 746 | def __init__(self, url_id, fs_id): |
| 747 | # id when used in build server urls |
| 748 | self.url_id = url_id |
| 749 | # id when used in build commands |
| 750 | self.fs_id = fs_id |
| 751 | |
Jeff Gaston | b9b0905 | 2018-02-05 14:16:05 -0500 | [diff] [blame] | 752 | def getBuildId(args): |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 753 | # must be in the format 12345 or P12345 |
Jeff Gaston | b9b0905 | 2018-02-05 14:16:05 -0500 | [diff] [blame] | 754 | source = args.source |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 755 | number_text = source[:] |
| 756 | presubmit = False |
| 757 | if number_text.startswith("P"): |
| 758 | presubmit = True |
| 759 | number_text = number_text[1:] |
| 760 | if not number_text.isnumeric(): |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 761 | return None |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 762 | url_id = source |
| 763 | fs_id = url_id |
| 764 | if presubmit: |
| 765 | fs_id = "0" |
| 766 | args.file = False |
| 767 | return buildId(url_id, fs_id) |
Jeff Gaston | b9b0905 | 2018-02-05 14:16:05 -0500 | [diff] [blame] | 768 | |
Colin Cross | 573e121 | 2018-02-12 14:59:52 -0800 | [diff] [blame] | 769 | def getFile(args): |
| 770 | source = args.source |
| 771 | if not source.isnumeric(): |
| 772 | return args.source |
Alan Viverette | 7e897e2 | 2018-03-09 15:24:10 -0500 | [diff] [blame] | 773 | return None |
Colin Cross | 573e121 | 2018-02-12 14:59:52 -0800 | [diff] [blame] | 774 | |
Alan Viverette | 4ec9a17 | 2018-02-20 16:19:31 -0500 | [diff] [blame] | 775 | |
| 776 | def script_relative(rel_path): |
Jeff Gaston | a68a8d4 | 2018-03-23 14:00:13 -0400 | [diff] [blame] | 777 | return os.path.join(script_dir, rel_path) |
Alan Viverette | 4ec9a17 | 2018-02-20 16:19:31 -0500 | [diff] [blame] | 778 | |
| 779 | |
Jeff Gaston | cc296a8 | 2018-03-23 14:33:24 -0400 | [diff] [blame] | 780 | def uncommittedChangesExist(): |
| 781 | try: |
| 782 | # Make sure we don't overwrite any pending changes. |
| 783 | diffCommand = "cd " + git_dir + " && git diff --quiet" |
| 784 | subprocess.check_call(diffCommand, shell=True) |
| 785 | subprocess.check_call(diffCommand + " --cached", shell=True) |
| 786 | return False |
| 787 | except subprocess.CalledProcessError: |
| 788 | return True |
| 789 | |
| 790 | |
Jeff Gaston | a7fba9b | 2018-03-26 23:48:51 -0400 | [diff] [blame] | 791 | rm(temp_dir) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 792 | parser = argparse.ArgumentParser( |
Alan Viverette | 4583709 | 2017-05-12 14:50:53 -0400 | [diff] [blame] | 793 | description=('Update current prebuilts')) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 794 | parser.add_argument( |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 795 | 'source', |
| 796 | help='Build server build ID or local Maven ZIP file') |
| 797 | parser.add_argument( |
| 798 | '-d', '--design', action="store_true", |
| 799 | help='If specified, updates only the Design Library') |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 800 | parser.add_argument( |
Jeff Gaston | 6e7e750 | 2018-04-04 00:22:45 -0400 | [diff] [blame] | 801 | '-m', '--material', action="store_true", |
| 802 | help='If specified, updates only the intermediate-AndroidX Design Library') |
| 803 | parser.add_argument( |
Alan Viverette | 3e57a4a | 2017-08-11 15:49:47 -0400 | [diff] [blame] | 804 | '-c', '--constraint', action="store_true", |
| 805 | help='If specified, updates only Constraint Layout') |
| 806 | parser.add_argument( |
Jeff Gaston | 9edf86c | 2018-04-18 13:45:23 -0400 | [diff] [blame] | 807 | '--constraint_x', action="store_true", |
| 808 | help='If specified, updates Constraint Layout X') |
| 809 | parser.add_argument( |
Jeff Gaston | 782c3e3 | 2018-02-06 14:36:17 -0500 | [diff] [blame] | 810 | '-j', '--jetifier', action="store_true", |
| 811 | help='If specified, updates only Jetifier') |
| 812 | parser.add_argument( |
Alan Viverette | 5bfe05b | 2017-06-06 14:21:29 -0400 | [diff] [blame] | 813 | '-p', '--platform', action="store_true", |
| 814 | help='If specified, updates only the Android Platform') |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 815 | parser.add_argument( |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 816 | '-f', '--finalize_sdk', type=int, |
| 817 | help='If specified, imports the source build as the specified finalized SDK version') |
| 818 | parser.add_argument( |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 819 | '-b', '--buildtools', action="store_true", |
| 820 | help='If specified, updates only the Build Tools') |
Jeff Gaston | cc296a8 | 2018-03-23 14:33:24 -0400 | [diff] [blame] | 821 | parser.add_argument( |
Jeff Gaston | 41fd5e6 | 2018-04-25 17:02:02 -0400 | [diff] [blame] | 822 | '--stx', action="store_true", |
Jeff Gaston | 08a2ee4 | 2018-05-07 18:08:41 -0400 | [diff] [blame] | 823 | help='If specified, updates Support Library and Androidx (that is, all artifacts built from frameworks/support)') |
Jeff Gaston | 41fd5e6 | 2018-04-25 17:02:02 -0400 | [diff] [blame] | 824 | parser.add_argument( |
Jeff Gaston | cc296a8 | 2018-03-23 14:33:24 -0400 | [diff] [blame] | 825 | '--commit-first', action="store_true", |
| 826 | help='If specified, then if uncommited changes exist, commit before continuing') |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 827 | args = parser.parse_args() |
Jeff Gaston | 41fd5e6 | 2018-04-25 17:02:02 -0400 | [diff] [blame] | 828 | if args.stx: |
Jeff Gaston | 26cdb23 | 2018-07-09 20:21:58 -0400 | [diff] [blame] | 829 | args.androidx = True |
Jeff Gaston | 41fd5e6 | 2018-04-25 17:02:02 -0400 | [diff] [blame] | 830 | else: |
Jeff Gaston | 26cdb23 | 2018-07-09 20:21:58 -0400 | [diff] [blame] | 831 | args.androidx = False |
| 832 | args.support = False |
Jeff Gaston | 56fe276 | 2018-02-06 14:54:37 -0500 | [diff] [blame] | 833 | args.file = True |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 834 | if not args.source: |
| 835 | parser.error("You must specify a build ID or local Maven ZIP file") |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 836 | sys.exit(1) |
Jeff Gaston | 08a2ee4 | 2018-05-07 18:08:41 -0400 | [diff] [blame] | 837 | if not (args.support or args.platform or args.constraint or args.buildtools \ |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 838 | or args.design or args.jetifier or args.androidx or args.material \ |
Jeff Gaston | 9edf86c | 2018-04-18 13:45:23 -0400 | [diff] [blame] | 839 | or args.finalize_sdk or args.constraint_x): |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 840 | parser.error("You must specify at least one target to update") |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 841 | sys.exit(1) |
Jeff Gaston | 08a2ee4 | 2018-05-07 18:08:41 -0400 | [diff] [blame] | 842 | if (args.support or args.constraint or args.constraint_x or args.design or args.material or args.androidx) \ |
Colin Cross | 74683bc | 2018-04-11 17:36:18 -0700 | [diff] [blame] | 843 | and which('pom2bp') is None: |
Louis Pullen-Freilich | 61bb70e | 2019-04-09 16:15:32 +0100 | [diff] [blame] | 844 | 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 Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 845 | sys.exit(1) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 846 | |
Jeff Gaston | cc296a8 | 2018-03-23 14:33:24 -0400 | [diff] [blame] | 847 | if uncommittedChangesExist(): |
| 848 | if args.commit_first: |
| 849 | subprocess.check_call("cd " + git_dir + " && git add -u", shell=True) |
| 850 | subprocess.check_call("cd " + git_dir + " && git commit -m 'save working state'", shell=True) |
| 851 | |
| 852 | if uncommittedChangesExist(): |
Anton Hansson | 10861a0 | 2018-04-06 13:57:08 +0100 | [diff] [blame] | 853 | 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 Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 854 | sys.exit(1) |
| 855 | |
| 856 | try: |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 857 | components = None |
| 858 | if args.constraint: |
Jeff Gaston | db739a2 | 2018-06-26 14:12:22 -0400 | [diff] [blame] | 859 | if update_constraint('studio', getBuildId(args), getFile(args)): |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 860 | components = append(components, 'Constraint Layout') |
| 861 | else: |
Jeff Gaston | 9edf86c | 2018-04-18 13:45:23 -0400 | [diff] [blame] | 862 | print_e('Failed to update Constraint Layout, aborting...') |
| 863 | sys.exit(1) |
| 864 | if args.constraint_x: |
| 865 | if update_constraint_x(getFile(args)): |
| 866 | components = append(components, 'Constraint Layout X') |
| 867 | else: |
| 868 | print_e('Failed to update Constraint Layout X, aborting...') |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 869 | sys.exit(1) |
| 870 | if args.support: |
Jeff Gaston | 17ccf8f | 2018-08-29 11:33:19 -0400 | [diff] [blame] | 871 | if update_support('androidx', getBuildId(args), getFile(args)): |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 872 | components = append(components, 'Support Library') |
| 873 | else: |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 874 | print_e('Failed to update Support Library, aborting...') |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 875 | sys.exit(1) |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 876 | if args.androidx: |
Jeff Gaston | 17ccf8f | 2018-08-29 11:33:19 -0400 | [diff] [blame] | 877 | if update_androidx('androidx', \ |
Jeff Gaston | bbd6bfc | 2018-03-27 17:35:49 -0400 | [diff] [blame] | 878 | getBuildId(args), getFile(args)): |
| 879 | components = append(components, 'AndroidX') |
| 880 | else: |
| 881 | print_e('Failed to update AndroidX, aborting...') |
| 882 | sys.exit(1) |
Jeff Gaston | 782c3e3 | 2018-02-06 14:36:17 -0500 | [diff] [blame] | 883 | if args.jetifier: |
Jeff Gaston | 17ccf8f | 2018-08-29 11:33:19 -0400 | [diff] [blame] | 884 | if update_jetifier('androidx', getBuildId(args)): |
Jeff Gaston | 782c3e3 | 2018-02-06 14:36:17 -0500 | [diff] [blame] | 885 | components = append(components, 'Jetifier') |
| 886 | else: |
| 887 | print_e('Failed to update Jetifier, aborting...') |
| 888 | sys.exit(1) |
Anton Hansson | be15e8c | 2018-04-26 17:35:45 +0100 | [diff] [blame] | 889 | if args.platform or args.finalize_sdk: |
Anton Hansson | 87654c4 | 2018-04-26 15:19:42 +0100 | [diff] [blame] | 890 | if update_framework_current(getBuildId(args)): |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 891 | components = append(components, 'platform SDK') |
| 892 | else: |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 893 | print_e('Failed to update platform SDK, aborting...') |
Alan Viverette | cd3de26 | 2017-08-14 09:51:30 -0400 | [diff] [blame] | 894 | sys.exit(1) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 895 | if args.finalize_sdk: |
Anton Hansson | be15e8c | 2018-04-26 17:35:45 +0100 | [diff] [blame] | 896 | n = args.finalize_sdk |
| 897 | if finalize_sdk(getBuildId(args), n): |
| 898 | # We commit the finalized dir separately from the current sdk update. |
| 899 | msg = "Import final sdk version %d from build %s" % (n, getBuildId(args).url_id) |
| 900 | subprocess.check_call(['git', 'add', '%d' % n]) |
Sundong Ahn | cc34cc3 | 2018-07-11 15:18:47 +0900 | [diff] [blame] | 901 | subprocess.check_call(['git', 'add', 'Android.bp']) |
Anton Hansson | be15e8c | 2018-04-26 17:35:45 +0100 | [diff] [blame] | 902 | subprocess.check_call(['git', 'commit', '-m', msg]) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 903 | else: |
Anton Hansson | be15e8c | 2018-04-26 17:35:45 +0100 | [diff] [blame] | 904 | print_e('Failed to finalize SDK %d, aborting...' % n) |
Anton Hansson | 9709fd4 | 2018-04-03 16:52:13 +0100 | [diff] [blame] | 905 | sys.exit(1) |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 906 | if args.design: |
Colin Cross | 573e121 | 2018-02-12 14:59:52 -0800 | [diff] [blame] | 907 | if update_design(getFile(args)): |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 908 | components = append(components, 'Design Library') |
| 909 | else: |
Jeff Gaston | 6e7e750 | 2018-04-04 00:22:45 -0400 | [diff] [blame] | 910 | print_e('Failed to update Design Library, aborting...') |
| 911 | sys.exit(1) |
| 912 | if args.material: |
| 913 | if update_material(getFile(args)): |
| 914 | components = append(components, 'intermediate-AndroidX Design Library') |
| 915 | else: |
| 916 | print_e('Failed to update intermediate-AndroidX Design Library, aborting...') |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 917 | sys.exit(1) |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 918 | if args.buildtools: |
Jeff Gaston | b9b0905 | 2018-02-05 14:16:05 -0500 | [diff] [blame] | 919 | if update_buildtools('sdk_phone_armv7-sdk_mac', 'darwin', getBuildId(args)) \ |
| 920 | and update_buildtools('sdk_phone_x86_64-sdk', 'linux', getBuildId(args)) \ |
| 921 | and update_buildtools('sdk_phone_armv7-win_sdk', 'windows', getBuildId(args)): |
Alan Viverette | c1c32b6 | 2017-12-20 09:40:36 -0500 | [diff] [blame] | 922 | components = append(components, 'build tools') |
| 923 | else: |
| 924 | print_e('Failed to update build tools, aborting...') |
| 925 | sys.exit(1) |
Jeff Gaston | b70daa9 | 2018-03-29 20:10:22 -0400 | [diff] [blame] | 926 | |
Jeff Gaston | f12f3ce | 2018-03-23 16:41:24 -0400 | [diff] [blame] | 927 | |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 928 | |
Colin Cross | 941d980 | 2018-05-03 21:37:57 -0700 | [diff] [blame] | 929 | subprocess.check_call(['git', 'add', current_path, buildtools_dir]) |
Colin Cross | 573e121 | 2018-02-12 14:59:52 -0800 | [diff] [blame] | 930 | if not args.source.isnumeric(): |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 931 | src_msg = "local Maven ZIP" |
| 932 | else: |
Jeff Gaston | 13e3841 | 2018-02-06 14:45:36 -0500 | [diff] [blame] | 933 | src_msg = "build %s" % (getBuildId(args).url_id) |
Alan Viverette | 129555e | 2018-01-30 09:57:57 -0500 | [diff] [blame] | 934 | msg = "Import %s from %s\n\n%s" % (components, src_msg, flatten(sys.argv)) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 935 | subprocess.check_call(['git', 'commit', '-m', msg]) |
Anton Hansson | be15e8c | 2018-04-26 17:35:45 +0100 | [diff] [blame] | 936 | if args.finalize_sdk: |
| 937 | print('NOTE: Created two commits:') |
| 938 | subprocess.check_call(['git', 'log', '-2', '--oneline']) |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 939 | print('Remember to test this change before uploading it to Gerrit!') |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 940 | |
| 941 | finally: |
| 942 | # Revert all stray files, including the downloaded zip. |
| 943 | try: |
| 944 | with open(os.devnull, 'w') as bitbucket: |
| 945 | subprocess.check_call(['git', 'add', '-Af', '.'], stdout=bitbucket) |
| 946 | subprocess.check_call( |
Jeff Gaston | 9edf86c | 2018-04-18 13:45:23 -0400 | [diff] [blame] | 947 | ['git', 'commit', '-m', 'COMMIT TO REVERT - RESET ME!!!', '--allow-empty'], stdout=bitbucket) |
Alan Viverette | d4527e6 | 2017-05-11 15:03:25 -0400 | [diff] [blame] | 948 | subprocess.check_call(['git', 'reset', '--hard', 'HEAD~1'], stdout=bitbucket) |
| 949 | except subprocess.CalledProcessError: |
Alan Viverette | f5cb0e6 | 2017-11-17 15:15:23 -0500 | [diff] [blame] | 950 | print_e('ERROR: Failed cleaning up, manual cleanup required!!!') |