Skip to content

Commit

Permalink
Add arch variable for artifact name template
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitsangwan01 committed Jul 7, 2024
1 parent f68dfc9 commit 4d9ecaa
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions packages/flutter_app_packager/lib/src/api/make_config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:ffi';
import 'dart:io';

import 'package:flutter_app_packager/src/api/make_error.dart';
Expand Down Expand Up @@ -29,6 +30,7 @@ class MakeConfig {
Version get appVersion => pubspec.version!;
String get appBuildName => appVersion.toString().split('+').first;
String get appBuildNumber => appVersion.toString().split('+').last;
String? get arch => Abi.current().architecture?.name;

Pubspec? _pubspec;
Directory? _packagingDirectory;
Expand Down Expand Up @@ -69,6 +71,7 @@ class MakeConfig {
'platform': platform,
'flavor': flavor,
'channel': channel,
'arch': arch,
'ext': packageFormat.isEmpty ? null : packageFormat,
};

Expand Down Expand Up @@ -187,3 +190,65 @@ class MakeLinuxPackageConfig extends MakeConfig {
return _appBinaryName!;
}
}

extension _AbiArch on Abi {
_Architecture? get architecture {
switch (this) {
case Abi.androidArm:
return _Architecture.arm;
case Abi.androidArm64:
return _Architecture.arm64;
case Abi.androidIA32:
return _Architecture.ia32;
case Abi.androidX64:
return _Architecture.x64;
case Abi.androidRiscv64:
return _Architecture.riscv64;
case Abi.fuchsiaArm64:
return _Architecture.arm64;
case Abi.fuchsiaX64:
return _Architecture.x64;
case Abi.fuchsiaRiscv64:
return _Architecture.riscv64;
case Abi.iosArm:
return _Architecture.arm;
case Abi.iosArm64:
return _Architecture.arm64;
case Abi.iosX64:
return _Architecture.x64;
case Abi.linuxArm:
return _Architecture.arm;
case Abi.linuxArm64:
return _Architecture.arm64;
case Abi.linuxIA32:
return _Architecture.ia32;
case Abi.linuxX64:
return _Architecture.x64;
case Abi.linuxRiscv32:
return _Architecture.riscv32;
case Abi.linuxRiscv64:
return _Architecture.riscv64;
case Abi.macosArm64:
return _Architecture.arm64;
case Abi.macosX64:
return _Architecture.x64;
case Abi.windowsArm64:
return _Architecture.arm64;
case Abi.windowsIA32:
return _Architecture.ia32;
case Abi.windowsX64:
return _Architecture.x64;
default:
return null;
}
}
}

enum _Architecture {
arm,
arm64,
ia32,
x64,
riscv32,
riscv64,
}

0 comments on commit 4d9ecaa

Please sign in to comment.