Commit 3f45aab1 authored by Georg Koppen's avatar Georg Koppen Committed by Matthew Finkel
Browse files

Modify build system

Bug 40083: Make locale ordering in BuildConfig deterministic

Bug 40042: Add option do overwrite timestamp in extension version

Bug 40059: Use MOZ_BUILD_DATE for versionCode

At the same time we adapt MOZ_BUILD_DATE to our needs where it is
actually used and not in tor-browser-build. This gives us more
flexibility. See: tor-browser-build#40084.

Bug 40067: Fix reproducibility issue in classes2.dex

We make sure our MOZ_BUILD_DATE gets used as a source for showing date
related information on the Fenix about page.

Bug 40071: Show only supported locales

Bug 40064: Use Gecko Beta for Nightly and Debug variants

Bug 40123: Allow building the instrumented tests apks for variants other than debug

This allows to specify the variant of the instrumented tests via
a `testBuildType` gradle argument. It also applies a workaround for
a R8 issue from https://issuetracker.google.com/issues/140851070.
parent 1ebb9fcd
...@@ -17,7 +17,16 @@ import org.gradle.internal.logging.text.StyledTextOutputFactory ...@@ -17,7 +17,16 @@ import org.gradle.internal.logging.text.StyledTextOutputFactory
import static org.gradle.api.tasks.testing.TestResult.ResultType import static org.gradle.api.tasks.testing.TestResult.ResultType
def obtainTestBuildType() {
def result = "debug";
if (project.hasProperty("testBuildType")) {
result = project.getProperties().get("testBuildType")
}
result
}
android { android {
testBuildType obtainTestBuildType()
compileSdkVersion Config.compileSdkVersion compileSdkVersion Config.compileSdkVersion
if (project.hasProperty("testBuildType")) { if (project.hasProperty("testBuildType")) {
...@@ -400,9 +409,9 @@ dependencies { ...@@ -400,9 +409,9 @@ dependencies {
jnaForTest Deps.jna jnaForTest Deps.jna
testImplementation files(configurations.jnaForTest.copyRecursive().files) testImplementation files(configurations.jnaForTest.copyRecursive().files)
debugImplementation Deps.mozilla_browser_engine_gecko_nightly debugImplementation Deps.mozilla_browser_engine_gecko_beta
nightlyImplementation Deps.mozilla_browser_engine_gecko_nightly nightlyImplementation Deps.mozilla_browser_engine_gecko_beta
betaImplementation Deps.mozilla_browser_engine_gecko_beta betaImplementation Deps.mozilla_browser_engine_gecko_beta
releaseImplementation Deps.mozilla_browser_engine_gecko_release releaseImplementation Deps.mozilla_browser_engine_gecko_release
...@@ -648,16 +657,22 @@ task buildTranslationArray { ...@@ -648,16 +657,22 @@ task buildTranslationArray {
// This isn't running as a task, instead the array is build when the gradle file is parsed. // This isn't running as a task, instead the array is build when the gradle file is parsed.
// https://github.com/mozilla-mobile/fenix/issues/14175 // https://github.com/mozilla-mobile/fenix/issues/14175
def foundLocales = new StringBuilder() def foundLocales = new StringBuilder()
def languageCodes = []
foundLocales.append("new String[]{") foundLocales.append("new String[]{")
fileTree("src/main/res").visit { FileVisitDetails details -> fileTree("src/main/res").visit { FileVisitDetails details ->
if(details.file.path.endsWith("${File.separator}strings.xml")){ if(details.file.path.endsWith("${File.separator}torbrowser_strings.xml")){
def languageCode = details.file.parent.tokenize(File.separator).last().replaceAll('values-','').replaceAll('-r','-') def languageCode = details.file.parent.tokenize(File.separator).last().replaceAll('values-','').replaceAll('-r','-')
languageCode = (languageCode == "values") ? "en-US" : languageCode languageCode = (languageCode == "values") ? "en-US" : languageCode
foundLocales.append("\"").append(languageCode).append("\"").append(",") languageCodes.add(languageCode)
} }
} }
// The order of files in a `FileTree` is not stable, even on a single
// computer. Thus we need to sort the `languageCode`s. See: fenix#40083.
languageCodes.sort()
languageCodes.each {
foundLocales.append("\"").append(it).append("\"").append(",")
}
foundLocales.append("}") foundLocales.append("}")
def foundLocalesString = foundLocales.toString().replaceAll(',}','}') def foundLocalesString = foundLocales.toString().replaceAll(',}','}')
android.defaultConfig.buildConfigField "String[]", "SUPPORTED_LOCALE_ARRAY", foundLocalesString android.defaultConfig.buildConfigField "String[]", "SUPPORTED_LOCALE_ARRAY", foundLocalesString
...@@ -740,7 +755,13 @@ ext.updateExtensionVersion = { task, extDir -> ...@@ -740,7 +755,13 @@ ext.updateExtensionVersion = { task, extDir ->
rename { 'manifest.json' } rename { 'manifest.json' }
into extDir into extDir
def values = ['version': AndroidComponents.VERSION + "." + new Date().format('MMddHHmmss')] def systemEnvBuildDate = System.getenv('MOZ_BUILD_DATE')
// MOZ_BUILD_DATE is in the yyyyMMddHHmmss format. Thus, we only use a
// substring of it if it is available.
def values = ['version': AndroidComponents.VERSION + "." +
(systemEnvBuildDate != null ?
systemEnvBuildDate.substring(4) :
new Date().format('MMddHHmmss'))]
inputs.properties(values) inputs.properties(values)
expand(values) expand(values)
} }
......
...@@ -121,3 +121,6 @@ ...@@ -121,3 +121,6 @@
# Keep Android Lifecycle methods # Keep Android Lifecycle methods
# https://bugzilla.mozilla.org/show_bug.cgi?id=1596302 # https://bugzilla.mozilla.org/show_bug.cgi?id=1596302
-keep class androidx.lifecycle.** { *; } -keep class androidx.lifecycle.** { *; }
# Workaround for 'already has mapping' r8 issue (https://issuetracker.google.com/issues/140851070)
-keep class com.google.android.gms.common.internal.BaseGmsClient { *; }
...@@ -38,7 +38,14 @@ object Config { ...@@ -38,7 +38,14 @@ object Config {
@JvmStatic @JvmStatic
fun generateBuildDate(): String { fun generateBuildDate(): String {
val dateTime = LocalDateTime.now() val dateTime = if (System.getenv("MOZ_BUILD_DATE") != null) {
// Converting our MOZ_BUILD_DATE to LocalDateTime
val format = SimpleDateFormat("yyyyMMddHHmmss", Locale.US)
val date = format.parse(System.getenv("MOZ_BUILD_DATE"))
java.sql.Timestamp(date.getTime()).toLocalDateTime()
} else {
LocalDateTime.now()
}
val timeFormatter = DateTimeFormatter.ofPattern("h:mm a") val timeFormatter = DateTimeFormatter.ofPattern("h:mm a")
return "${dateTime.dayOfWeek.toString().toLowerCase().capitalize()} ${dateTime.monthValue}/${dateTime.dayOfMonth} @ ${timeFormatter.format(dateTime)}" return "${dateTime.dayOfWeek.toString().toLowerCase().capitalize()} ${dateTime.monthValue}/${dateTime.dayOfMonth} @ ${timeFormatter.format(dateTime)}"
...@@ -47,7 +54,7 @@ object Config { ...@@ -47,7 +54,7 @@ object Config {
private val fennecBaseVersionCode by lazy { private val fennecBaseVersionCode by lazy {
val format = SimpleDateFormat("yyyyMMddHHmmss", Locale.US) val format = SimpleDateFormat("yyyyMMddHHmmss", Locale.US)
val cutoff = format.parse("20141228000000") val cutoff = format.parse("20141228000000")
val build = Date() val build = if (System.getenv("MOZ_BUILD_DATE") != null) format.parse(System.getenv("MOZ_BUILD_DATE")) else Date()
Math.floor((build.time - cutoff.time) / (1000.0 * 60.0 * 60.0)).toInt() Math.floor((build.time - cutoff.time) / (1000.0 * 60.0 * 60.0)).toInt()
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment