getBinaryPlatform function

String getBinaryPlatform()

Get prisma binary engine platform.

Implementation

String getBinaryPlatform() {
  final String dartSdkVersion = Platform.version.toLowerCase();

  if (Platform.isWindows) {
    return 'windows';
  } else if (Platform.isMacOS) {
    return dartSdkVersion.contains('arm') ? 'darwin-arm64' : 'darwin';
  } else if (!Platform.isLinux) {
    throw UnsupportedError('Unsupported operating system');
  }

  final LinuxOperatingSystemDistro distro = LinuxOperatingSystemDistro.current;

  // NixOS
  if (distro == LinuxOperatingSystemDistro.nixos) {
    return 'linux-nixos';
  }

  final String opensslVersion = getOpenSSLVersion();

  // ARM architecture
  if (dartSdkVersion.contains('arm')) {
    return 'linux-arm${dartSdkVersion.contains('arm64') ? '64' : ''}-openssl-$opensslVersion';
  }

  // Debian
  if (distro == LinuxOperatingSystemDistro.debian) {
    return 'debian-openssl-$opensslVersion';
  }

  // RHEL(Red Hat Enterprise Linux)
  if (distro == LinuxOperatingSystemDistro.rhel) {
    return 'rhel-openssl-$opensslVersion';
  }

  // Musl
  if (distro == LinuxOperatingSystemDistro.musl) {
    final String musl = 'linux-musl';
    if (opensslVersion == '3.0.x') {
      return '$musl-openssl-$opensslVersion';
    }
  }

  // Raspbian
  if (distro == LinuxOperatingSystemDistro.arm) {
    return 'arm';
  }

  throw UnsupportedError('Unsupported operating system');
}