Browse Source

fix: use $CARGO_MANIFEST_DIR to fully specify include_dir paths in tauri-cli (#9310)

* Allow tauri-cli to work with Bazel.

Signed-off-by: Scott Pledger <scottpledger2005@gmail.com>

* change file

---------

Signed-off-by: Scott Pledger <scottpledger2005@gmail.com>
scottpledger 1 year ago
parent
commit
6703b7cbca

+ 5 - 0
.changes/cli-include-dir-cargo-manifest-dir.md

@@ -0,0 +1,5 @@
+---
+"tauri-cli": patch:enhance
+---
+
+Use `$CARGO_MANIFEST_DIR` when including templates at build-time.

+ 1 - 1
tooling/cli/src/init.rs

@@ -22,7 +22,7 @@ use clap::Parser;
 use handlebars::{to_json, Handlebars};
 use handlebars::{to_json, Handlebars};
 use include_dir::{include_dir, Dir};
 use include_dir::{include_dir, Dir};
 
 
-const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/app");
+const TEMPLATE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/templates/app");
 const TAURI_CONF_TEMPLATE: &str = include_str!("../templates/tauri.conf.json");
 const TAURI_CONF_TEMPLATE: &str = include_str!("../templates/tauri.conf.json");
 
 
 #[derive(Debug, Parser)]
 #[derive(Debug, Parser)]

+ 1 - 1
tooling/cli/src/mobile/android/project.rs

@@ -27,7 +27,7 @@ use std::{
   path::{Path, PathBuf},
   path::{Path, PathBuf},
 };
 };
 
 
-const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/mobile/android");
+const TEMPLATE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/templates/mobile/android");
 
 
 pub fn gen(
 pub fn gen(
   config: &Config,
   config: &Config,

+ 1 - 1
tooling/cli/src/mobile/ios/project.rs

@@ -22,7 +22,7 @@ use std::{
   path::{Component, PathBuf},
   path::{Component, PathBuf},
 };
 };
 
 
-const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/mobile/ios");
+const TEMPLATE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/templates/mobile/ios");
 
 
 // unprefixed app_root seems pretty dangerous!!
 // unprefixed app_root seems pretty dangerous!!
 // TODO: figure out what cargo-mobile meant by that
 // TODO: figure out what cargo-mobile meant by that

+ 1 - 1
tooling/cli/src/plugin/init.rs

@@ -20,7 +20,7 @@ use std::{
   path::{Component, Path, PathBuf},
   path::{Component, Path, PathBuf},
 };
 };
 
 
-pub const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/plugin");
+pub const TEMPLATE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/templates/plugin");
 
 
 #[derive(Debug, Parser)]
 #[derive(Debug, Parser)]
 #[clap(about = "Initialize a Tauri plugin project on an existing directory")]
 #[clap(about = "Initialize a Tauri plugin project on an existing directory")]