File size: 1,960 Bytes
a4ff84b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | // Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '../base/common.dart';
import '../build_info.dart';
const String kGooglePlayVersioning = 'https://developer.android.com/studio/publish/versioning.html';
const String kSupportedAbis = 'https://flutter.dev/docs/deployment/android#what-are-the-supported-target-architectures';
/// Validates that the build mode and build number are valid for a given build.
void validateBuild(AndroidBuildInfo androidBuildInfo) {
final BuildInfo buildInfo = androidBuildInfo.buildInfo;
if (buildInfo.codeSizeDirectory != null && androidBuildInfo.targetArchs.length > 1) {
throwToolExit(
'Cannot perform code size analysis when building for multiple ABIs. '
'Specify one of android-arm, android-arm64, or android-x64 in the '
'--target-platform flag.'
);
}
if (buildInfo.mode.isPrecompiled && androidBuildInfo.targetArchs.contains(AndroidArch.x86)) {
throwToolExit(
'Cannot build ${androidBuildInfo.buildInfo.mode.cliName} mode for x86 ABI.\n'
'For more information see $kSupportedAbis .'
);
}
if (buildInfo.buildNumber != null) {
final int? result = int.tryParse(buildInfo.buildNumber!);
if (result == null) {
throwToolExit(
'buildNumber: ${buildInfo.buildNumber} was not a valid integer value.\n'
'For more information see $kGooglePlayVersioning .'
);
}
if (result < 0) {
throwToolExit(
'buildNumber: ${buildInfo.buildNumber} must be a positive integer value.\n'
'For more information see $kGooglePlayVersioning .'
);
}
if (result > 2100000000) {
throwToolExit(
'buildNumber: ${buildInfo.buildNumber} is greater than the maximum '
'allowed value of 2100000000.\n'
'For more information see $kGooglePlayVersioning .'
);
}
}
}
|