1# Install dependencies: 2 3Ensure the following components are installed: 4- repo 5- clang++-14 6- clang-format-14 7- clang-tidy-14 8- doxygen 9- graphviz 10- Git LFS 11 12# How to download 13 14```sh 15repo init -u https://gitee.com/ark-standalone-build/manifest.git -b master 16repo sync -c -j8 17repo forall -c 'git lfs pull' 18./prebuilts_download.sh 19``` 20 21# How to build and test 22 23## Build AbcKit for Linux 24 25```sh 26# Debug mode 27./ark.py x64.debug abckit_packages --gn-args="is_standard_system=true abckit_enable=true" 28# Release mode 29./ark.py x64.release abckit_packages --gn-args="is_standard_system=true abckit_enable=true" 30``` 31 32## Build AbcKit for Windows 33```sh 34# Debug mode 35./ark.py mingw_x86_64.debug abckit_packages --gn-args="is_standard_system=true abckit_enable=true" 36# Release mode 37./ark.py mingw_x86_64.release abckit_packages --gn-args="is_standard_system=true abckit_enable=true" 38``` 39 40## Output Locations 41 42The generated abckit binary and libabckit.so/libabckit.dll are in the `out/${target}/arkcompiler/runtime_core/libabckit` directory. 43 44The generated binary and library depend on the libraries in: 45- `out/${target}/arkcompiler/runtime_core/` 46- `out/${target}/arkcompiler/ets_runtime/` 47- `out/${target}/thirdparty/icu/` 48- `out/${target}/thirdparty/zlib/` 49 50NOTE: Replace ${target} with build target: x64.debug, x64.release, mingw\_x86\_64.debug or mingw\_x86\_64.release. 51 52## Run unit tests 53 54```sh 55# Debug mode 56./ark.py x64.debug abckit_tests --gn-args="is_standard_system=true abckit_enable=true" 57# Release mode 58./ark.py x64.release abckit_tests --gn-args="is_standard_system=true abckit_enable=true" 59``` 60 61## Run unit tests with sanitizers 62 63```sh 64# Debug mode 65./ark.py x64.debug abckit_tests --gn-args="is_standard_system=true abckit_enable=true libabckit_with_sanitizers=true" 66# Release mode 67./ark.py x64.release abckit_tests --gn-args="is_standard_system=true abckit_enable=true libabckit_with_sanitizers=true" 68``` 69 70# How to use AbcKit 71 72Requirements: 73- AbcKit works with the release version of abc files 74- Currently AbcKit supports abc files compiled from ArkTS and JS 75- Currently AbcKit does not support CommonJS modules 76 77AbcKit provides C API and C++ API to inspect and modify abc file. 78 79Users can use AbcKit API to implement abckit plugins. 80 81There are two ways to use abckit: executable binary and dynamic library. 82 83(1) executable binary 84 85Implement the following function: 86 87```cpp 88extern "C" int Entry(AbckitFile *file) 89{ 90 // Users can use AbcKit API here. 91 return 0; 92} 93``` 94 95Compile the code to a dynamic library (e.g. transformer.so) as an abckit plugin. 96 97Run the following command to execute the abckit plugin: 98 99```sh 100./abckit --plugin-path transformer.so --input-file /path/to/input.abc --output-file /path/to/output.abc 101``` 102 103(2) dynamic library 104 105Users can load libabckit.so/libabckit.dll then use AbcKit API. 106 107# Full tests (`self-check.sh`) 108 109Remove out, build AbcKit, execute format, tidy, unit-tests and stress tests in debug and release modes: 110 111```sh 112./arkcompiler/runtime_core/libabckit/scripts/self-check.sh --dir=/path/to/standalone/root 113``` 114 115# Code coverage (`self-check.sh`) 116 117Remove out, build AbcKit, execute unit-tests and stress tests in debug mode and collect code coverage: 118 119```sh 120./arkcompiler/runtime_core/libabckit/scripts/self-check.sh --dir=/path/to/standalone/root --coverage 121``` 122