This project automates the process of collecting, wrapping, and packaging the OpenHarmony ETS (ArkCompiler) toolchain binaries into a portable NPM package. It enables you to use tools like es2abc and ark_js_vm on your development machine with ease, similar to how TypeScript is used.
- Automated Collection: Scans OpenHarmony build output for required binaries and shared libraries.
- Dependency Management: Bundles necessary
.sofiles (ICU, ZLib, Runtime) so you don't need to mess with system library paths. - Smart Wrappers: Generates executable wrappers that automatically configure
LD_LIBRARY_PATHbefore running the tools. - NPM Integration: Generates a valid
package.jsonfor easy installation vianpm linkornpm install.
- OpenHarmony Source Build: You must have a successful build of OpenHarmony (specifically the
arkcompilercomponents). - Node.js: Required to run the build script.
The build is controlled by config.json. You may need to edit this file to match your environment:
{
"ohosRoot": "/path/to/your/openharmony/src",
"outDirRelative": "out/rk3568/clang_x64",
"frontend": "arkcompiler/ets_frontend",
"runtime": "arkcompiler/ets_runtime",
// ...
}ohosRoot: Absolute path to your OpenHarmony source root.outDirRelative: Path to the build output directory (relative to root).binaries: List of executables to include in the package.
-
Navigate to this directory.
-
Run the build script:
node build.js
This will create a
dist/directory containing the full package.
To use the tools globally on your machine:
cd dist
npm linkOnce linked, you can run the commands directly from any terminal:
# Compile JavaScript to Ark Bytecode
es2abc --output hello.abc hello.js
# Run the Bytecode
ark_js_vm hello.abc
# Check AOT Compiler
ark_aot_compiler --helpA verification script is included to test that all binaries link correctly and function as expected:
bash verify.shBy default, the following tools are packaged:
- es2abc: JS to ABC compiler
- ark_js_vm: Ark Runtime Virtual Machine
- ark_aot_compiler: Ahead-of-Time compiler
- ark_stub_compiler: Stub compiler
- es2panda: Panda assembler
- merge_abc: ABC file merger
- profdump: Profiling dump tool
- quick_fix: Quick fix tool
- "error while loading shared libraries": If you see this when running a tool, it means a required
.sofile was not copied todist/lib. Checkbuild.jsand ensures the library is listed in the copy logic. - "Permission denied": Ensure the scripts in
dist/binhave execute permission (the build script attempts to set this).