Ver Fonte

fix(docs): target triple detection script, closes #2084 (#2096)

Lucas Fernandes Nogueira há 4 anos atrás
pai
commit
66efb43388

+ 13 - 16
docs/usage/guides/bundler/sidecar.md

@@ -37,30 +37,27 @@ Here's a Node.js script to append the target triple to a binary:
 const execa = require('execa')
 const fs = require('fs')
 
+let extension = ''
+if (process.platform === 'win32') {
+  extension = '.exe'
+}
+
 async function main() {
-  const rustTargetInfo = JSON.parse(
-    (
-      await execa(
-        'rustc',
-        ['-Z', 'unstable-options', '--print', 'target-spec-json'],
-        {
-          env: {
-            RUSTC_BOOTSTRAP: 1
-          }
-        }
-      )
-    ).stdout
-  )
-  const platformPostfix = rustTargetInfo['llvm-target']
+  const rustInfo = (await execa('rustc', ['-vV'])).stdout
+  const targetTriple = /host: (\S+)/g.exec(rustInfo)[1]
+  if (!targetTriple) {
+    console.error('Failed to determine platform target triple')
+  }
   fs.renameSync(
-    'src-tauri/binaries/app',
-    `src-tauri/binaries/app-${platformPostfix}`
+    `src-tauri/binaries/app${extension}`,
+    `src-tauri/binaries/app-${targetTriple}${extension}`
   )
 }
 
 main().catch((e) => {
   throw e
 })
+
 ```
 
 ## Running the sidecar binary on JavaScript

+ 6 - 15
examples/sidecar/scripts/move-binary.js

@@ -12,23 +12,14 @@ if (process.platform === 'win32') {
 }
 
 async function main() {
-  const rustTargetInfo = JSON.parse(
-    (
-      await execa(
-        'rustc',
-        ['-Z', 'unstable-options', '--print', 'target-spec-json'],
-        {
-          env: {
-            RUSTC_BOOTSTRAP: 1
-          }
-        }
-      )
-    ).stdout
-  )
-  const platformPostfix = rustTargetInfo['llvm-target']
+  const rustInfo = (await execa('rustc', ['-vV'])).stdout
+  const targetTriple = /host: (\S+)/g.exec(rustInfo)[1]
+  if (!targetTriple) {
+    console.error('Failed to determine platform target triple')
+  }
   fs.renameSync(
     `src-tauri/binaries/app${extension}`,
-    `src-tauri/binaries/app-${platformPostfix}${extension}`
+    `src-tauri/binaries/app-${targetTriple}${extension}`
   )
 }
 

+ 0 - 1
tooling/bundler/src/bundle/windows/msi/wix.rs

@@ -486,7 +486,6 @@ pub fn build_wix_app_installer(
   data.insert("binaries", binaries_json);
 
   let resources = generate_resource_data(settings)?;
-  println!("{:?}", serde_json::to_string(&resources).unwrap());
   let mut resources_wix_string = String::from("");
   let mut files_ids = Vec::new();
   for (_, dir) in resources {