mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
feat(cli/mobile): allow checking gen folder into source control (#5146)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
@@ -54,7 +54,7 @@ pub fn render<P: AsRef<Path>, D: Serialize>(
|
||||
create_dir_all(&parent)?;
|
||||
created_dirs.push(parent);
|
||||
}
|
||||
File::create(path)
|
||||
File::create(path).map(Some)
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ pub fn render<P: AsRef<Path>, D: Serialize>(
|
||||
pub fn render_with_generator<
|
||||
P: AsRef<Path>,
|
||||
D: Serialize,
|
||||
F: FnMut(&PathBuf) -> std::io::Result<File>,
|
||||
F: FnMut(&PathBuf) -> std::io::Result<Option<File>>,
|
||||
>(
|
||||
handlebars: &Handlebars<'_>,
|
||||
data: &D,
|
||||
@@ -80,13 +80,14 @@ pub fn render_with_generator<
|
||||
file_path.set_extension("toml");
|
||||
}
|
||||
}
|
||||
let mut output_file = out_file_generator(&file_path)?;
|
||||
if let Some(utf8) = file.contents_utf8() {
|
||||
handlebars
|
||||
.render_template_to_write(utf8, &data, &mut output_file)
|
||||
.expect("Failed to render template");
|
||||
} else {
|
||||
output_file.write_all(file.contents())?;
|
||||
if let Some(mut output_file) = out_file_generator(&file_path)? {
|
||||
if let Some(utf8) = file.contents_utf8() {
|
||||
handlebars
|
||||
.render_template_to_write(utf8, &data, &mut output_file)
|
||||
.expect("Failed to render template");
|
||||
} else {
|
||||
output_file.write_all(file.contents())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
for dir in dir.dirs() {
|
||||
|
||||
@@ -641,7 +641,7 @@ pub fn command(_options: Options) -> Result<()> {
|
||||
InfoBlock::new("MSVC", "").display();
|
||||
for i in build_tools {
|
||||
indent(6);
|
||||
println!("{}", format!("{} {}", "-".cyan(), i));
|
||||
println!("{} {}", "-".cyan(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ pub fn gen(
|
||||
}
|
||||
|
||||
let mut options = fs::OpenOptions::new();
|
||||
options.write(true);
|
||||
|
||||
#[cfg(unix)]
|
||||
if path.file_name().unwrap() == OsStr::new("gradlew") {
|
||||
@@ -129,7 +130,11 @@ pub fn gen(
|
||||
options.mode(0o755);
|
||||
}
|
||||
|
||||
options.create_new(true).write(true).open(path)
|
||||
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
|
||||
options.create(true).open(path).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
},
|
||||
)
|
||||
.with_context(|| "failed to process template")?;
|
||||
|
||||
@@ -18,8 +18,8 @@ use cargo_mobile::{
|
||||
use handlebars::Handlebars;
|
||||
use include_dir::{include_dir, Dir};
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
fs::{create_dir_all, File},
|
||||
ffi::{OsStr, OsString},
|
||||
fs::{create_dir_all, OpenOptions},
|
||||
path::{Component, PathBuf},
|
||||
};
|
||||
|
||||
@@ -136,7 +136,14 @@ pub fn gen(
|
||||
created_dirs.push(parent);
|
||||
}
|
||||
|
||||
File::create(path)
|
||||
let mut options = OpenOptions::new();
|
||||
options.write(true);
|
||||
|
||||
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
|
||||
options.create(true).open(path).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
},
|
||||
)
|
||||
.with_context(|| "failed to process template")?;
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
build
|
||||
/buildSrc/src/main/{{package-path}}/kotlin/BuildTask.kt
|
||||
/buildSrc/src/main/{{package-path}}/kotlin/RustPlugin.kt
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
/build
|
||||
/src/main/{{package-path}}/generated
|
||||
|
||||
Reference in New Issue
Block a user