@ccgo/hvigor-ohos-plugin
v0.0.3
Published
Convention plugins for CCGO cross-platform C++ projects - OpenHarmony/HarmonyOS hvigor build tools
Maintainers
Readme
CCGO Hvigor Plugins
Convention plugins for CCGO cross-platform C++ projects - OpenHarmony/HarmonyOS hvigor build tools.
Overview
This package provides hvigor plugins that integrate with CCGO's cross-platform build system for OpenHarmony/HarmonyOS projects. These plugins are published to npm and can be consumed by any CCGO project.
Requirements
- Node.js >= 18.0.0
- DevEco Studio with hvigor (provides
@ohos/hvigor) - CCGO CLI tool
Installation
npm install @ccgo/hvigor-ohos-plugin --save-devOr add to your oh-package.json5:
{
"devDependencies": {
"@ccgo/hvigor-ohos-plugin": "^0.0.1"
}
}Available Plugins
archivePlugin
Builds native C++ libraries and packages them into a HAR (Harmony Archive) file.
Features:
- Builds native libraries using CCGO
- Packages HAR using hvigorw
- Copies artifacts to
target/{debug|release}/ohos/ - Supports both debug and release builds
Usage:
In your module's hvigorfile.ts (e.g., ohos/main_ohos_sdk/hvigorfile.ts):
import { harTasks } from '@ohos/hvigor-ohos-plugin';
import { archivePlugin } from '@ccgo/hvigor-ohos-plugin';
export default {
system: harTasks,
plugins: [archivePlugin()]
}Run the build:
# From the ohos/ directory
hvigorw buildHAR --mode module -p module=main_ohos_sdk@defaultOptions:
archivePlugin({
// Custom native build command (default: 'ccgo build ohos --native-only')
nativeBuildCommand: 'ccgo build ohos --native-only',
// Custom HAR assembly command
harAssembleCommand: 'hvigorw assembleHar --mode module -p product=default --no-daemon --info',
// Whether to copy HAR to target directory (default: true)
copyToTarget: true,
})Project Structure
ccgo-hvigor-plugins/
├── src/
│ ├── index.ts # Main exports
│ ├── plugins/
│ │ └── archive-plugin.ts # Archive plugin implementation
│ └── types/
│ └── @ohos/
│ └── hvigor.d.ts # Type definitions for @ohos/hvigor
├── dist/ # Compiled output (generated)
├── package.json
├── tsconfig.json
└── README.mdDevelopment
Build
npm run buildLocal Testing
Build the package:
npm run buildLink locally:
npm linkIn your CCGO project:
npm link @ccgo/hvigor-ohos-plugin
Publishing
# Login to npm (first time only)
npm login
# Publish
npm publish --access publicIntegration with CCGO Template
When using CCGO template, update the generated ohos/main_ohos_sdk/hvigorfile.ts:
Before (local plugin):
import { harTasks } from '@ohos/hvigor-ohos-plugin';
import { archivePlugin } from '../hvigor/archive-plugin';
export default {
system: harTasks,
plugins: [archivePlugin()]
}After (remote plugin):
import { harTasks } from '@ohos/hvigor-ohos-plugin';
import { archivePlugin } from '@ccgo/hvigor-ohos-plugin';
export default {
system: harTasks,
plugins: [archivePlugin()]
}Environment Variables
CCGO_CI_BUILD_IS_RELEASE- Set to1ortruefor release builds (affects output directory)
License
MIT License - see LICENSE file for details.
Related Projects
- ccgo - CCGO CLI tool
- ccgo-template - Project template
- ccgo-gradle-plugins - Gradle plugins for Android/KMP
Contributing
This project is part of the CCGO ecosystem. For contribution guidelines, see the main CCGO repository.
