Skip to main content

euv_cli/builder/ecosystem/
struct.rs

1use super::*;
2
3/// Configuration for building the shared zero-SIMD WebAssembly host core (`euv_app.wasm` + CJS/ESM glue).
4#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
5pub struct SharedWasmHostConfig {
6    /// Root path of the `euv` workspace containing `example/`.
7    pub(crate) workspace_root: PathBuf,
8    /// Optional staging directory overriding `target/mobile-hosts/euv-host-wasm`.
9    pub(crate) stage_dir: Option<PathBuf>,
10    /// Whether to compile in release mode (`panic=abort` + optional `wasm-opt -Oz` + AI-schema check).
11    #[get(type(copy))]
12    pub(crate) release: bool,
13    /// Whether to skip the optional `wasm-opt` pass.
14    #[get(type(copy))]
15    pub(crate) skip_wasm_opt: bool,
16    /// Whether to reuse existing staged WASM/glue files when present on disk.
17    #[get(type(copy))]
18    pub(crate) reuse_existing: bool,
19}
20
21/// Output paths produced by compiling the shared zero-DOM WebAssembly host core.
22#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
23pub struct SharedWasmHostArtifacts {
24    /// Compiled (and optionally `wasm-opt` optimized) `euv_app.wasm` path.
25    pub(crate) wasm_path: PathBuf,
26    /// Patched CommonJS glue path (`euv_wasm_glue.cjs.js`).
27    pub(crate) glue_cjs_path: PathBuf,
28    /// Patched ES Module glue path (`euv_wasm_glue.esm.js`).
29    pub(crate) glue_esm_path: PathBuf,
30    /// Final `euv_app.wasm` size in bytes.
31    #[get(type(copy))]
32    pub(crate) wasm_bytes: u64,
33}
34
35/// Configuration for generating and compiling a HarmonyOS / OpenHarmony Stage-Model project.
36#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
37pub struct HarmonyBuildConfig {
38    /// Root directory of the `euv` workspace.
39    pub(crate) workspace_root: PathBuf,
40    /// Target HarmonyOS device form factor (`phone`, `tablet`, `2in1`, `universal`, `foldable`, `wearable`, `tv`, `car`).
41    #[get(type(copy))]
42    pub(crate) device_kind: HarmonyDeviceKind,
43    /// Optional explicit ABI list; empty triggers auto-selection (`[arm64-v8a, x86_64]` for PC/universal, `[arm64-v8a]` otherwise).
44    pub(crate) abis: Vec<HarmonyAbi>,
45    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
46    pub(crate) app_version: Option<String>,
47    /// Optional output directory overriding `dist/harmony/<device>`.
48    pub(crate) out_dir: Option<PathBuf>,
49    /// Optional staging directory overriding `target/mobile-hosts/harmony-<device>`.
50    pub(crate) build_dir: Option<PathBuf>,
51    /// Optional OpenHarmony SDK root directory overriding `OHOS_SDK_HOME` auto-detection.
52    pub(crate) ohos_sdk_root: Option<PathBuf>,
53    /// When `true`, generates the Stage-Model + N-API + Rust shell without invoking OHOS NDK/hvigorw.
54    #[get(type(copy))]
55    pub(crate) shell_only: bool,
56    /// When `true` and a `.hap` is assembled, installs it via `hdc install -r`.
57    #[get(type(copy))]
58    pub(crate) install_hap: bool,
59}
60
61/// Report emitted after generating or compiling a HarmonyOS / OpenHarmony project.
62#[derive(Clone, Debug, Deserialize, Eq, Getter, PartialEq, Serialize)]
63pub struct HarmonyBuildReport {
64    /// Device form factor label (`phone`, `2in1`, `wearable`, etc.).
65    pub(crate) device_kind: String,
66    /// Resolved semantic version written into `oh-package.json5` and `AppScope/app.json5`.
67    pub(crate) version: String,
68    /// Computed HarmonyOS integer `versionCode`.
69    #[get(type(copy))]
70    pub(crate) version_code: u32,
71    /// Generated HarmonyOS project root directory.
72    pub(crate) out_dir: PathBuf,
73    /// Rust staticlib host build directory.
74    pub(crate) build_dir: PathBuf,
75    /// Paths to compiled `libeuv_harmony_host.so` binaries (empty in `shell_only` or without OHOS NDK).
76    pub(crate) compiled_so_paths: Vec<PathBuf>,
77    /// Optional assembled `.hap` path when `hvigorw` was executed.
78    pub(crate) hap_path: Option<PathBuf>,
79    /// Whether `hdc install -r` deployed the `.hap`.
80    #[get(type(copy))]
81    pub(crate) installed: bool,
82}
83
84/// Configuration for generating and packaging MiniApp vendor hosts (13 ecosystems).
85#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
86pub struct MiniAppBuildConfig {
87    /// Root directory of the `euv` workspace.
88    pub(crate) workspace_root: PathBuf,
89    /// Target MiniApp vendors to generate (empty defaults to all 13 vendors).
90    pub(crate) vendors: Vec<MiniAppVendor>,
91    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
92    pub(crate) app_version: Option<String>,
93    /// Optional output root overriding `dist/miniapp`.
94    pub(crate) out_base: Option<PathBuf>,
95    /// Whether to compile the shared WASM core in release profile.
96    #[get(type(copy))]
97    pub(crate) release: bool,
98    /// When `true`, skips shared WASM core and HarmonyOS native compilation.
99    #[get(type(copy))]
100    pub(crate) shell_only: bool,
101    /// Whether to skip optional `wasm-opt` when compiling the shared WASM core.
102    #[get(type(copy))]
103    pub(crate) skip_wasm_opt: bool,
104}
105
106/// Report produced after building one or more MiniApp vendor projects.
107#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
108pub struct MiniAppBuildReport {
109    /// Resolved semantic version used in generated manifests.
110    pub(crate) version: String,
111    /// Generated vendor labels and output directories.
112    pub(crate) generated_dirs: Vec<PathBuf>,
113    /// Whether the shared zero-DOM WASM core was compiled and bundled into JS vendors.
114    #[get(type(copy))]
115    pub(crate) wasm_bundled: bool,
116}
117
118/// Configuration for generating and packaging QuickApp vendor projects (`alliance`, `huawei`).
119#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
120pub struct QuickAppBuildConfig {
121    /// Root directory of the `euv` workspace.
122    pub(crate) workspace_root: PathBuf,
123    /// Target QuickApp vendors (empty defaults to `[Alliance, Huawei]`).
124    pub(crate) vendors: Vec<QuickAppVendor>,
125    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
126    pub(crate) app_version: Option<String>,
127    /// Optional output root overriding `dist/quickapp`.
128    pub(crate) out_base: Option<PathBuf>,
129    /// Whether to compile the shared WASM core in release profile.
130    #[get(type(copy))]
131    pub(crate) release: bool,
132    /// When `true`, skips shared WASM core compilation and `hap release` `.rpk` packaging.
133    #[get(type(copy))]
134    pub(crate) shell_only: bool,
135    /// Whether to skip optional `wasm-opt`.
136    #[get(type(copy))]
137    pub(crate) skip_wasm_opt: bool,
138}
139
140/// Report produced after building one or more QuickApp vendor projects.
141#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
142pub struct QuickAppBuildReport {
143    /// Resolved semantic version written into `package.json` and `src/manifest.json`.
144    pub(crate) version: String,
145    /// Computed numeric `versionCode`.
146    #[get(type(copy))]
147    pub(crate) version_code: u32,
148    /// Generated QuickApp vendor project directories.
149    pub(crate) generated_dirs: Vec<PathBuf>,
150    /// Whether the shared zero-DOM WASM core was compiled and copied.
151    #[get(type(copy))]
152    pub(crate) wasm_bundled: bool,
153}
154
155/// Configuration for generating and building smartwatch wearable hosts across 8 ecosystems.
156#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
157pub struct WearableBuildConfig {
158    /// Root directory of the `euv` workspace.
159    pub(crate) workspace_root: PathBuf,
160    /// Target wearable vendors (empty defaults to all 8 vendors).
161    pub(crate) vendors: Vec<WearableVendor>,
162    /// Optional explicit semantic version overriding workspace `Cargo.toml`.
163    pub(crate) app_version: Option<String>,
164    /// Optional output root overriding `dist/wearable`.
165    pub(crate) out_base: Option<PathBuf>,
166    /// Whether to compile native/WASM artifacts in release profile.
167    #[get(type(copy))]
168    pub(crate) release: bool,
169    /// When `true`, generates project shells without invoking NDK/Xcode/OHOS/WASM compilers.
170    #[get(type(copy))]
171    pub(crate) shell_only: bool,
172    /// When `true`, installs built Wear OS APK / HarmonyOS Watch HAP where supported.
173    #[get(type(copy))]
174    pub(crate) install: bool,
175    /// Whether to skip optional `wasm-opt`.
176    #[get(type(copy))]
177    pub(crate) skip_wasm_opt: bool,
178}
179
180/// Report produced after building one or more smartwatch wearable targets.
181#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
182pub struct WearableBuildReport {
183    /// Resolved semantic version written into wearable manifests.
184    pub(crate) version: String,
185    /// Computed numeric `versionCode`.
186    #[get(type(copy))]
187    pub(crate) version_code: u32,
188    /// Generated wearable project directories or artifact paths.
189    pub(crate) generated_paths: Vec<PathBuf>,
190    /// Whether the shared zero-DOM WASM core was compiled and bundled into WASM watches.
191    #[get(type(copy))]
192    pub(crate) wasm_bundled: bool,
193}