Here I take the development board of 3518 as an example to explain, 3516 is also generic.

Below is the previously fully compiled script

python build.py ipcamera_hi3518ev300 -b debug
Copy the code

HarmonyOS initially only supported full compilation. The biggest downside of this approach was that we developed a user-mode application on the source code of the system, which required us to compile and burn the image each time. Each compilation and burn took at least 15 minutes. Imagine the hassle of adding a row of logs every time you debug.

HarmonyOS (HarmonyOS) : HarmonyOS (HarmonyOS) : HarmonyOS (HarmonyOS) : HarmonyOS

python build.py ipcamera_hi3518ev300 -T //applications/sample/camera/app:camera_app
Copy the code

Here to separate compilation HarmonyOS bring the HelloWorld project as an example, this -t parameters is very important, it is compiled on behalf of the single module, / / applications/sample/camera/app only to compile the module’s absolute path, Camera_app is the name of the module to compile.

The -t parameter is not supported by HarmonyOS if you downloaded the official Code1.0 source code from HarmonyOS. Let’s see when this parameter is updated to the source repository. First we go to Gitee to find the repository where the build framework resides

We then look at the COMMIT records under the repository to find the key records below

If you look at the commit log, it’s clear that there was a single module build, so let’s open up the commit record and see what was changed

Git git git git git git git git git git git git git git git git git git git

Now let’s talk about the front of the single module compiler at the end of the module name camera_app how to come, about how to compile user mode procedures, I suggest you take a good look at the official source code “user program framework” warehouse under the introduction, will definitely benefit a lot. I pick key here, the first is at / / build/lite/product/ipcamera_hi3518ev300 json this file to the user program compiled relevant configuration, can be understood as a configuration list, tell the system which the user mode application need to participate in the compilation. We can find the following configuration in it

    {
      "name": "applications",
      "component": [
        { "name": "camera", "dir": "//applications/sample/camera/app:camera_app", "features":[] },
        { "name": "communication", "dir": "//applications/sample/camera/communication:sample", "features":[] }
      ]
    },
Copy the code

If you look at the configuration after dir, you might wonder why we used the parameter after -t, but where did the camerA_app parameter after the colon come from?

If you don’t understand the following, you can go to the Makefile and GN knowledge first.

Here each user mode program is compiled through the GN file configuration, we first find the module path in the source directory, as shown below

Haha, you may wonder why I use IDEA to look at the code, because I do not have Source Insight installed on my computer, and I am most proficient in Java and Android technology, so I am used to using IDEA, a quick search function is enough for me to read the source code of the system.

Here we see the build.gn script. If you open it, you can see the following key code:

lite_component("camera_app") {
    target_type = "executable"

    features = [
        ":hello_world",
    ]
}
Copy the code

The parameter module name of the previous call, CamerA_app, is configured here.

A simple example of a standard helloWorld usage for gn is as follows

executable("hello_world") {
  sources = [
    "hello_world.c",
  ]
}
Copy the code

Later I’ll show you how to create a separate user-mode program that will write this GN file and json file. This post is already long enough to be covered in the next blog post.

Look at the system source code is really very interesting, only nai work too busy no time to see…

Author: soft Xia Dewang would like to know more, please visit: 51 cto and huawei officials strategic cooperation HongMeng technology community at https://harmonyos.51cto.com