-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
137 lines (120 loc) · 3.98 KB
/
build.rs
File metadata and controls
137 lines (120 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
use std::path::Path;
const COMMANDS: &[&str] = &[
"check_for_updates",
"check_for_updates_in_background",
"can_check_for_updates",
"current_version",
"feed_url",
"set_feed_url",
"automatically_checks_for_updates",
"set_automatically_checks_for_updates",
"automatically_downloads_updates",
"set_automatically_downloads_updates",
"last_update_check_date",
"reset_update_cycle",
"update_check_interval",
"set_update_check_interval",
"check_for_update_information",
"session_in_progress",
"http_headers",
"set_http_headers",
"user_agent_string",
"set_user_agent_string",
"sends_system_profile",
"set_sends_system_profile",
"clear_feed_url_from_user_defaults",
"reset_update_cycle_after_short_delay",
"allowed_channels",
"set_allowed_channels",
"feed_url_override",
"set_feed_url_override",
"feed_parameters",
"set_feed_parameters",
"should_download_release_notes",
"set_should_download_release_notes",
"should_relaunch_application",
"set_should_relaunch_application",
"may_check_for_updates_config",
"set_may_check_for_updates_config",
"should_proceed_with_update",
"set_should_proceed_with_update",
"decryption_password",
"set_decryption_password",
"last_found_update",
];
fn main() {
tauri_plugin::Builder::new(COMMANDS)
.android_path("android")
.ios_path("ios")
.build();
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
if target_os == "macos" && !is_publish_verify() {
setup_sparkle_framework();
}
}
fn is_publish_verify() -> bool {
if std::env::var("DOCS_RS").is_ok() {
return true;
}
if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
if manifest_dir.contains("target/package/") {
return true;
}
}
false
}
fn find_src_tauri_from_out_dir() -> Option<String> {
let out_dir = std::env::var("OUT_DIR").ok()?;
let out_path = Path::new(&out_dir);
for ancestor in out_path.ancestors() {
if ancestor.join("tauri.conf.json").exists() {
return Some(ancestor.to_string_lossy().to_string());
}
}
None
}
fn setup_sparkle_framework() {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let mut search_paths: Vec<String> = Vec::new();
if let Ok(path) = std::env::var("SPARKLE_FRAMEWORK_PATH") {
search_paths.push(path);
}
if let Some(src_tauri) = find_src_tauri_from_out_dir() {
search_paths.push(src_tauri);
}
search_paths.push(manifest_dir.clone());
let mut framework_dir = None;
for search_path in &search_paths {
if search_path.is_empty() {
continue;
}
let path = Path::new(search_path);
let framework_path = path.join("Sparkle.framework");
if framework_path.exists() {
println!(
"cargo:warning=Found Sparkle.framework at: {}",
framework_path.display()
);
framework_dir = Some(search_path.clone());
break;
}
}
let framework_dir = framework_dir.unwrap_or_else(|| {
eprintln!("Searched paths: {:?}", search_paths);
panic!(
"\n\
Sparkle.framework not found!\n\
\n\
Please download Sparkle framework by running:\n\
\n\
curl -fsSL https://raw.githubusercontent.com/ahonn/tauri-plugin-sparkle-updater/refs/heads/master/scripts/download-sparkle.sh | bash\n\
\n\
Or set the SPARKLE_FRAMEWORK_PATH environment variable to the directory containing Sparkle.framework.\n"
)
});
println!("cargo:rustc-link-search=framework={}", framework_dir);
println!("cargo:rustc-link-lib=framework=Sparkle");
println!("cargo:rustc-link-lib=framework=AppKit");
println!("cargo:rustc-link-lib=framework=Foundation");
println!("cargo:rerun-if-env-changed=SPARKLE_FRAMEWORK_PATH");
}