-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workaround for non reproducible baseline profiles in AGP to libre…
… builds (#1065) Add workaround for non reproducible baseline profiles in AGP
- Loading branch information
1 parent
22689a6
commit e2f358f
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
dependencies { | ||
classpath libs.android.gradle | ||
} | ||
} | ||
|
||
import com.android.tools.profgen.ArtProfileKt | ||
import com.android.tools.profgen.ArtProfileSerializer | ||
import com.android.tools.profgen.DexFile | ||
|
||
/** | ||
* This is a temporary workaround for https://issuetracker.google.com/issues/231837768 | ||
* which will be fixed in AGP 8.1.0, at which point the workaround may be deleted. | ||
*/ | ||
project.afterEvaluate { | ||
tasks.compileLibreReleaseArtProfile.doLast { | ||
outputs.files.each { file -> | ||
if (file.toString().endsWith(".profm")) { | ||
println("Sorting ${file}") | ||
def version = ArtProfileSerializer.valueOf("METADATA_0_0_2") | ||
def profile = ArtProfileKt.ArtProfile(file) | ||
def keys = new ArrayList(profile.profileData.keySet()) | ||
def sortedData = new LinkedHashMap() | ||
Collections.sort keys, new DexFile.Companion() | ||
keys.each { key -> sortedData[key] = profile.profileData[key] } | ||
new FileOutputStream(file).with { | ||
write(version.magicBytes$profgen) | ||
write(version.versionBytes$profgen) | ||
version.write$profgen(it, sortedData, "") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters