irondash / cargokit

Integrate cargo build with flutter plugins and applications.
Other
51 stars 16 forks source link

Build fails if esp rustup toolchains (rust for ESP32) is installed #42

Closed mattiasgronlund closed 6 months ago

mattiasgronlund commented 6 months ago

Hi, nice work!

I run into a small problem, where cargokit fails if rustup esp toolchain is installed:

$ rustup target list --toolchain esp --installed
error: toolchain 'esp' does not support components: esp is a custom toolchain

The following small hack allows cargokit to ignore the esp toolchain, and all other toolchains which fails to be queried for targets...

--- a/build_tool/lib/src/rustup.dart
+++ b/build_tool/lib/src/rustup.dart
@@ -78,19 +78,24 @@ class Rustup {
   }

   static List<String> _getInstalledTargets(String toolchain) {
-    final res = runCommand("rustup", [
-      'target',
-      'list',
-      '--toolchain',
-      toolchain,
-      '--installed',
-    ]);
-    final lines = res.stdout
-        .toString()
-        .split('\n')
-        .where((e) => e.isNotEmpty)
-        .toList(growable: true);
-    return lines;
+    try {
+      final res = runCommand("rustup", [
+        'target',
+        'list',
+        '--toolchain',
+        toolchain,
+        '--installed',
+      ]);
+      final lines = res.stdout
+          .toString()
+          .split('\n')
+          .where((e) => e.isNotEmpty)
+          .toList(growable: true);
+      return lines;
+    } catch (e) {
+      log.warning("Ignoring toolchain: $toolchain");
+      return [];
+    }
   }

   bool _didInstallRustSrcForNightly = false;
knopp commented 6 months ago

I think we should probably filter out everything that does not start with "nightly", "stable" or "beta". I don't know if there is any way to convince rustup not to list custom toolchains.