mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-07 10:22:29 +02:00
enhance hvigor plugin
This commit is contained in:
@@ -118,7 +118,7 @@ impl Target {
|
||||
Self::Android => "android",
|
||||
#[cfg(target_os = "macos")]
|
||||
Self::Ios => "ios",
|
||||
Self::OpenHarmony => "open-harmony",
|
||||
Self::OpenHarmony => "ohos",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user