Build MoonBit computation libraries for HarmonyOS Native/Node-API.
moon install shop1111/moonohos/cmd/moonohos@0.3.0
moonohos --versionmoon update
moon build --target native --release --deny-warn cmd/moonohos
$taskCli = '.\_build\native\release\build\cmd\moonohos\moonohos.exe'
& $taskCli build --sdk 'D:\apps\DevEco Studio\sdk'
.\scripts\build_example.ps1 -DevEco 'D:\apps\DevEco Studio'{
"version": 1,
"module": "./my-core",
"package": "username/my-core",
"nativeModule": "moonohos",
"functions": [
{
"name": "add",
"params": [{"name": "left", "type": "Int"}, {"name": "right", "type": "Int"}],
"return": "Int"
}
]
}& $taskCli build --config .\moonohos.json --sdk 'D:\apps\DevEco Studio\sdk' --abi x86_64 --out .\native-package
& $taskCli build --config .\moonohos.json --sdk 'D:\apps\DevEco Studio\sdk' --dry-run| MoonBit | C 适配边界 | ArkTS |
|---|---|---|
| Int | int32_t | number,有限整数,范围 −2147483648…2147483647 |
| Double | double | number,参数和返回值必须有限 |
| Bool | int32_t | boolean |
| Unit 返回值 | void | void |
| String | moonbit_string_t,内部固定版本 ABI | string,UTF-16 码元原样复制 |
| Bytes | moonbit_bytes_t,内部固定版本 ABI | Uint8Array,复制视图范围 |
| Array[T] | 不透明指针与编译器生成的访问函数 | Array<T> |
| 具名普通 Struct | 不透明指针与编译器生成的访问函数 | 具名 interface |
import native from 'libmoonohos.so';
const text: string = native.join_text('你好,', 'MoonBit 🌙');
const bytes: Uint8Array = native.echo_bytes(new Uint8Array([0, 127, 255]));"types": [
{"name": "Sample", "fields": [
{"name": "label", "type": "String"},
{"name": "values", "type": "Array[Double]"}
]}
]& $taskCli doctor --sdk 'D:\apps\DevEco Studio\sdk' --json
& $taskCli check --config moonohos.json --json
& $taskCli inspect --config moonohos.json --json
& $taskCli plan --config moonohos.json --abi x86_64 --json
& $taskCli verify --out _build/moonohos/dist --json
& $taskCli build --sdk 'D:\apps\DevEco Studio\sdk' --out _build/moonohos/dist-cached --cache --jsondist/
libs/arm64-v8a/libmoonohos.so
libs/x86_64/libmoonohos.so
types/libmoonohos/index.d.ts
types/libmoonohos/oh-package.json5
cmake/MoonOHOS.cmake
manifest.json
README.md
NOTICE.NativeSDK.txt
NOTICE.MoonBit.txt{"dependencies":{"libmoonohos.so":"file:./src/main/cpp/types/libmoonohos"}}moon fmt
moon check --target native --deny-warn
moon test --target native --deny-warn
moon info --target native
python scripts\verify_manual.py 'D:\apps\DevEco Studio\sdk'
python scripts\verify_host.py
python scripts\verify_integration.py 'D:\apps\DevEco Studio\sdk'
.\scripts\verify_device.ps1 -Hdc 'D:\apps\DevEco Studio\sdk\default\openharmony\toolchains\hdc.exe'#deprecated("`ConfigError::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn ConfigError::to_repr(ConfigError) -> Reprpub struct ContentFingerprint {
domain : String
name : String
digest : String
}pub struct ConversionLimits {
depth : Int
nodes : Int
bytes : Int
}pub struct ElfInfo {
abi : String
dependencies : Array[String]
imports : Array[String]
exports : Array[String]
soname : String?
segments : Array[ElfSegment]
}pub struct ElfSegment {
offset : Int
file_size : Int
memory_size : UInt64
address : UInt64
flags : Int
alignment : UInt64
}pub struct EnvironmentFact {
name : String
actual : String
expected : String
available : Bool
}pub struct GeneratedArtifacts {
wrapper : String
package_file : String
header : String
embed : String
native : String
declarations : String
cmake : String
}pub struct PackageFile {
path : String
size : Int
checksum : String
}pub struct PackageInterface {
functions : Array[InterfaceFunction]
records : Array[InterfaceRecord]
}pub struct PackageManifest {
module_name : String
version : String
abis : Array[String]
files : Array[PackageFile]
}fn environment_fact(name : String, actual : String, expected : String, available : Bool) -> EnvironmentFactfn verify_library(info : ElfInfo, manifest : PackageManifest, abi : String) -> Unit raise ConfigErrorInstall
Download zipBuild MoonBit computation libraries for HarmonyOS Native/Node-API.