Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fa4c50b
feat: add openharmony support
lucasfernog Aug 19, 2025
a735cf1
fix get-prop
lucasfernog Aug 19, 2025
7a07470
fix dist
lucasfernog Aug 19, 2025
75688b8
fix emulator start cmd
lucasfernog Aug 19, 2025
2f415dd
fix imagepath
lucasfernog Aug 19, 2025
397427d
enhance hvigor plugin
lucasfernog Aug 20, 2025
c0e0c20
implement device run
lucasfernog Aug 20, 2025
d9326c8
devtools port forwarding
lucasfernog Aug 20, 2025
a895c27
use log
lucasfernog Aug 20, 2025
2c9372e
fix socket read
lucasfernog Aug 20, 2025
283f06e
do not require command line tools
lucasfernog Aug 21, 2025
48af541
fix if
lucasfernog Aug 21, 2025
171b93e
default OHOS_HOME
lucasfernog Aug 21, 2025
fa75ad2
windows paths
lucasfernog Aug 21, 2025
b26dda2
fix windows emulator list path
lucasfernog Aug 27, 2025
6655de6
dev --open on Windows
FabianLars Aug 27, 2025
3b36e0b
fix open name on cli
lucasfernog Aug 27, 2025
d639bd8
set OHOS_NDK_HOME for cargo-ohos
lucasfernog Aug 27, 2025
c5a387f
remove dbg
lucasfernog Aug 27, 2025
6575cd5
fix windows emulator imageRoot path
lucasfernog Aug 27, 2025
7e25240
Merge remote-tracking branch 'origin/dev' into feat/ohos
lucasfernog Sep 1, 2025
a1f2406
fix error message
lucasfernog Sep 2, 2025
eadd606
set OHOS_BASE_SDK_HOME for hvigor
lucasfernog Sep 2, 2025
0c8bddd
set DEVECO_SDK_HOME (linux requirement?)
lucasfernog Sep 2, 2025
2068b31
hvigorw actually experts a different OHOS_BASE_SDK_HOME on linux
lucasfernog Sep 2, 2025
8584c1c
install deps with ohpm
lucasfernog Sep 2, 2025
5356a1e
check signed hap
lucasfernog Sep 2, 2025
5a78021
fix device name for real devices
lucasfernog Sep 2, 2025
2e751b1
ohpm is a .bat on windows
lucasfernog Sep 3, 2025
5e52188
expect sdk to be on /default/openharmony instead of /default/openharmony
lucasfernog Sep 4, 2025
d4d48b6
fix ohpm path macos
lucasfernog Sep 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ toml = { version = "0.9", features = ["preserve_order"] }
duct = "1"
which = "8"
os_pipe = "1"
dirs = "6"

[dev-dependencies]
rstest = "0.26"
Expand Down
6 changes: 6 additions & 0 deletions src/config/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct Metadata {
pub apple: crate::apple::config::Metadata,
#[serde(default, rename = "cargo-android")]
pub android: crate::android::config::Metadata,
#[serde(default, rename = "cargo-open-harmony")]
pub open_harmony: crate::open_harmony::config::Metadata,
}

impl Metadata {
Expand Down Expand Up @@ -63,4 +65,8 @@ impl Metadata {
pub fn android(&self) -> &crate::android::config::Metadata {
&self.android
}

pub fn open_harmony(&self) -> &crate::open_harmony::config::Metadata {
&self.open_harmony
}
}
13 changes: 12 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use self::{app::App, raw::*};
#[cfg(target_os = "macos")]
use crate::apple;
use crate::{
android, bicycle, templating,
android, bicycle, open_harmony, templating,
util::cli::{Report, Reportable, TextWrapper},
};
use serde::Serialize;
Expand All @@ -31,6 +31,8 @@ pub enum FromRawError {
AppleConfigInvalid(apple::config::Error),
#[error(transparent)]
AndroidConfigInvalid(android::config::Error),
#[error(transparent)]
OpenHarmonyConfigInvalid(open_harmony::config::Error),
}

impl FromRawError {
Expand All @@ -40,6 +42,7 @@ impl FromRawError {
#[cfg(target_os = "macos")]
Self::AppleConfigInvalid(err) => err.report(msg),
Self::AndroidConfigInvalid(err) => err.report(msg),
Self::OpenHarmonyConfigInvalid(err) => err.report(msg),
}
}
}
Expand Down Expand Up @@ -99,6 +102,7 @@ pub struct Config {
#[cfg(target_os = "macos")]
apple: apple::config::Config,
android: android::config::Config,
open_harmony: open_harmony::config::Config,
}

impl Config {
Expand All @@ -109,11 +113,14 @@ impl Config {
.map_err(FromRawError::AppleConfigInvalid)?;
let android = android::config::Config::from_raw(app.clone(), raw.android)
.map_err(FromRawError::AndroidConfigInvalid)?;
let open_harmony = open_harmony::config::Config::from_raw(app.clone(), raw.open_harmony)
.map_err(FromRawError::OpenHarmonyConfigInvalid)?;
Ok(Self {
app,
#[cfg(target_os = "macos")]
apple,
android,
open_harmony,
})
}

Expand Down Expand Up @@ -175,6 +182,10 @@ impl Config {
&self.android
}

pub fn open_harmony(&self) -> &open_harmony::config::Config {
&self.open_harmony
}

pub fn build_a_bike(&self) -> bicycle::Bicycle {
templating::init(Some(self))
}
Expand Down
5 changes: 4 additions & 1 deletion src/config/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::app;
#[cfg(target_os = "macos")]
use crate::apple;
use crate::{
android,
android, open_harmony,
util::cli::{Report, Reportable, TextWrapper},
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -77,6 +77,7 @@ pub struct Raw {
#[cfg(target_os = "macos")]
pub apple: Option<apple::config::Raw>,
pub android: Option<android::config::Raw>,
pub open_harmony: Option<open_harmony::config::Raw>,
}

impl Raw {
Expand All @@ -89,6 +90,7 @@ impl Raw {
#[cfg(target_os = "macos")]
apple: Some(apple),
android: None,
open_harmony: None,
})
}

Expand All @@ -101,6 +103,7 @@ impl Raw {
#[cfg(target_os = "macos")]
apple: Some(apple),
android: None,
open_harmony: None,
})
}

Expand Down
37 changes: 36 additions & 1 deletion src/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::android;
#[cfg(target_os = "macos")]
use crate::apple;
use crate::{android, open_harmony};
use crate::{
config::{
self,
Expand Down Expand Up @@ -65,6 +65,8 @@ pub enum Error {
cause: io::Error,
},
OpenInEditorFailed(util::OpenInEditorError),
OpenHarmonyEnvFailed(open_harmony::env::Error),
OpenHarmonyInitFailed(open_harmony::project::Error),
}

impl Reportable for Error {
Expand All @@ -87,6 +89,8 @@ impl Reportable for Error {
Self::DotCargoWriteFailed(err) => err.report(),
Self::DotFirstInitDeleteFailed { path, cause } => Report::action_request(format!("Failed to delete first init dot file {path:?}; the project generated successfully, but `cargo mobile init` will have unexpected results unless you manually delete this file!"), cause),
Self::OpenInEditorFailed(err) => Report::error("Failed to open project in editor (your project generated successfully though, so no worries!)", err),
Self::OpenHarmonyEnvFailed(err) => err.report(),
Self::OpenHarmonyInitFailed(err) => err.report(),
}
}
}
Expand Down Expand Up @@ -204,6 +208,37 @@ pub fn exec(
);
}

// Generate DevEco Studio project
if metadata.open_harmony().supported() {
match open_harmony::env::Env::new() {
Ok(env) => open_harmony::project::gen(
config.open_harmony(),
metadata.open_harmony(),
&env,
&bike,
wrapper,
&filter,
skip_targets_install,
)
.map_err(Error::OpenHarmonyInitFailed)?,
Err(err) => {
if err.sdk_issue() {
Report::action_request(
"Failed to initialize OpenHarmony environment; OpenHarmony support won't be usable until you fix the issue below and re-run `cargo mobile init`!",
err,
)
.print(wrapper);
} else {
Err(Error::OpenHarmonyEnvFailed(err))?;
}
}
}
} else {
println!(
"Skipping OpenHarmony init, since it's marked as unsupported in your Cargo.toml metadata"
);
}

dot_cargo
.write(config.app())
.map_err(Error::DotCargoWriteFailed)?;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod doctor;
pub mod dot_cargo;
pub mod env;
pub mod init;
pub mod open_harmony;
pub mod opts;
pub mod os;
mod project;
Expand Down
Loading
Loading