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
138
139
140
141
142
143
144
145
//! Target definitions: `<os>-<toolkit>` pairs (DESIGN.md ยง1) and their build/launch shapes.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum TargetKind {
Desktop,
IosSim,
Android,
/// HarmonyOS Next / ArkUI: a Rust cdylib (`libentry.so`) loaded by an ArkTS host and mounted
/// into a NodeContent, packaged into a `.hap` (see apps/day-arkui-demo/platform/ohos). Cross-compiled
/// with the OpenHarmony NDK (`OHOS_NDK_HOME`); packaged/signed/run via DevEco Studio or hvigor.
HarmonyOs,
}
#[derive(Clone, Copy, Debug)]
pub struct Target {
pub name: &'static str,
pub toolkit: &'static str,
pub kind: TargetKind,
/// Host OS that can build this target.
pub host: &'static str,
/// Human-friendly label for pickers/menus (e.g. `day new`'s interactive target chooser).
pub label: &'static str,
/// Not yet production-ready โ surfaced with an `[EXPERIMENTAL]` tag in menus.
pub experimental: bool,
}
// Ordered for presentation (mobile first, then desktops grouped by OS, experimental last) โ this is
// the order the `day new` interactive target menu shows. `find()` is by name and `Day.toml` defaults
// are string literals, so the order is purely cosmetic elsewhere.
pub const TARGETS: &[Target] = &[
Target {
name: "ios-uikit",
toolkit: "uikit",
kind: TargetKind::IosSim,
host: "macos",
label: "iOS",
experimental: false,
},
Target {
name: "android-widget",
toolkit: "widget",
kind: TargetKind::Android,
host: "any",
label: "Android",
experimental: false,
},
Target {
name: "macos-appkit",
toolkit: "appkit",
kind: TargetKind::Desktop,
host: "macos",
label: "macOS (AppKit)",
experimental: false,
},
Target {
name: "macos-gtk",
toolkit: "gtk",
kind: TargetKind::Desktop,
host: "macos",
label: "macOS (GTK)",
experimental: false,
},
Target {
name: "macos-qt",
toolkit: "qt",
kind: TargetKind::Desktop,
host: "macos",
label: "macOS (Qt)",
experimental: false,
},
Target {
name: "linux-gtk",
toolkit: "gtk",
kind: TargetKind::Desktop,
host: "linux",
label: "Linux (GTK)",
experimental: false,
},
Target {
name: "linux-qt",
toolkit: "qt",
kind: TargetKind::Desktop,
host: "linux",
label: "Linux (Qt)",
experimental: false,
},
Target {
name: "windows-winui",
toolkit: "winui",
kind: TargetKind::Desktop,
host: "windows",
label: "Windows (WinUI)",
experimental: false,
},
Target {
name: "windows-qt",
toolkit: "qt",
kind: TargetKind::Desktop,
host: "windows",
label: "Windows (Qt)",
experimental: false,
},
Target {
name: "windows-gtk",
toolkit: "gtk",
kind: TargetKind::Desktop,
host: "windows",
label: "Windows (GTK)",
experimental: false,
},
Target {
name: "ohos-arkui",
toolkit: "arkui",
kind: TargetKind::HarmonyOs,
host: "any",
label: "OpenHarmony ArkUI",
experimental: false,
},
];
pub fn find(name: &str) -> Option<&'static Target> {
TARGETS.iter().find(|t| t.name == name)
}
pub fn host_os() -> &'static str {
if cfg!(target_os = "macos") {
"macos"
} else if cfg!(target_os = "linux") {
"linux"
} else if cfg!(target_os = "windows") {
"windows"
} else {
"other"
}
}
/// The default target for the current host โ the sensible preselection for `day new app`'s target
/// menu and the fallback when a non-interactive `day new app` gets no `--toolkit`.
pub fn host_default() -> &'static str {
match host_os() {
"linux" => "linux-gtk",
"windows" => "windows-winui",
_ => "macos-appkit",
}
}