@@ -104,6 +104,7 @@ def _process_art_profile(
104104 ctx ,
105105 final_classes_dex ,
106106 merged_profile ,
107+ output_primary_profile ,
107108 proguard_output_map = None ,
108109 profgen = None ,
109110 toolchain_type = None ):
@@ -124,27 +125,17 @@ def _process_art_profile(
124125 ArtProfileInfo containing the generated profile, the metadata, and the combined zip file.
125126 """
126127
127- # Profgen
128128 output_profile = _get_profile_artifact (ctx , "baseline.prof" )
129129 output_profile_meta = _get_profile_artifact (ctx , "baseline.profm" )
130- profgen_inputs = [final_classes_dex , merged_profile ]
131- profgen_args = ctx .actions .args ()
132- profgen_args .add ("bin" , merged_profile )
133- profgen_args .add ("--apk" , final_classes_dex )
134- profgen_args .add ("--output" , output_profile )
135- profgen_args .add ("--output-meta" , output_profile_meta )
136- if proguard_output_map :
137- profgen_args .add ("--map" , proguard_output_map )
138- profgen_inputs .append (proguard_output_map )
139- ctx .actions .run (
140- mnemonic = "GenerateARTProfile" ,
141- executable = profgen ,
142- progress_message = "Generating Android P-R ART profile for %{label} APK" ,
143- arguments = [profgen_args ],
144- inputs = profgen_inputs ,
145- outputs = [output_profile , output_profile_meta ],
146- use_default_shell_env = True ,
147- toolchain = toolchain_type ,
130+ _generate_profile (
131+ ctx ,
132+ output_profile ,
133+ output_profile_meta ,
134+ final_classes_dex ,
135+ merged_profile ,
136+ proguard_output_map ,
137+ profgen ,
138+ toolchain_type ,
148139 )
149140
150141 # Zip ART profiles
@@ -161,10 +152,21 @@ def _process_art_profile(
161152 resources = [output_profile , output_profile_meta ],
162153 java_toolchain = _common .get_java_toolchain (ctx ),
163154 )
155+
156+ _dump_profile (
157+ ctx ,
158+ output_primary_profile ,
159+ output_profile ,
160+ final_classes_dex ,
161+ profgen ,
162+ toolchain_type ,
163+ )
164+
164165 return ArtProfileInfo (
165166 art_profile_zip = output_profile_zip ,
166167 baseline_profile = output_profile ,
167168 baseline_profile_metadata = output_profile_meta ,
169+ primary_profile = output_primary_profile ,
168170 )
169171
170172def _get_profile_dir (ctx ):
@@ -216,6 +218,60 @@ def _expand_wildcards(
216218 toolchain = toolchain_type ,
217219 )
218220
221+ def _generate_profile (
222+ ctx ,
223+ output_profile ,
224+ output_profile_meta ,
225+ final_classes_dex ,
226+ merged_profile ,
227+ proguard_output_map = None ,
228+ profgen = None ,
229+ toolchain_type = None ):
230+ profgen_inputs = [final_classes_dex , merged_profile ]
231+ args = ctx .actions .args ()
232+ args .add ("bin" , merged_profile )
233+ args .add ("--apk" , final_classes_dex )
234+ args .add ("--output" , output_profile )
235+ args .add ("--output-meta" , output_profile_meta )
236+ if proguard_output_map :
237+ args .add ("--map" , proguard_output_map )
238+ profgen_inputs .append (proguard_output_map )
239+
240+ ctx .actions .run (
241+ mnemonic = "GenerateARTProfile" ,
242+ executable = profgen ,
243+ progress_message = "Generating Android P-R ART profile for %{label} APK" ,
244+ arguments = [args ],
245+ inputs = profgen_inputs ,
246+ outputs = [output_profile , output_profile_meta ],
247+ use_default_shell_env = True ,
248+ toolchain = toolchain_type ,
249+ )
250+
251+ def _dump_profile (
252+ ctx ,
253+ output ,
254+ binary_profile ,
255+ final_classes_dex ,
256+ profgen = None ,
257+ toolchain_type = None ):
258+ args = ctx .actions .args ()
259+ args .add ("dumpProfile" )
260+ args .add ("--profile" , binary_profile )
261+ args .add ("--apk" , final_classes_dex )
262+ args .add ("--output" , output )
263+
264+ ctx .actions .run (
265+ mnemonic = "DumpProfile" ,
266+ executable = profgen ,
267+ progress_message = "Dumping Obfuscated-HRP profile for %{label} APK" ,
268+ arguments = [args ],
269+ inputs = [binary_profile , final_classes_dex ],
270+ outputs = [output ],
271+ use_default_shell_env = True ,
272+ toolchain = toolchain_type ,
273+ )
274+
219275baseline_profiles = struct (
220276 expand_wildcards = _expand_wildcards ,
221277 get_profile_artifact = _get_profile_artifact ,
0 commit comments