1# Customizing Ark Bytecode During Compilation
2
3If you want to customize the content of the Ark bytecode file, you can use the ArkTS compilation toolchain to customize the Ark bytecode file.
4
5## Capability Configuration Description
6
7Prepare a dynamic library file for operating the ARK bytecode file. In the build-profile.json5 configuration file of the project, configure the [compilation option transformLib](arkoptions-guide.md) and set the option value to the path of the dynamic library, the compiler loads the dynamic library at the specified time and executes the specific Transform method in the library.
8
9## Capability execution mechanism
10
11If the transformLib option is not configured in the build-profile.json5 file of the project, the compiler directly generates the ARK bytecode file to the default location. If transformLib is configured and the corresponding dynamic library file can be correctly loaded, the compiler generates an ARK bytecode file to the default destination location, calls the Transform method in the dynamic library, and transfers the path of the ARK bytecode file as a parameter. The Transform method is used to customize the logic for regenerating the ARK bytecode file.
12
13The following development example is a dynamic library template. You need to implement the specific logic of Transform based on your requirements.
14
15## How to Develop
16
171. Create the source code for modifying the dynamic library.
18
19   ```
20   /**
21    * @brief Entry method for modifying the ARK bytecode file
22    * @param abc_path Path for storing the ARK bytecode file to be processed.
23    */
24   extern "C" int Transform(const char *abc_path)
25   {
26       // You can read the ARK bytecode file corresponding to ${abc_path}, modify related data based on the ARK bytecode format, and generate a new ARK bytecode file.
27       return 0;
28   }
29   ```
30
312. Use the C language compilation tool (G++) to compile the link library file of the corresponding platform.
32
33   Windows
34
35   ```
36   g++ --share -o example.dll example.cpp
37   ```
38
39   Linux
40
41   ```
42   g++ --share -o example.so example.cpp
43   ```
44
45   Mac platform:
46
47   ```
48   g++ --shared -o example.so example.cpp
49   ```
50
513. Configure the transformLib option in the build-profile.json5 file in the IDE. The following uses the Windows environment as an example.
52
53   The path configured in the option is the path of the link library file generated in step 2 in the project (in this example, the path is in the dll directory).
54
55   !image_0000002079773605](figures/image_0000002079773605.png)
56
574. Recompile the project to customize the Ark bytecode.
58