| 1 | import 'dart:io'; |
| 2 | |
| 3 | import './print_verbose_dummy.dart'; |
| 4 | import 'package:dio/dio.dart'; |
| 5 | import 'package:archive/archive_io.dart'; |
| 6 | |
| 7 | final _dio = Dio(); |
| 8 | |
| 9 | final List<String> triplets = [ |
| 10 | "x86_64-linux-gnu", // linux desktop - majority of users onlinux |
| 11 | // "i686-linux-gnu", // not supported by cake |
| 12 | // "i686-meego-linux-gnu", // sailfishos (emulator)- not supported by cake |
| 13 | // "aarch64-linux-gnu", // not (yet) supported by cake - (mostly) mobile linux |
| 14 | // "aarch64-meego-linux-gnu", // sailfishos - not supported by cake |
| 15 | "x86_64-linux-android", |
| 16 | // "i686-linux-android", // not supported by monero_c - mostly old android emulators |
| 17 | "aarch64-linux-android", |
| 18 | "armv7a-linux-androideabi", |
| 19 | // "i686-w64-mingw32", // 32bit windows - not supported by monero_c |
| 20 | "x86_64-w64-mingw32", |
| 21 | // "x86_64-apple-darwin11", // Intel macbooks (contrib) - not used by cake |
| 22 | // "aarch64-apple-darwin11", // apple silicon macbooks (contrib) - not used by cake |
| 23 | // "x86_64-host-apple-darwin", // not available on CI (yet) |
| 24 | "aarch64-apple-darwin", // apple silicon macbooks |
| 25 | "x86_64-apple-darwin", // intel macbooks |
| 26 | "aarch64-apple-ios", |
| 27 | "aarch64-apple-ios-simulator", |
| 28 | ]; |
| 29 | |
| 30 | Future<void> main() async { |
| 31 | final resp = await _dio.get("https://api.github.com/repos/mrcyjanek/monero_c/releases"); |
| 32 | final data = resp.data[0]; |
| 33 | final tagName = data['tag_name']; |
| 34 | print("Downloading artifacts for: ${tagName}"); |
| 35 | final assets = data['assets'] as List<dynamic>; |
| 36 | for (var i = 0; i < assets.length; i++) { |
| 37 | for (var triplet in triplets) { |
| 38 | final asset = assets[i]; |
| 39 | final filename = asset["name"] as String; |
| 40 | if (!filename.contains(triplet)) continue; |
| 41 | final coin = filename.split("_")[0]; |
| 42 | String localFilename = filename.replaceAll("${coin}_${triplet}_", ""); |
| 43 | localFilename = "scripts/monero_c/release/${coin}/${triplet}_${localFilename}"; |
| 44 | final url = asset["browser_download_url"] as String; |
| 45 | print("- downloading $localFilename"); |
| 46 | await _dio.download(url, localFilename); |
| 47 | if (localFilename.endsWith(".xz")) { |
| 48 | print(" extracting $localFilename"); |
| 49 | final inputStream = InputFileStream(localFilename); |
| 50 | final archive = XZDecoder().decodeBytes(inputStream.toUint8List()); |
| 51 | final outputStream = OutputFileStream(localFilename.replaceAll(".xz", "")); |
| 52 | outputStream.writeBytes(archive); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | if (Platform.isMacOS) { |
| 57 | print("Generating ios framework"); |
| 58 | final result = |
| 59 | Process.runSync("bash", ["-c", "cd scripts/ios && ./gen_framework.sh && cd ../.."]); |
| 60 | print((result.stdout + result.stderr).toString().trim()); |
| 61 | } |
| 62 | } |