1# Compilation and Building 2 3The compilation and building subsystem provides a framework based on Generate Ninja (GN) and Ninja. This subsystem allows you to: 4 5- Build products based on different chipset platforms, for example, Hi3516D V300. 6 7- Package capabilities required by a product by assembling modules based on the product configuration. 8 9## Introduction 10 11It is considered best practice to learn the following basic concepts before you start building: 12 13- Platform 14 15 A combination of development boards and kernels. Supported subsystems and components vary with the platform. 16 17- Subsystem 18 19 OpenHarmony is designed with a layered architecture, which consists of the kernel layer, system service layer, framework layer, and application layer from the bottom up. System functions are developed by the level of system, subsystem, and component. In a multi-device deployment scenario, you can customize subsystems and components as required. A subsystem is a logical system consisting of components. 20 21- Component 22 23 A component is a reusable software unit that contains source code, configuration files, resource files, and build scripts. A component can be built independently, integrated in binary mode, and then tested independently. 24 25- GN 26 27 GN is a system used to generate build files for Ninja. 28 29- Ninja 30 31 Ninja is a small high-speed build system. 32 33 34## Directory Structure 35 36```text 37/build # Main directory 38 39├── __pycache__ 40├── build_scripts/ # Python scripts for build 41├── common/ 42├── config/ # Build-related configuration 43├── core 44│ └── gn/ # BUILD.gn configuration 45│ └── build_scripts/ 46├── docs 47├── gn_helpers.py* 48├── lite/ # hb and preloader entry 49├── misc/ 50├── ohos # OpenHarmony building and packaging configuration 51│ ├── kits # Kits build and packaging templates and processing 52│ ├── ndk # NDK templates and processing 53│ ├── notice # Notice templates and processing 54│ ├── packages # Distribution packaging templates and processing 55│ ├── sa_profile # SA profiles and processing 56│ ├── sdk # SDK templates and processing, which contains the module configuration in the SDK 57│ └── testfwk # Testing-related processing 58├── ohos.gni* # Common .gni files (facilitating one-time import of each module) 59├── ohos_system.prop 60├── ohos_var.gni* 61├── prebuilts_download.sh* # Prebuilt script 62├── print_python_deps.py* 63├── scripts/ 64├── subsystem_config.json 65├── subsystem_config_example.json 66├── templates/ # C/C++ build templates 67├── test.gni* 68├── toolchain # Build toolchain configuration 69├── tools # Common tools 70├── version.gni 71├── zip.py* 72``` 73 74 75**Figure 1** Architecture of the compilation and building subsystem 76![](figures/build_framework_en.png) 77 78 79## Working Principles 80 81The compilation and build process of OpenHarmony is as follows: 82 831. Parsing commands: Parse the name of the product to build and load related configurations. 84 852. Running GN: Configure the toolchain and global options based on the parsed product name and compilation type. 86 873. Running Ninja: Start building and generate a product distribution. 88 89## Building a Mini or Small System 90 91See [build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README.md). 92 93## Building a Standard System 94 95See [build](https://gitee.com/openharmony/build). 96 97## Repositories Involved 98 99[build\_lite](https://gitee.com/openharmony/build_lite) 100 101[build](https://gitee.com/openharmony/build) 102