enhance hvigor plugin

This commit is contained in:
Lucas Nogueira
2025-08-20 08:15:38 -03:00
parent b22662bceb
commit 122665da0c
4 changed files with 27 additions and 23 deletions

View File

@@ -118,7 +118,7 @@ impl Target {
Self::Android => "android",
#[cfg(target_os = "macos")]
Self::Ios => "ios",
Self::OpenHarmony => "open-harmony",
Self::OpenHarmony => "ohos",
}
}

View File

@@ -23,7 +23,7 @@ pub fn gen(
map.insert(
"root-dir-rel",
Path::new(&os::replace_path_separator(
util::relativize_path(app.root_dir(), &dest).into_os_string(),
util::relativize_path(app.root_dir(), &dest.join("entry")).into_os_string(),
)),
);
map.insert("root-dir", app.root_dir());

View File

@@ -1,6 +1,28 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
import { hvigor, HvigorPlugin, HvigorNode, HvigorTask } from '@ohos/hvigor';
import { execFileSync } from 'child_process';
import { resolve } from 'path';
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[tauriPlugin()] /* Custom plugin to extend the functionality of Hvigor. */
}
function tauriPlugin(): HvigorPlugin {
return {
pluginId: 'tauri',
apply(node: HvigorNode) {
const buildRustCode = () => {
const properties = hvigor.getParameter().getProperties();
const target = properties.target || "aarch64";
execFileSync(`{{tauri-binary}}`,
[{{quote-and-join tauri-binary-args}}, "--target", target], {
cwd: resolve(__dirname, "{{root-dir-rel}}"),
stdio: "inherit",
});
}
node.getTaskByName('default@ConfigureCmake').afterRun(buildRustCode);
}
}
}

View File

@@ -1,24 +1,6 @@
import { appTasks } from '@ohos/hvigor-ohos-plugin';
import { hvigor, HvigorPlugin, HvigorNode } from '@ohos/hvigor';
import { execFileSync } from 'child_process';
import { resolve } from 'path';
export default {
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[tauriPlugin()] /* Custom plugin to extend the functionality of Hvigor. */
}
function tauriPlugin(): HvigorPlugin {
return {
pluginId: 'tauri',
apply(node: HvigorNode) {
const properties = hvigor.getParameter().getProperties();
const target = properties.target || "aarch64";
execFileSync(`{{tauri-binary}}`, [{{quote-and-join tauri-binary-args}}, "--target", target], {
cwd: resolve(__dirname, "{{root-dir-rel}}"),
stdio: "inherit",
shell: true,
});
}
}
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}