Repository navigation
fix: #7614 - rebuild every time on macos because of Info.plist changes - #9878
Merged
lucasfernog merged 7 commits intoJun 26, 2024
Merged
Conversation
lucasfernog
requested changes
May 25, 2024
lucasfernog
left a comment
Member
There was a problem hiding this comment.
nice catch, can you clean this up so it only serializes the plist once?
diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs
index 59e9a78ef..ace1e345a 100644
--- a/core/tauri-codegen/src/context.rs
+++ b/core/tauri-codegen/src/context.rs
@@ -4,6 +4,7 @@
use std::collections::BTreeMap;
use std::convert::identity;
+use std::io::BufWriter;
use std::path::{Path, PathBuf};
use std::{ffi::OsStr, str::FromStr};
@@ -328,18 +329,20 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
plist.insert("CFBundleVersion".into(), version.clone().into());
}
}
-
+
let plist_file = out_dir.join("Info.plist");
- let old = if plist_file.exists() {
- plist::Value::from_file(&plist_file).expect("failed to read old Info.plist")
- } else {
- plist::Value::Dictionary(Default::default())
- };
- let old = serde_json::to_string(&old).unwrap();
- let n = serde_json::to_string(&info_plist).unwrap();
- if old.ne(&n) {
- info_plist.to_file_xml(plist_file).expect("failed to write Info.plist");
+
+ let mut plist_contents = BufWriter::new(Vec::new());
+ info_plist
+ .to_writer_xml(&mut plist_contents)
+ .expect("failed to serialize plist");
+ let plist_contents =
+ String::from_utf8_lossy(&plist_contents.into_inner().unwrap()).into_owned();
+
+ if plist_contents != std::fs::read_to_string(&plist_file).unwrap_or_default() {
+ std::fs::write(&plist_file, &plist_contents).expect("failed to write Info.plist");
}
+
quote!({
tauri::embed_plist::embed_info_plist!(concat!(std::env!("OUT_DIR"), "/Info.plist"));
})
lucasfernog
requested changes
May 28, 2024
lucasfernog
left a comment
Member
There was a problem hiding this comment.
must fix clippy and also add a change file in the .changes folder:
.changes/fix-build-script-rerun-macos.md
---
"tauri-codegen": patch:bug
---
Fixes Info.plist rewriting always triggering build to rerun.
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
lucasfernog
approved these changes
Jun 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to macos documentation
Current logic of the build prepare Info.plist with added timestamp at the end, this cause rebuild each restart even if not needed. Because
You can include more integers but the system ignores themit does not make any sense to add timestampI also have to check Info.plist content from previous build with new build. If no changes just skip the write
This should solve #7614