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