android_sdk.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const path = require("path");
  4. const rimraf = require("rimraf");
  5. const config_1 = require("../config");
  6. const utils_1 = require("../utils");
  7. const binary_1 = require("./binary");
  8. function getAndroidArch() {
  9. switch (config_1.Config.osArch()) {
  10. case 'arm':
  11. return 'armeabi-v7a';
  12. case 'arm64':
  13. return 'arm64-v8a';
  14. case 'x86':
  15. case 'x32':
  16. case 'ia32':
  17. case 'ppc':
  18. return 'x86';
  19. case 'x86-64':
  20. case 'x64':
  21. case 'ia64':
  22. case 'ppc64':
  23. return 'x86_64';
  24. default:
  25. return config_1.Config.osArch();
  26. }
  27. }
  28. /**
  29. * The android sdk binary.
  30. */
  31. class AndroidSDK extends binary_1.Binary {
  32. constructor(alternateCDN) {
  33. super(alternateCDN || config_1.Config.cdnUrls().android);
  34. this.name = 'android-sdk';
  35. this.versionCustom = AndroidSDK.versionDefault;
  36. }
  37. id() {
  38. return AndroidSDK.id;
  39. }
  40. prefix() {
  41. return 'android-sdk_r';
  42. }
  43. suffix() {
  44. if (this.ostype === 'Darwin') {
  45. return '-macosx.zip';
  46. }
  47. else if (this.ostype === 'Linux') {
  48. return '-linux.tgz';
  49. }
  50. else if (this.ostype === 'Windows_NT') {
  51. return '-windows.zip';
  52. }
  53. }
  54. getUrl() {
  55. return Promise.resolve({ url: this.cdn + this.filename(), version: this.versionCustom });
  56. }
  57. getVersionList() {
  58. return null;
  59. }
  60. url(ostype) {
  61. return this.cdn + this.filename();
  62. }
  63. zipContentName() {
  64. if (this.ostype === 'Darwin') {
  65. return this.name + '-macosx';
  66. }
  67. else if (this.ostype === 'Linux') {
  68. return this.name + '-linux';
  69. }
  70. else if (this.ostype === 'Windows_NT') {
  71. return this.name + '-windows';
  72. }
  73. }
  74. executableSuffix() {
  75. return '';
  76. }
  77. remove(sdkPath) {
  78. try {
  79. let avds = require(path.resolve(sdkPath, 'available_avds.json'));
  80. let version = path.basename(sdkPath).slice(this.prefix().length);
  81. avds.forEach((avd) => {
  82. utils_1.spawnSync(path.resolve(sdkPath, 'tools', 'android'), ['delete', 'avd', '-n', avd + '-v' + version + '-wd-manager']);
  83. });
  84. }
  85. catch (e) {
  86. }
  87. rimraf.sync(sdkPath);
  88. }
  89. }
  90. AndroidSDK.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
  91. AndroidSDK.id = 'android';
  92. AndroidSDK.versionDefault = config_1.Config.binaryVersions().android;
  93. AndroidSDK.isDefault = false;
  94. AndroidSDK.DEFAULT_API_LEVELS = '24';
  95. AndroidSDK.DEFAULT_ARCHITECTURES = getAndroidArch();
  96. AndroidSDK.DEFAULT_PLATFORMS = 'google_apis';
  97. AndroidSDK.VERSIONS = {
  98. // Before 24 is not supported
  99. 24: '7.0',
  100. 25: '7.1'
  101. };
  102. exports.AndroidSDK = AndroidSDK;
  103. //# sourceMappingURL=android_sdk.js.map