• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 安装依赖项:
2
3确保安装以下组件:
4- repo
5- clang++-14
6- clang-format-14
7- clang-tidy-14
8- doxygen
9- graphviz
10- Git LFS
11
12# 如何下载
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# 如何构建和测试
22
23## 构建 Linux 平台的 AbcKit
24
25```sh
26# debug模式
27./ark.py x64.debug abckit_packages --gn-args="is_standard_system=true abckit_enable=true"
28# release模式
29./ark.py x64.release abckit_packages --gn-args="is_standard_system=true abckit_enable=true"
30```
31
32## 构建 Windows 平台的 AbcKit
33```sh
34# debug模式
35./ark.py mingw_x86_64.debug abckit_packages --gn-args="is_standard_system=true abckit_enable=true"
36# release模式
37./ark.py mingw_x86_64.release abckit_packages --gn-args="is_standard_system=true abckit_enable=true"
38```
39
40## 构建产物的位置
41
42生成的 Abckit 二进制文件和 libabckit.so/libabckit.dll 位于 `out/${target}/arkcompiler/runtime_core/libabckit` 目录。
43
44生成的二进制文件和库依赖于以下目录中的库:
45- `out/${target}/arkcompiler/runtime_core/`
46- `out/${target}/arkcompiler/ets_runtime/`
47- `out/${target}/thirdparty/icu/`
48- `out/${target}/thirdparty/zlib/`
49
50注意:根据编译方式将 ${target} 替换为:x64.debugx64.release、mingw\_x86\_64.debug 或 mingw\_x86\_64.release51
52## 运行单元测试
53
54```sh
55# debug模式
56./ark.py x64.debug abckit_tests --gn-args="is_standard_system=true abckit_enable=true"
57# release模式
58./ark.py x64.release abckit_tests --gn-args="is_standard_system=true abckit_enable=true"
59```
60
61## 使用 Sanitizer 运行单元测试
62
63```sh
64# debug模式
65./ark.py x64.debug abckit_tests --gn-args="is_standard_system=true abckit_enable=true libabckit_with_sanitizers=true"
66# release模式
67./ark.py x64.release abckit_tests --gn-args="is_standard_system=true abckit_enable=true libabckit_with_sanitizers=true"
68```
69
70# 如何使用 AbcKit
71
72要求:
73- AbcKit 适用于 `release` 模式的方舟字节码文件
74- 目前 AbcKit 支持从 ArkTS 或 JS 编译的方舟字节码文件
75- 目前 AbcKit 不支持 CommonJS 模块
76
77AbcKit 提供 C API 和 C++ API 来读取和修改方舟字节码文件。
78
79用户可以使用 AbcKit API 来实现 Abckit 插件。
80
81有两种使用 Abckit 的方式:可执行二进制文件和动态库。
82
83(1) 可执行二进制文件
84
85实现以下函数:
86
87```cpp
88extern "C" int Entry(AbckitFile *file)
89{
90    // 用户可以在这里使用 AbcKit API。
91    return 0;
92}
93```
94
95将代码编译为动态库(例如 transformer.so)作为 abckit 插件。
96
97运行以下命令来执行 abckit 插件:
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) 动态库
104
105用户可以加载 libabckit.so/libabckit.dll 然后使用 AbcKit API。
106
107# 全量测试
108
109删除 out 目录,构建 AbcKit,在debug和release模式下执行`self-check.sh` 脚本。该脚本会进行代码格式化、代码检查、单元测试和压力测试。
110
111```sh
112./arkcompiler/runtime_core/libabckit/scripts/self-check.sh --dir=/path/to/standalone/root
113```
114
115# 代码覆盖率
116
117删除 out 目录,构建 AbcKit,在debug模式下执行 `self-check.sh` 脚本。该脚本会执行单元测试和压力测试,并收集代码覆盖率。
118
119```sh
120./arkcompiler/runtime_core/libabckit/scripts/self-check.sh --dir=/path/to/standalone/root --coverage
121```
122