当前位置:网站首页>华为云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();
}
在这个里边一步一步的去看下去就能理解了,文章就不贴了。
边栏推荐
- Typical cases of xdfs & China Daily Online Collaborative Editing Platform
- 【Attention】Visual Attention Network
- 【Transformer】ACMix:On the Integration of Self-Attention and Convolution
- Transformer回顾+理解
- Error in installing pyspider under Windows: Please specify --curl dir=/path/to/build/libcurl solution
- ML17-神经网络实战
- The differences and reasons between MySQL with and without quotation marks when querying string types
- 迁移学习——Robust Visual Domain Adaptation with Low-Rank Reconstruction
- 3、 How to read video?
- 二、深度学习数据增强方法汇总
猜你喜欢

【Attention】Visual Attention Network

GAN:生成对抗网络 Generative Adversarial Networks

2022春招——芯动科技FPGA岗技术面(一面心得)

ML9自学笔记

ROS教程(Xavier)

Briefly talk about the difference between pendingintent and intent

The differences and reasons between MySQL with and without quotation marks when querying string types

Are you sure you know the interaction problem of activity?

GA-RPN:引导锚点的建议区域网络

预训练语言模型的使用方法
随机推荐
Continue the new journey and control smart storage together
The third week of postgraduate freshman training: resnet+resnext
Low rank transfer subspace learning
【语义分割】Fully Attentional Network for Semantic Segmentation
【卷积核设计】Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs
ML自学笔记5
逻辑回归-项目实战-信用卡检测任务(下)
ABSA1: Attentional Encoder Network for Targeted Sentiment Classification
[CV] what are the specific numbers of convolution kernels (filters) 3*3, 5*5, 7*7 and 11*11?
6、 Pointer meter recognition based on deep learning key points
D3.js vertical relationship diagram (with arrows and text description of connecting lines)
ML4自学笔记
ROS教程(Xavier)
二、多并发实现接口压力测试
PyTorch中的模型构建
Error in installing pyspider under Windows: Please specify --curl dir=/path/to/build/libcurl solution
一、网页端文件流的传输
Ffmpeg creation GIF expression pack tutorial is coming! Say thank you, brother black fly?
预训练语言模型的使用方法
fastText学习——文本分类