当前位置:网站首页>华为云14天鸿蒙设备开发-Day2编译框架
华为云14天鸿蒙设备开发-Day2编译框架
2022-07-29 05:22:00 【Q-Stark】
前言
前两篇搭建好了环境,干了代码。编译的时候,ninja?gn?嘛玩意?这篇简单介绍一下。同时自己也能加深理解。
一、编译框架
ninja简介
在Unix/Linux下通常使用Makefile来控制代码的编译,但是Makefile对于比较大的项目有时候会比较慢,代码在编译都变成了程序员放松的借口了。所以这个Google的程序员在开发Chrome的时候因为忍受不了Makefile的速度,自己重新开发出来一套新的控制编译的工具叫作Ninja,Ninja相对于Makefile这套工具更注重于编译速度。除了Chrome现在还有一些其他的比较大的项目也在开始使用Ninja。
编译相关文件
- 业务源码.c文件:在其中实现功能代码,通过启动恢复模块接口**
APP_FEARTURE_INIT**启动业务,Hello_World作为函数名,用作业务入口。
#include <stdio.h>
#include "ohos_init.h"
void Hello_World(void)
{
printf("Hello World!\r\n");
}
APP_FEATURE_INIT(Hello_World);
APP_FEATURE_INIT()在osoh_init.h文件中定义。
2. 源文件同目录下的业务编译文件BUILD.gn:用于将业务构建成静态库
- static_library中指定业务模块的编译结果,为静态库文件libmyapp.a,开发者根据实际情况完成填写。
- sources中指定静态库.a所依赖的.c文件及其路径,若路径中包含"//“则表示绝对路径(此处为代码根路径),若不包含”//" 则表示相对路径。
- include_dirs中指定source所需要依赖的.h文件路径。
static_library("myapp") {
sources = [
"hello_world.c"
]
include_dirs = [
"//utils/native/lite/include",
]
}
applications\BearPi\BearPi-HM_Nano\sample\BUILD.gn模块构建BUILD.gn文件:指定参与构建的特性模块
- my_app是相对路径,指向./applications/BearPi/BearPi-HM/sample/my_app/BUILD.gn,与自定义文件夹名称保持一致
- myapp是目标,指向./applications/BearPi/BearPi-HM/sample/my_app/BUILD.gn中的static_library(“myapp”)。是静态库名称
import("//build/lite/config/component/lite_component.gni")
lite_component("app") {
features = [
#"A1_kernal_thread:thread_example",
#"A2_kernel_timer:timer_example",
#"A3_kernel_event:event_example",
#"A4_kernel_mutex:mutex_example",
#"A5_kernel_semaphore:semaphore_example",
#"A6_kernel_message:message_example",
#"B1_basic_led_blink:led_example",
"B2_basic_button:button_example",
#"B3_basic_pwm_led:pwm_example",
#"B4_basic_adc:adc_example",
#"B5_basic_i2c_nfc:i2c_example",
#"B6_basic_uart:uart_example",
#"C1_e53_sf1_mq2:e53_sf1_example",
#"C2_e53_ia1_temp_humi_pls:e53_ia1_example",
#"C3_e53_sc1_pls:e53_sc1_example",
#"C4_e53_sc2_axis:e53_sc2_example",
#"C5_e53_is1_infrared:e53_is1_example",
#"D1_iot_wifi_ap:wifi_ap",
#"D2_iot_wifi_sta_connect:wifi_sta_connect",
#"D3_iot_udp_client:udp_client",
#"D4_iot_tcp_server:tcp_server",
#"D5_iot_mqtt:iot_mqtt",
#"D6_iot_cloud_oc:oc_mqtt",
#"D7_iot_cloud_onenet:onenet_mqtt",
#"D8_iot_cloud_oc_smoke:cloud_oc_smoke",
#"D9_iot_cloud_oc_light:cloud_oc_light",
#"D10_iot_cloud_oc_manhole_cover:cloud_oc_manhole_cover",
#"D11_iot_cloud_oc_infrared:cloud_oc_infrared",
#"D12_iot_cloud_oc_agriculture:cloud_oc_agriculture",
#"D13_iot_cloud_oc_gps:cloud_oc_gps",
#"Zx_Developer:zx_develop_sample" ##不参与构建,为开发者贡献演示结构,其中Zx为 Z1,Z2...Z100
#"Z1_hi3861_uart_ylc:uart_hi3861",
#"Z2_hi3861_flash_ylc:flash_example",
#"my_app:myapp",
]
}
build\lite\product\BearPi-HM_Nano.jsonProduct文件夹下的JSON文件
在子系统中说明应用子系统的路径,并链接上述特性模块构建文件
{
"ohos_version": "OpenHarmony 1.0",
"board": "hi3861v100",
"kernel": "liteos_riscv",
"compiler": "gcc",
"subsystem": [
{
"name": "applications",
"component": [
{ "name": "BearPi-HM_Nano", "dir": "//applications/BearPi/BearPi-HM_Nano/sample:app", "features":[] }
]
},
{
"name": "iot_hardware",
"component": [
{ "name": "wifi-iot", "dir": "//base/iot_hardware/frameworks/wifiiot_lite:iothardware", "features":[] }
]
},
{
"name": "hiviewdfx",
"component": [
{ "name": "common_lite", "dir": "//base/hiviewdfx/utils/lite:common_lite", "features":[] },
{ "name": "hiview_lite", "dir": "//base/hiviewdfx/services/hiview_lite:hiview_lite", "features":[] },
{ "name": "hilog_lite", "dir": "//base/hiviewdfx/frameworks/hilog_lite/mini:hilog_lite", "features":[] }
]
},
{
"name": "distributedschedule",
"component": [
{ "name": "samgr_lite", "dir": "//foundation/distributedschedule/services/samgr_lite:samgr", "features":[] }
]
},
{
"name": "security",
"component": [
{ "name": "hichainsdk_lite", "dir": "//base/security/frameworks/hichainsdk_lite:hichainsdk", "features":[] }
]
},
{
"name": "startup",
"component": [
{ "name": "bootstrap_lite", "dir": "//base/startup/services/bootstrap_lite/source:bootstrap", "features":[] },
{ "name": "parameter", "dir": "//base/startup/frameworks/syspara_lite/parameter:parameter", "features":[] },
{ "name": "token", "dir": "//base/startup/frameworks/syspara_lite/token:token", "features":[] }
]
},
{
"name": "communication",
"component": [
{ "name": "wifi_lite", "dir": "//foundation/communication/frameworks/wifi_lite:wifi", "features":[] },
{ "name": "softbus_lite", "dir": "//foundation/communication/services/softbus_lite:softbus", "features":[] }
]
},
{
"name": "utils",
"component": [
{ "name": "kv_store", "dir": "//utils/native/lite/kv_store:kv_store", "features":[] },
{ "name": "file", "dir": "//utils/native/lite/file:file", "features":[] }
]
},
{
"name": "vendor",
"component": [
{ "name": "hi3861_sdk", "dir": "//vendor/hisi/hi3861/hi3861:wifiiot_sdk", "features":[] }
]
},
{
"name": "test",
"component": [
{ "name": "xts_act", "dir": "//test/xts/acts", "features":[] },
{ "name": "xts_tools", "dir": "//test/xts/tools", "features":[] }
]
}
],
"vendor_adapter_dir": "//vendor/hisi/hi3861/hi3861_adapter",
"third_party_dir": "//vendor/hisi/hi3861/hi3861/third_party",
"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":""
}
二、运行入口
vendor\hisi\hi3861\hi3861\app\wifiiot_app\src\app_main.c
base\startup\services\bootstrap_lite\source\system_init.c中
初始化了各个模块,板级支持包等
#include "core_main.h"
#include <ohos_init.h>
#include <samgr_lite.h>
void HOS_SystemInit(void)
{
MODULE_INIT(bsp);
MODULE_INIT(device);
MODULE_INIT(core);
SYS_INIT(service);
SYS_INIT(feature);
MODULE_INIT(run);
SAMGR_Bootstrap();
}
在这个里边一步一步的去看下去就能理解了,文章就不贴了。
边栏推荐
- ML16 neural network (2)
- [tensorrt] convert pytorch into deployable tensorrt
- 一、multiprocessing.pool.RemoteTraceback
- 三、如何搞自定义数据集?
- 6、 Pointer meter recognition based on deep learning key points
- STM32:麦克纳姆轮进行循迹任务(库函数程序代码)
- [convolution kernel design] scaling up your kernels to 31x31: revising large kernel design in CNN
- 迁移学习——Transitive Transfer Learning
- ML6自学笔记
- 1、 What is the difference between transfer learning and fine tuning?
猜你喜欢

Typical case of xdfs & Aerospace Institute HPC cluster

第三周周报 ResNet+ResNext

D3.js vertical relationship diagram (with arrows and text description of connecting lines)

【Transformer】TransMix: Attend to Mix for Vision Transformers

【Transformer】AdaViT: Adaptive Tokens for Efficient Vision Transformer

PyTorch的数据读取机制

Transfer learning

【语义分割】语义分割综述

【Transformer】TransMix: Attend to Mix for Vision Transformers

虚假新闻检测论文阅读(一):Fake News Detection using Semi-Supervised Graph Convolutional Network
随机推荐
2021-06-10
基于STM32开源:磁流体蓝牙音箱(包含源码+PCB)
ML9自学笔记
【卷积核设计】Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs
一、常见损失函数的用法
torch.nn.Parameter()函数理解
【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
迁移学习——Transitive Transfer Learning
【图像分类】如何使用 mmclassification 训练自己的分类模型
【语义分割】语义分割综述
Analysis on the principle of flow
Configuration and use of Nacos external database
【Attention】Visual Attention Network
引入Spacy模块出错—OSError: [E941] Can‘t find model ‘en‘.
ML16-神经网络(2)
ROS常用指令
神经网络相关知识回顾(PyTorch篇)
迁移学习——Transfer Joint Matching for Unsupervised Domain Adaptation
MySQL inserts millions of data (using functions and stored procedures)
ML15-神经网络(1)