鴻蒙系統怎么快速編譯


  1. hb build -f是全量編譯,有近2k文件,編譯速度非常慢
  2. 我使用的嵌入式板子是Hi3518EV300,編譯過程中我發現了很多test也參與了編譯,這些在對於非硬件驅動開發工程師來講不需要。故 把此部分干掉會節省很多時間。修改如下文件/vendor/hisilicon/hispark_aries/config.json把子系統test刪除,你會發現編譯文件數量立即降到1k以內,我配置的config.json如下:
{
    "product_name": "ipcamera_hispark_aries",
    "ohos_version": "OpenHarmony 1.0",
    "device_company": "hisilicon",
    "board": "hispark_aries",
    "kernel_type": "liteos_a",
    "kernel_version": "",
    "subsystems": [
      {
        "subsystem": "aafwk",
        "components": [
          { "component": "ability", "features":[ "enable_ohos_appexecfwk_feature_ability = false" ] }
        ]
      },
      {
        "subsystem": "applications",
        "components": [
          { "component": "test_app", "features":[] }
        ]
      },
      {
        "subsystem": "hiviewdfx",
        "components": [
          { "component": "hilog", "features":[] }
        ]
      },
      {
        "subsystem": "distributed_schedule",
        "components": [
          { "component": "system_ability_manager", "features":[] },
          { "component": "foundation", "features":[] },
          { "component": "distributed_schedule", "features":[] }
        ]
      },
      {
        "subsystem": "security",
        "components": [
          { "component": "hichainsdk", "features":[] },
          { "component": "permission", "features":[] },
          { "component": "app_verify", "features":[] }
        ]
      },
      {
        "subsystem": "graphic",
        "components": [
          { "component": "graphic_utils", "features":[] },
          { "component": "surface", "features":[] }
        ]
      },
      {
        "subsystem": "startup",
        "components": [
          { "component": "syspara", "features":[] },
          { "component": "bootstrap", "features":[] },
          { "component": "init", "features":[] },
          { "component": "appspawn", "features":[] }
        ]
      },
      {
        "subsystem": "kernel",
        "components": [
          { "component": "liteos_a", "features":[] }
        ]
      },
      {
        "subsystem": "communication",
        "components": [
          { "component": "ipc", "features":[] },
          { "component": "soft_bus", "features":[] },
          { "component": "wpa_supplicant", "features":[] }
        ]
      },
      {
        "subsystem": "drivers",
        "components": [
          { "component": "adapter_uhdf", "features":[] },
          { "component": "peripheral_display", "features":[] },
          { "component": "peripheral_input", "features":[] },
          { "component": "peripheral_wlan", "features":[] }
        ]
      },
      {
        "subsystem": "appexecfwk",
        "components": [
          { "component": "bundle_mgr", "features":[] }
        ]
      },
      {
        "subsystem": "utils",
        "components": [
          { "component": "kv_store", "features":[] },
          { "component": "os_dump", "features":[] }
        ]
      },
      {
        "subsystem": "vendor",
        "components": [
          { "component": "middleware", "features":[] },
          { "component": "hi3518ev300_init", "features":[] },
          { "component": "hardware", "features":[] }
        ]
      }
    ],
    "vendor_adapter_dir": "//device/hisilicon/hardware",
    "third_party_dir": "//third_party",
    "product_adapter_dir": "//vendor/hisilicon/hispark_aries/hals",
    "ohos_product_type":"",
    "ohos_manufacture":"",
    "ohos_brand":"",
    "ohos_market_name":"",
    "ohos_product_series":"",
    "ohos_product_model":"",
    "ohos_software_model":"",
    "ohos_hardware_model":"",
    "ohos_hardware_profile":"",
    "ohos_serial":"",
    "ohos_bootloader_version":"",
    "ohos_secure_patch_level":"",
    "ohos_abi_list":""
  }

applications子系統是我自己寫的測試demo,我把ai_server和media_server全部刪除了,因為我這個dmeo不需要

  1. /vendor/hisilicon/hispark_aries/init_configs/init_liteos_a_3518ev300.cfg是系統啟動后,init進程拉起的進程配置,配置如下:
{
    "jobs" : [{
            "name" : "pre-init",
            "cmds" : [
                "mkdir /storage/data/log",
                "chmod 0755 /storage/data/log",
                "chown 4 4 /storage/data/log",
                "loadcfg /patch/fstab.cfg",
                "mkdir /storage/data/softbus",
                "chmod 0700 /storage/data/softbus",
                "chown 7 7 /storage/data/softbus",
                "mkdir /sdcard",
                "chmod 0777 /sdcard",
                "mount vfat /dev/mmcblk0 /sdcard rw,umask=000",
                "mount vfat /dev/mmcblk1 /sdcard rw,umask=000"
            ]
        }, {
            "name" : "init",
            "cmds" : [
                "start shell",
                "start apphilogcat",
                "start foundation",
                "start bundle_daemon",
                "start appspawn",
                "start hiview"
            ]
        }, {
            "name" : "post-init",
            "cmds" : [
                "chown 0 99 /dev/hdf/dev_mgr",
                "chown 0 99 /dev/hdf/hdfwifi",
                "chown 0 99 /dev/gpio",
                "chown 0 99 /dev/i2c-0",
                "chown 0 99 /dev/i2c-1",
                "chown 0 99 /dev/i2c-2",
                "chown 0 99 /dev/uartdev-0",
                "chown 0 99 /dev/uartdev-1",
                "chown 0 99 /dev/uartdev-2",
                "chown 0 99 /dev/spidev0.0",
                "chown 0 99 /dev/spidev1.0",
                "chown 0 99 /dev/spidev1.1"
            ]
        }
    ],
    "services" : [{
            "name" : "foundation",
            "path" : ["/bin/foundation"],
            "uid" : 7,
            "gid" : 7,
            "once" : 0,
            "importance" : 1,
            "caps" : [10, 11, 12, 13]
        }, {
            "name" : "shell",
            "path" : ["/bin/shell"],
            "uid" : 2,
            "gid" : 2,
            "once" : 0,
            "importance" : 0,
            "caps" : [4294967295]
        }, {
            "name" : "appspawn",
            "path" : ["/bin/appspawn"],
            "uid" : 1,
            "gid" : 1,
            "once" : 0,
            "importance" : 0,
            "caps" : [2, 6, 7, 8, 11, 23]
        }, {
            "name" : "apphilogcat",
            "path" : ["/bin/apphilogcat"],
            "uid" : 4,
            "gid" : 4,
            "once" : 1,
            "importance" : 0,
            "caps" : []
        }, {
            "name" : "wms_server",
            "path" : ["/bin/wms_server"],
            "uid" : 6,
            "gid" : 6,
            "once" : 1,
            "importance" : 0,
            "caps" : []
        }, {
            "name" : "bundle_daemon",
            "path" : ["/bin/bundle_daemon"],
            "uid" : 8,
            "gid" : 8,
            "once" : 0,
            "importance" : 0,
            "caps" : [0, 1]
        }, {
            "name" : "hiview",
            "path" : ["/bin/hiview"],
            "uid" : 4,
            "gid" : 4,
            "once" : 1,
            "importance" : 0,
            "caps" : []
        }
    ]
}

  1. 這個時候編譯你會發現還是有單元測試的模塊編譯進來如ai service,找到對應的BUILD.gn你會發現原來當編譯是debug系統時會編譯單元測試模塊
import("//build/lite/config/component/lite_component.gni")

# manage all components of aisystem

lite_component("ai") {
  features = [
    "client:client",
    "server:server",
  ]
  if (ohos_build_type == "debug") {
    deps = [ "//foundation/ai/engine/test" ]
  }
}

而我們hb build編譯時默認就是debug,如果編譯release就不會有了,我們執行 hb build -f -b release,發現又少了100多個文件參與編譯,我這邊編譯一次系統只有600多個文件了,速度比之前快了很多

  1. 另外鴻蒙支持模塊編譯,此模塊對應的名稱在/build/lite/components下面的json文件中,如我只想編譯soft_bus模塊,輸入 hb build soft_bus即可,同時通過修改可以裁剪子系統下面的對應的模塊


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM