当前位置:网站首页>#Summer Challenge#[FFH] OpenHarmony Device Development Foundation (3) Compilation Dependencies
#Summer Challenge#[FFH] OpenHarmony Device Development Foundation (3) Compilation Dependencies
2022-08-02 12:15:00 【51CTO】
一、前言
This article will make a brief introduction of lightweight and small system USES to compile tools,Detailed interpretation of the new module after compiling rely on three configurations of the way.
<br>
二、gn和ninja
Lightweight and small system is a based ongn和ninja的构建系统,以支持OpenHarmony组件化开发为目标,Support components assembled product and compile,Independent build chip solution source,独立构建单个组件.After the completion of the new component development,需要基于gnGrammar configuration to build information,并保存在BUILD.gn文件中.You can use in this article further understand HongMeng tang teacherGn和Ninja: The HongMeng of shallowGn与Ninja
<br>
三、开发准备
You can refer to this article is not yet installed the development environmentstep by step进行配置:
DevEco Device ToolOne-stop integrated development environment to build
From the source to obtain,编译,Burn to a serial port debug one-stop integrated development,可以参考这篇:
DevEco Device ToolEquipment development summary of the whole process
After more than ready to,I believe you have been able to easily compile engineering、Code burning etc and run through the whole process.After the above work is prepared to do to get into the link to the development.
其实,Function development is generally familiar with everybody,In addition to the use of the new interface,Technically don't have much difficulty,Most of the time are in the original function.功能开发完成后,How to integrate into the system,应该是大家比较关心的问题,这也是OpenHarmonyEquipment development different from other embedded development different places.
<br>
四、Compile rely on three configurations of the way
首先,Let's understand the compilation and compile rely on.简单来说,Compile time dependent module or code will be involved in the compiling,OpenHarmonyThe introduction of dependence has the following three ways:
- 产品配置config.jsonAdd components depend on.
- 已有模块BUILD.gn中depsConfigure components depend on.
- Existing module to add the source code path,By introducing rely on file.
Next we need to add a component first presentation components depend on the configuration and file depends on the configuration of the
在applications/sample/wifi-iot/app目录下增加my_first_demo组件,配置如下图:
demo01.c代码如下
显然,CFiles are compiled three dependent way needs to be,Related to the functional development.
接下来,Let us one by one to analyze the three compile depend on the way.
1.产品配置config.jsonAdd components depend on
首先,We need to write for the business to build into a static library BUILD.gn 文件.demo001Is the static library name(后面会用到):
BUILD.gnIs to build a profile,Defines the build targets,Is the first two components depend on the way to some.So the component directory became so
From the point of view of equipment development,We add the function of general belongs to the application layer,Typically configured in application subsystem information stored in theapplications.json中,如下图左半部分所示.To when building products can form depends on themy_first_demoComponents together compile in,我们需要在config.jsonThe configuration subsystem depend on,Add below information of the blue circle.
The file path and look for the above points to corresponding relation.
上篇文章我们介绍过config.jsonIs product solutions for building entrance,Product solutions required components will be involved in the compilation process.所以在config.jsonThe configuration subsystem and component information can makemy_first_demoEngineering involved in the compilation process,And packed into the firmware.
但是,Every time we create a project to change the code to run toconfig.jsonTo modify,而config.jsonAlso can not directly modify,File open layers to findapplication.jsonTo find the corresponding components after modify the target file location,Just to watch the arrow above the file directory and should know the process is a little trouble
其实,There are some tutorial provides a simple solution:
例如,In even the teacher《OpenHarmonyIntroduction to equipment development》书中的HelloWorldRoutine is inapp模块BUILD.gnFile to compile rely on configuration,在features字段中增加索引,使目标模块参与编译.
图源《OpenHarmonyEquipment to develop the first》
If according to the format of the relative path is write so:
同时,Don't forget to delete the blue words in that way in front of the circle part of yo!
At this time a very smooth figure can rely on to organize a
When we understand the process,To write a similar procedure can be in the moduleapp的BUILD.gnAdd a short line of“组件名:静态库名称”即可了,Is it a lot easier?
Actually mean of the two methods are the same,Just a hierarchy problem,Similar to me in the upper has pointed out the,The lower don't have to detail the way.
<br>
2.已有模块BUILD.gn中depsConfigure components depend on
This way need in existing in translating module configurationdeps依赖.这里以在hal_token_static中增加my_first_demo为例,被依赖的模块my_first_demoWill participate in compiling,And package into the final firmware.
具体步骤为:将之前在app模块BUILD.gn中写的“my_first_demo:demo001”注释掉,右键单击my_first_demoCopy the folder relative path,然后打开
vendor/hisilicon/hispark_pegasus/hals/utils/token/BUILD.gn添加deps:
然后编译,烧录,Check the monitor can getdemo.cThe print statement:
When the control variable deletedepsConfiguration will not have the statement print out.
This way is a kind of implicit reliance on,不难看出,This depend on the way must rely on the compiled module to perform,So only two modules correlation is higher,直接依赖了my_first_demoOnly use this way,Otherwise is recommended to use the above way.
<br>
3.Existing module to add the source code path,By introducing rely on file
The last one is file depend on,是最简单的一种方式,Only need to add the source files in the existing module can participate in compiling.
Again in thehal_token_staticIn the module as an example of operation:
此时,删除了my_first_demo目录下的BUILD.gn文件(可有可无,Anyway, don't use)After successful print out the goal statement!
这种方式,Commonly used in the coupling relationship between larger function,Call each other or more interfaces rely on the strong.At this time can put the files in the same module compiled together,To reduce the complexity of the configuration
五、后记
Reference documentation and tutorials:
OpenHarmony基础
《OpenHarmonyIntroduction to equipment development》
Don't know you read this article,For compiling depend on have a deeper understanding of?
The three methods rely on each have advantages and disadvantages,You might as well every method to test.We need in the future the development process of experience,充分利用好OpenHarmony的模块化、Can cut the advantage of,根据需要进行配置.
这里再提一嘴,I don't allow someone still doesn't workDevEco Device ToolTo south to develop!简直太好用了! Do not believe you see and experience this articleIf not I recently switched to this development environment,Repeatedly jump tools compile burn open serial port and so on,得浪费多少时间啊
总之,希望本文能帮到大家,If you have any consider、不对的地方,欢迎交流探讨~
边栏推荐
- 太厉害了,终于有人能把TCP/IP 协议讲的明明白白了
- Speed up your programs with bitwise operations
- 使用无界队列的线程池会导致内存飙升吗?
- 面积曲线AUC(area under curve)
- npm WARN deprecated [email protected] This version of tar is no longer supported, and will not receive
- 【第六届强网杯CTF-Wp】
- 手撸架构,Redis面试41问
- excel 批量翻译-excel 批量函数公司翻译大全免费
- Transfer files between servers
- Drools(8):WorkBench使用
猜你喜欢
使用mosquitto过程中的问题解决
Free Chinese-English Translation Software - Automatic Batch Chinese-English Translation Software Recommended Daquan
大疆P4M云遮挡矫正
Pytorch 占用cpu资源过多
NVIDIA NeMo Metrics 轻量性能采集系统
7种最常用数据分析思维,解决95%的分析难题
Swift中什么时候不能用 () 代替 Void 来使用
技术分享| 融合调度系统中的电子围栏功能说明
#夏日挑战赛#【FFH】OpenHarmony设备开发基础(三)编译依赖
云原生(三十) | Kubernetes篇之应用商店-Helm介绍
随机推荐
Drools(8):WorkBench使用
An example of type3 voltage loop compensator taking Boost as an example
Create your own app applet ecosystem with applet containers
30行代码实现无服务器实时健康码识别--操作手册
如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?
翻译英语的软件-免费翻译软件-各种语言互相翻译
WPF 实现窗体抖动效果
QAbstractScrollArea、QScrollArea
Idea 全局搜索(idea如何全局搜索关键字)
【第六届强网杯CTF-Wp】
[kali-information collection] (1.9) Metasploit + search engine tool Shodan
npm WARN deprecated [email protected] This version of tar is no longer supported, and will not receive
openresty 性能优化
Lexicon 27 - Remove Elements - Simple Questions
【Acunetix-忘记密码】
面积曲线AUC(area under curve)
使用kubesphere图形界面创建一个devops的CI/CD流程
手撸架构,网络 面试36问
Learning Experience Sharing Seven: YOLOv5 Code Chinese Comments
主流跨端技术一览