subsys-build-module.md 21.6 KB
Newer Older
A
Annie_wang 已提交
1 2 3
# Module
## Configuration Rules

A
Annie_wang 已提交
4
The Compilation and Building subsystem implements compilation and packaging by module, component, and product. A module is a target to build. It can be a dynamic library, static library, configuration file, or prebuilt module. A module must belong to a component and can belong to only one component. OpenHarmony provides customized GN templates to configure modules. For details about the GN basics, see [GN Reference](https://gn.googlesource.com/gn/+/main/docs/reference.md).
A
Annie_wang 已提交
5 6 7 8 9 10 11 12 13 14

The common templates for module configuration are as follows:

```
# C/C++ templates
ohos_shared_library
ohos_static_library
ohos_executable
ohos_source_set

A
Annie_wang 已提交
15
# Prebuilt templates
A
Annie_wang 已提交
16 17 18 19
ohos_prebuilt_executable
ohos_prebuilt_shared_library
ohos_prebuilt_static_library

A
Annie_wang 已提交
20
# HAP templates
A
Annie_wang 已提交
21 22 23 24 25
ohos_hap
ohos_app_scope
ohos_js_assets
ohos_resources

A
Annie_wang 已提交
26 27 28 29 30 31 32 33 34 35 36
# Rust templates
ohos_rust_executable
ohos_rust_shared_library
ohos_rust_static_library
ohos_rust_proc_macro
ohos_rust_shared_ffi
ohos_rust_static_ffi
ohos_rust_cargo_crate
ohos_rust_systemtest
ohos_rust_unittest

A
Annie_wang 已提交
37 38
# Other templates
# Configuration file
A
Annie_wang 已提交
39
ohos_prebuilt_etc
A
Annie_wang 已提交
40

A
Annie_wang 已提交
41
# SA profile
A
Annie_wang 已提交
42 43 44
ohos_sa_profile
```

A
Annie_wang 已提交
45
You are advised to use the OpenHarmony customized templates.
A
Annie_wang 已提交
46

A
Annie_wang 已提交
47
### C/C++ Template Example
A
Annie_wang 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

The .gni file corresponding to the templates starting with **ohos** is located in **openharmony/build/templates/cxx/cxx.gni**.

**ohos_shared_library** example:

```shell
import("//build/ohos.gni")
ohos_shared_library("helloworld") {
  sources = ["file"]
  include_dirs = []             # If there are duplicate header files, the header files defined earlier take effect.
  cflags = []                   # If there are duplicate or conflict settings, the settings in cflags take effect.
  cflags_c = []
  cflags_cc = []
  ldflags = []                  # If there are duplicate or conflict definitions, the settings in ohos_template take effect.
  configs = []
  deps = []                     # Define dependent modules that belong to the same component.

  external_deps = [             # Define dependent modules that belong to different components.
A
Annie_wang 已提交
66 67
  "part_name:module_name",      # The value is in the Component_name:Module_name format.
  ]                             # The dependent modules must be declared in inner_kits by the dependent component.
A
Annie_wang 已提交
68 69 70 71

  output_name = [string]        # Name of the module output.
  output_extension = []         # Extension name of the module.
  module_install_dir = []       # Module installation directory. The default directory is /system/lib64 or /system/lib. Specify the directory from system/ or vendor/.
A
Annie_wang 已提交
72
  relative_install_dir = []     # Relative module installation directory (relative to /system/lib64 or /system/lib). If module_install_dir is configured, the parameter does not take effect.
A
Annie_wang 已提交
73 74 75

  part_name = [string]          # (Mandatory) Component name.
  output_dir
A
Annie_wang 已提交
76 77 78 79 80 81 82

  # Sanitizer configuration. Each item is optional, and set to false or left unspecified by default.
  sanitize = {
    # Sanitizer settings
    cfi = [boolean]               # Whether to enable the control-flow integrity (CFI) check.
    cfi_cross_dso = [boolean]     # Whether to enable the cross-DSO CFI check.
    integer_overflow = [boolean]  # Whether to enable the integer overflow check.
A
Annie_wang 已提交
83
    boundary_sanitize = [boolean] # Whether to enable the boundary check.
A
Annie_wang 已提交
84 85 86 87 88 89 90 91
    ubsan = [boolean]             # Whether to enable some Undefined Behavior Sanitizer (UBSAN) options.
    all_ubsan = [boolean]         # Whether to enable all UBSAN options.
    ...

    debug = [boolean]             # Whether to enable the debug mode.
    blocklist = [string]          # Path of the blocklist.
  }

A
Annie_wang 已提交
92 93
  testonly = [boolean]
  license_as_sources = []
A
Annie_wang 已提交
94
  license_file = []               # A .txt file.
A
Annie_wang 已提交
95 96 97 98 99 100 101 102 103 104
  remove_configs = []
  no_default_deps = []
  install_images = []
  install_enable = [boolean]
  symlink_target_name = []
  version_script = []
  use_exceptions = []
}
```

A
Annie_wang 已提交
105
**ohos_static_library** example
A
Annie_wang 已提交
106 107 108 109

```shell
import("//build/ohos.gni")
ohos_static_library("helloworld") {
A
Annie_wang 已提交
110
  sources = ["file"]            # .c files.
A
Annie_wang 已提交
111 112 113 114 115 116 117 118
  include_dirs = ["dir"]        # Directories to be included.
  configs = []                  # Configuration.
  deps = []                     # Define dependent modules that belong to the same component.
  part_name = [string]          # Component name.
  subsystem_name = [string]     # Subsystem name.
  cflags = []

  external_deps = [             # Define dependent modules that belong to different components.
A
Annie_wang 已提交
119 120
  "part_name:module_name",      # The value is in the Component_name:Module_name format.
  ]                             # The dependent modules must be declared in inner_kits by the dependent component.
A
Annie_wang 已提交
121 122 123

  lib_dirs = []
  public_configs = []
A
Annie_wang 已提交
124 125 126 127

  # Sanitizer configuration. Each item is optional, and set to false or left unspecified by default.
  sanitize = {
    # Sanitizer settings
A
Annie_wang 已提交
128
    cfi = [boolean]               # Whether to enable the control-flow integrity (CFI) check.
A
Annie_wang 已提交
129 130
    cfi_cross_dso = [boolean]     # Whether to enable the cross-DSO CFI check.
    integer_overflow = [boolean]  # Whether to enable the integer overflow check.
A
Annie_wang 已提交
131 132
    boundary_sanitize = [boolean] # Whether to enable the boundary check.
    ubsan = [boolean]             # Whether to enable some Undefined Behavior Sanitizer (UBSAN) options.
A
Annie_wang 已提交
133 134 135 136 137 138 139
    all_ubsan = [boolean]         # Whether to enable all UBSAN options.
    ...

    debug = [boolean]             # Whether to enable the debug mode.
    blocklist = [string]          # Path of the blocklist.
  }

A
Annie_wang 已提交
140 141
  remove_configs = []
  no_default_deps = []
A
Annie_wang 已提交
142
  license_file = []               # A .txt file.
A
Annie_wang 已提交
143 144 145 146 147 148 149 150 151 152
  license_as_sources = []
  use_exceptions = []
}
```

**ohos_executable** example:

```shell
import("//build/ohos.gni")
ohos_executable("helloworld") {
A
Annie_wang 已提交
153
  configs = []                       # Configuration.
A
Annie_wang 已提交
154 155 156 157 158
  part_name = [string]               # Component name.
  subsystem_name = [string]          # Subsystem name.
  deps = []                          # Define dependent modules that belong to the same component.

  external_deps = [                  # Define dependent modules that belong to different components.
A
Annie_wang 已提交
159 160
  "part_name:module_name",           # The value is in the Component_name:Module_name format.
  ]                                  # The dependent modules must be declared in inner_kits by the dependent component.
A
Annie_wang 已提交
161 162
  ohos_test = []
  test_output_dir = []
A
Annie_wang 已提交
163 164 165 166

  # Sanitizer configuration. Each item is optional, and set to false or left unspecified by default.
  sanitize = {
    # Sanitizer settings
A
Annie_wang 已提交
167
    cfi = [boolean]               # Whether to enable the control-flow integrity (CFI) check.
A
Annie_wang 已提交
168 169
    cfi_cross_dso = [boolean]     # Whether to enable the cross-DSO CFI check.
    integer_overflow = [boolean]  # Whether to enable the integer overflow check.
A
Annie_wang 已提交
170
    boundary_sanitize = [boolean] # Whether to enable the boundary check.
A
Annie_wang 已提交
171 172 173 174 175 176 177 178
    ubsan = [boolean]             # Whether to enable some Undefined Behavior Sanitizer (UBSAN) options.
    all_ubsan = [boolean]         # Whether to enable all UBSAN options.
    ...

    debug = [boolean]             # Whether to enable the debug mode.
    blocklist = [string]          # Path of the blocklist.
  }

A
Annie_wang 已提交
179 180
  testonly = [boolean]
  license_as_sources = []
A
Annie_wang 已提交
181
  license_file = []               # A .txt file.
A
Annie_wang 已提交
182 183 184
  remove_configs = []
  static_link = []
  install_images = []
A
Annie_wang 已提交
185
  module_install_dir = []         # Module installation directory, starting from system/ or vendor/.
A
Annie_wang 已提交
186 187
  relative_install_dir = []
  symlink_target_name = []
A
Annie_wang 已提交
188
  output_dir = [directory]        # Directory in which output files are located.
A
Annie_wang 已提交
189 190 191 192 193 194
  install_enable = [boolean]
  version_script = []
  use_exceptions = []
}
```

A
Annie_wang 已提交
195
**ohos_source_set** example
A
Annie_wang 已提交
196 197 198 199

```shell
import("//build/ohos.gni")
ohos_source_set("helloworld") {
A
Annie_wang 已提交
200 201 202 203
  sources = ["file"]              # .c files.
  include_dirs = []               # Directories to be included.
  configs = []                    # Configuration.
  public = []                     # .h header files.
A
Annie_wang 已提交
204 205
  defines = []
  public_configs = []
A
Annie_wang 已提交
206 207 208
  part_name = [string]            # Component name.
  subsystem_name = [string]       # Subsystem name.
  deps = []                       # Define dependent modules that belong to the same component.
A
Annie_wang 已提交
209

A
Annie_wang 已提交
210 211 212
  external_deps = [               # Define dependent modules that belong to different components.
  "part_name:module_name",        # The value is in the Component_name:Module_name format.
  ]                               # The dependent modules must be declared in inner_kits by the dependent component.
A
Annie_wang 已提交
213 214 215 216

  # Sanitizer configuration. Each item is optional, and set to false or left unspecified by default.
  sanitize = {
    # Sanitizer settings
A
Annie_wang 已提交
217
    cfi = [boolean]               # Whether to enable the control-flow integrity (CFI) check.
A
Annie_wang 已提交
218 219
    cfi_cross_dso = [boolean]     # Whether to enable the cross-DSO CFI check.
    integer_overflow = [boolean]  # Whether to enable the integer overflow check.
A
Annie_wang 已提交
220
    boundary_sanitize = [boolean] # Whether to enable the boundary check.
A
Annie_wang 已提交
221 222 223 224 225 226 227 228
    ubsan = [boolean]             # Whether to enable some Undefined Behavior Sanitizer (UBSAN) options.
    all_ubsan = [boolean]         # Whether to enable all UBSAN options.
    ...

    debug = [boolean]             # Whether to enable the debug mode.
    blocklist = [string]          # Path of the blocklist.
  }

A
Annie_wang 已提交
229 230 231 232 233
  testonly = [boolean]
  license_as_sources = []
  license_file = []
  remove_configs = []
  no_default_deps = []
A
Annie_wang 已提交
234
  license_file = []               # A .txt file.
A
Annie_wang 已提交
235 236 237 238 239
  license_as_sources = []
  use_exceptions = []
}
```

A
Annie_wang 已提交
240 241 242
**NOTE**<br>
  - Only **sources** and **part_name** are mandatory.
  - For details about the Sanitizer configuration, see [Using Sanitizer](subsys-build-reference.md#using-sanitizer).
A
Annie_wang 已提交
243

A
Annie_wang 已提交
244
### Prebuilt Template Example
A
Annie_wang 已提交
245 246 247

The .gni file of the prebuilt templates is located in **openharmony/build/templates/cxx/prebuilt.gni**.

A
Annie_wang 已提交
248
**ohos_prebuilt_executable** example
A
Annie_wang 已提交
249 250 251 252

```shell
import("//build/ohos.gni")
ohos_prebuilt_executable("helloworld") {
A
Annie_wang 已提交
253
  sources = ["file"]                   # Source.
A
Annie_wang 已提交
254
  output = []
A
Annie_wang 已提交
255
  install_enable = [boolean]
A
Annie_wang 已提交
256

A
Annie_wang 已提交
257
  deps = []                            # Define dependent modules that belong to the same component.
A
Annie_wang 已提交
258
  public_configs = []
A
Annie_wang 已提交
259 260
  subsystem_name = [string]            # Subsystem name.
  part_name = [string]                 # Component name.
A
Annie_wang 已提交
261 262 263 264 265

  testonly = [boolean]
  visibility = []

  install_images = []
A
Annie_wang 已提交
266 267
  module_install_dir = []              # Module installation directory, starting from system/ or vendor/.
  relative_install_dir = []            # Relative module installation directory (relative to system/etc). If module_install_dir is configured, the parameter does not take effect.
A
Annie_wang 已提交
268 269 270
  symlink_target_name = []


A
Annie_wang 已提交
271
  license_file = []                    # A .txt file.
A
Annie_wang 已提交
272 273 274 275
  license_as_sources = []
}
```

A
Annie_wang 已提交
276
**ohos_prebuilt_shared_library** example
A
Annie_wang 已提交
277 278 279 280

```shell
import("//build/ohos.gni")
ohos_prebuilt_shared_library("helloworld") {
A
Annie_wang 已提交
281
  sources = ["file"]                 # .so files.
A
Annie_wang 已提交
282 283 284
  output = []
  install_enable = [boolean]

A
Annie_wang 已提交
285
  deps = []                          # Define dependent modules that belong to the same component.
A
Annie_wang 已提交
286
  public_configs = []
A
Annie_wang 已提交
287 288
  subsystem_name = [string]          # Subsystem name.
  part_name = [string]               # Component name.
A
Annie_wang 已提交
289 290 291 292 293

  testonly = [boolean]
  visibility = []

  install_images = []
A
Annie_wang 已提交
294 295
  module_install_dir = []            # Module installation directory, starting from system/ or vendor/.
  relative_install_dir = []          # Relative module installation directory (relative to system/etc). If module_install_dir is configured, the parameter does not take effect.
A
Annie_wang 已提交
296 297 298
  symlink_target_name = [string]


A
Annie_wang 已提交
299
  license_file = [string]            # A .txt file.
A
Annie_wang 已提交
300 301 302 303
  license_as_sources = []
}
```

A
Annie_wang 已提交
304
**ohos_prebuilt_static_library** example
A
Annie_wang 已提交
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324

```shell
import("//build/ohos.gni")
ohos_prebuilt_static_library("helloworld") {
  sources = ["file"]              # .so files.
  output = []

  deps = []                       # Define dependent modules that belong to the same component.
  public_configs = []
  subsystem_name = [string]       # Subsystem name.
  part_name = [string]            # Component name.

  testonly = [boolean]
  visibility = []

  license_file = [string]         # A .txt file.
  license_as_sources = []
}
```

A
Annie_wang 已提交
325
![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: Only **sources** and **part_name** are mandatory.
A
Annie_wang 已提交
326 327 328

### HAP Templates

A
Annie_wang 已提交
329
For details about the HAP templates, see [HAP Build Guide](subsys-build-gn-hap-compilation-guide.md).
A
Annie_wang 已提交
330

A
Annie_wang 已提交
331
### Rust Templates
A
Annie_wang 已提交
332

A
Annie_wang 已提交
333
For details about the Rust templates, see [Rust Module Configuration Rules and Guide](subsys-build-rust-compilation.md).
A
Annie_wang 已提交
334 335 336 337 338 339 340 341 342 343

### Other Templates

**ohos_prebuilt_etc** example:

```shell
import("//build/ohos.gni")
ohos_prebuilt_etc("helloworld") {
  # The most common attributes of the ohos_prebuilt_etc template.
  sources = ["file"]
A
Annie_wang 已提交
344 345 346
  module_install_dir = []                 # Module installation directory, starting from system/ or vendor/.
  subsystem_name = [string]               # Subsystem name.
  part_name = [string]                    # (Mandatory) Component name.
A
Annie_wang 已提交
347
  install_images = []
A
Annie_wang 已提交
348
  relative_install_dir = []               # Relative module installation directory (relative to system/etc). If module_install_dir is configured, the parameter does not take effect.
A
Annie_wang 已提交
349 350
  
  # Uncommon attributes of the ohos_prebuilt_etc template:
A
Annie_wang 已提交
351
  deps = []                               # Define dependent modules that belong to the same component.
A
Annie_wang 已提交
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
  testonly = [boolean]
  visibility = []
  public_configs = []
  symlink_target_name = [string]
  license_file = [string]
  license_as_sources = []
}
```

**ohos_sa_profile** example:

```shell
import("//build/ohos.gni")
ohos_sa_profile("helloworld") {
  sources = [".xml"]                   # .xml file.
  part_name = [string]                 # Component name.
  subsystem_name = [string]            # Subsystem name.
}
```

A
Annie_wang 已提交
372
![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: Only **sources** and **part_name** are mandatory.
A
Annie_wang 已提交
373 374 375

## Adding and Building a Module

A
Annie_wang 已提交
376
The following figure shows the logic for adding a module. Generally, you need to add a module to a component of a subsystem. If there is no subsystem or component, you must add the subsystem and component first. Note that the chip solution is a special component and does not have a subsystem.
A
Annie_wang 已提交
377 378 379 380 381 382 383

- Add a module to an existing component.

- Add a module to a new component.

- Add a module to a new subsystem.

384
  ![](figures/module_addition_process.png)
A
Annie_wang 已提交
385 386 387 388 389 390 391 392 393

**Adding a Module to an Existing Component**

1. Configure the **BUILD.gn** file in the module directory and select the GN template.

2. Modify the **bundle.json** file.

   ```shell
   {
A
Annie_wang 已提交
394 395 396 397 398
      "name": "@ohos/<component_name>,                         # HPM component name, in the "@Organization/Component_name" format.
      "description": "xxxxxxxxxxxxxxxxxxx",                    # Description of the component functions.
      "version": "3.1",                                        # Version, which must be the same as the version of OpenHarmony.
      "license": "MIT",                                        # Component license.
      "publishAs": "code-segment",                             # HPM package release mode. The default value is code-segment.
A
Annie_wang 已提交
399 400
      "segment": {
          "destPath": "third_party/nghttp2"
A
Annie_wang 已提交
401 402 403
      },                                                       # Code restoration path (source code path) set when publishAs is code-segment.
      "dirs": {},                                              # Directory structure of the HPM package. This field is mandatory and can be left empty.
      "scripts": {},                                           # Scripts to be executed. This field is mandatory and can be left empty.
A
Annie_wang 已提交
404 405 406 407
      "licensePath": "COPYING",
      "readmePath": {
          "en": "README.rst"
      },
A
Annie_wang 已提交
408 409 410 411 412 413 414 415
      "component": {                                           # Component attributes.
          "name": "<component_name>",                          # Component name.
          "subsystem": "",                                     # Subsystem to which the component belongs.
          "syscap": [],                                        # System capabilities provided by the component for applications.
          "features": [],                                      # List of configurable features of the component. Generally, this parameter corresponds to sub_component in build.
          "adapted_system_type": [],                           # Types of adapted systems. The value can be mini, small, standard, or their combinations.
          "rom": "xxxKB"                                       # ROM baseline. If there is no baseline, enter the current value.
          "ram": "xxxKB",                                      # RAM baseline. If there is no baseline, enter the current value.
A
Annie_wang 已提交
416
          "deps": {
A
Annie_wang 已提交
417 418
              "components": [                                  # Other components on which this component depends.
              "third_party": [                                 # Third-party open-source software on which this component depends.
A
Annie_wang 已提交
419 420
          },
       
A
Annie_wang 已提交
421
          "build": {                                           # Build-related configuration.
A
Annie_wang 已提交
422
              "sub_component": [
A
Annie_wang 已提交
423 424 425 426 427 428
                  "//foundation/arkui/napi:napi_packages",     # Existing module 1.
                  "//foundation/arkui/napi:napi_packages_ndk"  # Existing module 2.
                  "//foundation/arkui/napi:new"                # Module to add.
              ],                                               # Component build entry. Configure the module here.
              "inner_kits": [],                                # APIs between components.
              "test": []                                       # Entry for building the component's test cases.
A
Annie_wang 已提交
429 430 431 432 433
          }
      }
   }
   ```

A
Annie_wang 已提交
434 435 436
   > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
   >
   > The **bundle.json** file must be in the folder of the corresponding subsystem.
A
Annie_wang 已提交
437 438 439 440 441 442 443 444 445

3. Start the build and check whether a .so file or binary file is generated.

**Creating a Component and Adding a Module**

1. Configure the **BUILD.gn** file in the module directory and select the corresponding GN template. Note that **part_name** in the **BUILD.gn** file is the name of the component to add.

2. Create a **bundle.json** file in the folder of the corresponding subsystem.

A
Annie_wang 已提交
446
3. Add the new component to the end of existing components in **vendor/{product_company}/{product-name}/config.json**.
A
Annie_wang 已提交
447 448 449 450 451 452

   ```shell
    "subsystems": [
         {
           "subsystem": "Subsystem to which the component belongs",
           "components": [
A
Annie_wang 已提交
453 454 455
             {"component": "Component 1 name", "features":[]},        # Existing component 1 in the subsystem
             { "component": "Component 2 name", "features":[] },      # Existing component 2 in the subsystem
             {"component": "New component name", "features":[]}       # New component in the subsystem
A
Annie_wang 已提交
456 457 458 459 460 461 462 463 464 465 466
           ]
         },
         .
    ]
   ```

4. Start the build and check whether a .so file or binary file is generated.
   

**Creating a Subsystem and Adding a Module**

A
Annie_wang 已提交
467
1. Configure the **BUILD.gn** file in the module directory and select the corresponding GN template. This step is the same as Step 1 in "Creating a Component and Adding a Module."
A
Annie_wang 已提交
468

A
Annie_wang 已提交
469
2. Create a **bundle.json** file in the folder of the component of the subsystem. This step is the same as Step 2 in "Creating a Component and Adding a Module."
A
Annie_wang 已提交
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492

3. Modify the **subsystem_config.json** file in the **build** directory.

   ```shell
   {
    "Subsystem 1 name": {                     # Existing subsystem 1
      "path": "Subsystem 1 directory",
      "name": "Subsystem 1 name"
    },
     "Subsystem 2 name": {                    # Existing subsystem 2
      "path": "Subsystem 2 directory",
      "name": "Subsystem 2 name"
    },
    "Subsystem name new": {                   # Subsystem to add
      "path": "New subsystem directory",
      "name": "New subsystem name"
    },
   
   }
   ```

   The **subsystem_config.json** file defines the subsystems and their directories. When adding a subsystem, specify **path** and **name** for the subsystem.

A
Annie_wang 已提交
493
4. If **product-name** in the **vendor/{product_company}/{product-name}** directory is **hispark_taurus_standard**, add the new component information to the end of existing components in the **config.json** file.
A
Annie_wang 已提交
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514

   ```shell
   "subsystems": [
     {
       "subsystem": "arkui",                      # Name of the existing subsystem
       "components": [                            # All components of the subsystem
         {
           "component": "ace_engine_standard",    # Name of the existing component
           "features": []
         },
         {
           "component": "napi",                   # Name of the existing component
           "features": []
         }
          {
           "component": "component_new1",         # Name of the new component to add
           "features": []
         }
      ]
     },
     {
A
Annie_wang 已提交
515
       "subsystem": "subsystem_new",              # Name of the new subsystem to add.
A
Annie_wang 已提交
516 517 518 519 520 521 522 523 524 525 526 527 528
       "components": [
         {
           "component": "component_new2",         # Name of the component to be added to the new subsystem
           "features": []
         }
       ]
     },
    
    ]
   ```

4. Start the build and check whether a .so file or binary file is generated.

A
Annie_wang 已提交
529

A
Annie_wang 已提交
530 531 532 533
**Building a Module**

You can start the build by using the [CLI or hb tool](subsys-build-all.md#build-commands). The following uses the CLI as an example:

A
Annie_wang 已提交
534
   You can run the **--build-target** *Module_name* command to build a module separately.
A
Annie_wang 已提交
535

A
Annie_wang 已提交
536 537 538
   ```shell
   ./build.sh --build-target Module_name
   ```
A
Annie_wang 已提交
539

A
Annie_wang 已提交
540
   You can also build a product. For example, to build hispark_taurus_standard, run the following command:
A
Annie_wang 已提交
541

A
Annie_wang 已提交
542 543 544
   ```shell
   ./build.sh --product-name hispark_taurus_standard --build-target Module_name --ccache
   ```
A
Annie_wang 已提交
545

A
Annie_wang 已提交
546
   You can also build the component to which the module belongs.
A
Annie_wang 已提交
547

A
Annie_wang 已提交
548 549 550
   ```shell
   ./build.sh --product-name hispark_taurus_standard --build-target musl --build-target Module_name --ccache
   ```