20
20
SOONG_DIR = os .path .join (AOSP_DIR , 'out' , 'soong' , '.intermediates' )
21
21
22
22
23
+ class GetRefDumpDirStem :
24
+ def __init__ (self , ref_dump_dir , chosen_vndk_version ,
25
+ chosen_platform_version , binder_bitness ):
26
+ self .ref_dump_dir = ref_dump_dir
27
+ self .chosen_vndk_version = chosen_vndk_version
28
+ self .chosen_platform_version = chosen_platform_version
29
+ self .binder_bitness = binder_bitness
30
+
31
+ def __call__ (self , category , arch ):
32
+ version_stem = (self .chosen_vndk_version
33
+ if category == 'vndk'
34
+ else self .chosen_platform_version )
35
+ return os .path .join (self .ref_dump_dir , category , version_stem ,
36
+ self .binder_bitness , arch )
37
+
38
+
23
39
def choose_vndk_version (version , platform_vndk_version , board_vndk_version ):
24
40
if version is None :
25
41
# This logic must be in sync with the logic for reference ABI dumps
@@ -38,12 +54,6 @@ def make_libs_for_product(libs, product, variant, vndk_version, targets):
38
54
make_tree (product , variant )
39
55
40
56
41
- def get_ref_dump_dir_stem (ref_dump_dir , category , chosen_vndk_version ,
42
- binder_bitness , arch ):
43
- return os .path .join (ref_dump_dir , category , chosen_vndk_version ,
44
- binder_bitness , arch )
45
-
46
-
47
57
def find_and_remove_path (root_path , file_name = None ):
48
58
if file_name is not None :
49
59
root_path = os .path .join (root_path , 'source-based' , file_name )
@@ -56,13 +66,11 @@ def find_and_remove_path(root_path, file_name=None):
56
66
shutil .rmtree (root_path )
57
67
58
68
59
- def remove_references_for_all_arches (ref_dump_dir , chosen_vndk_version ,
60
- binder_bitness , targets , libs ):
69
+ def remove_references_for_all_arches (get_ref_dump_dir_stem , targets , libs ):
61
70
for target in targets :
62
71
for category in ('ndk' , 'platform' , 'vndk' ):
63
- dir_to_remove = get_ref_dump_dir_stem (
64
- ref_dump_dir , category , chosen_vndk_version , binder_bitness ,
65
- target .get_arch_str ())
72
+ dir_to_remove = get_ref_dump_dir_stem (category ,
73
+ target .get_arch_str ())
66
74
if libs :
67
75
for lib in libs :
68
76
find_and_remove_path (dir_to_remove ,
@@ -76,40 +84,38 @@ def remove_references_for_all_arches(ref_dump_dir, chosen_vndk_version,
76
84
def tag_to_dir_name (tag ):
77
85
if tag == 'NDK' :
78
86
return 'ndk'
79
- if tag == 'PLATFORM' :
87
+ if tag in ( 'PLATFORM' , 'LLNDK' ) :
80
88
return 'platform'
81
- if tag .startswith ('VNDK' ) or tag == 'LLNDK' :
89
+ if tag .startswith ('VNDK' ):
82
90
return 'vndk'
83
91
raise ValueError (tag + 'is not a known tag.' )
84
92
85
93
86
- def find_and_copy_lib_lsdumps (ref_dump_dir , chosen_vndk_version ,
87
- binder_bitness , target , libs , lsdump_paths ,
88
- compress ):
94
+ def find_and_copy_lib_lsdumps (get_ref_dump_dir_stem , target , libs ,
95
+ lsdump_paths , compress ):
89
96
arch_lsdump_paths = find_lib_lsdumps (lsdump_paths , libs , target )
90
97
91
98
num_created = 0
92
99
for tag , path in arch_lsdump_paths :
93
- ref_dump_dir_stem = get_ref_dump_dir_stem (
94
- ref_dump_dir , tag_to_dir_name (tag ), chosen_vndk_version ,
95
- binder_bitness , target .get_arch_str ())
100
+ ref_dump_dir_stem = get_ref_dump_dir_stem (tag_to_dir_name (tag ),
101
+ target .get_arch_str ())
96
102
copy_reference_dump (
97
103
path , os .path .join (ref_dump_dir_stem , 'source-based' ), compress )
98
104
num_created += 1
99
105
return num_created
100
106
101
107
102
- def create_source_abi_reference_dumps (args , chosen_vndk_version ,
103
- binder_bitness , lsdump_paths , targets ):
108
+ def create_source_abi_reference_dumps (args , get_ref_dump_dir_stem ,
109
+ lsdump_paths , targets ):
104
110
num_libs_copied = 0
105
111
for target in targets :
106
112
assert target .primary_arch != ''
107
113
print (f'Creating dumps for arch: { target .arch } , '
108
114
f'primary arch: { target .primary_arch } ' )
109
115
110
116
num_libs_copied += find_and_copy_lib_lsdumps (
111
- args . ref_dump_dir , chosen_vndk_version , binder_bitness , target ,
112
- args .libs , lsdump_paths , args . compress )
117
+ get_ref_dump_dir_stem , target , args . libs , lsdump_paths ,
118
+ args .compress )
113
119
return num_libs_copied
114
120
115
121
@@ -120,27 +126,39 @@ def create_source_abi_reference_dumps_for_all_products(args):
120
126
121
127
for product in args .products :
122
128
build_vars = get_build_vars_for_product (
123
- ['PLATFORM_VNDK_VERSION' , 'BOARD_VNDK_VERSION' , 'BINDER32BIT' ],
129
+ ['PLATFORM_VNDK_VERSION' , 'BOARD_VNDK_VERSION' , 'BINDER32BIT' ,
130
+ 'PLATFORM_VERSION_CODENAME' , 'PLATFORM_SDK_VERSION' ],
124
131
product , args .build_variant )
125
132
126
133
platform_vndk_version = build_vars [0 ]
127
134
board_vndk_version = build_vars [1 ]
135
+ platform_version_codename = build_vars [3 ]
136
+ platform_sdk_version = build_vars [4 ]
128
137
if build_vars [2 ] == 'true' :
129
138
binder_bitness = '32'
130
139
else :
131
140
binder_bitness = '64'
132
141
133
142
chosen_vndk_version = choose_vndk_version (
134
143
args .version , platform_vndk_version , board_vndk_version )
144
+ # chosen_vndk_version is expected to be the finalized
145
+ # PLATFORM_SDK_VERSION if the codename is REL.
146
+ chosen_platform_version = (platform_sdk_version
147
+ if platform_version_codename == 'REL'
148
+ else 'current' )
149
+
150
+ get_ref_dump_dir_stem = GetRefDumpDirStem (args .ref_dump_dir ,
151
+ chosen_vndk_version ,
152
+ chosen_platform_version ,
153
+ binder_bitness )
135
154
136
155
targets = [t for t in (Target (True , product ), Target (False , product ))
137
156
if t .arch ]
138
157
# Remove reference ABI dumps specified in `args.libs` (or remove all of
139
158
# them if none of them are specified) so that we may build these
140
159
# libraries successfully.
141
- remove_references_for_all_arches (
142
- args .ref_dump_dir , chosen_vndk_version , binder_bitness , targets ,
143
- args .libs )
160
+ remove_references_for_all_arches (get_ref_dump_dir_stem , targets ,
161
+ args .libs )
144
162
145
163
if not args .no_make_lib :
146
164
# Build all the specified libs, or build `findlsdumps` if no libs
@@ -153,7 +171,7 @@ def create_source_abi_reference_dumps_for_all_products(args):
153
171
build = False )
154
172
155
173
num_processed += create_source_abi_reference_dumps (
156
- args , chosen_vndk_version , binder_bitness , lsdump_paths , targets )
174
+ args , get_ref_dump_dir_stem , lsdump_paths , targets )
157
175
158
176
return num_processed
159
177
0 commit comments