-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.rs
executable file
·68 lines (64 loc) · 1.78 KB
/
build.rs
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
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
const COMMANDS: &[&str] = &[
"available_ports",
"available_ports_direct",
"managed_ports",
"cancel_read",
"close",
"close_all",
"force_close",
"open",
"read",
"read_binary",
"start_listening",
"stop_listening",
"write",
"write_binary",
"set_baud_rate",
"set_data_bits",
"set_flow_control",
"set_parity",
"set_stop_bits",
"set_timeout",
"write_request_to_send",
"write_data_terminal_ready",
"read_clear_to_send",
"read_data_set_ready",
"read_ring_indicator",
"read_carrier_detect",
"bytes_to_read",
"bytes_to_write",
"clear_buffer",
"set_break",
"clear_break",
"write_rts",
"write_dtr",
"read_cts",
"read_dsr",
"read_ri",
"read_cd",
];
fn main() {
let result = tauri_plugin::Builder::new(COMMANDS)
.global_api_script_path("./src/api-iife.js")
.android_path("android")
.try_build();
// when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build
if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) {
result.unwrap();
}
tauri_plugin::mobile::update_android_manifest(
"SERIAL PLUGIN",
"activity",
r#"<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />"#
.to_string(),
)
.expect("failed to update AndroidManifest.xml");
}