当前位置:网站首页>#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、不对的地方,欢迎交流探讨~
边栏推荐
- WPF 实现窗体抖动效果
- 分布式限流利器,手撕&redisson实现
- Chapter 14 Manually create a REST service (2)
- [kali-information collection] (1.9) Metasploit + search engine tool Shodan
- Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单。
- Likou 209 - String with the Minimum Length - Sliding Window Method
- #夏日挑战赛#【FFH】OpenHarmony设备开发基础(三)编译依赖
- MD5详解(校验文件完整性)
- openresty 性能优化
- Drools(8):WorkBench使用
猜你喜欢
随机推荐
免费文档翻译-免费批量文档翻译软件推荐
用位运算为你的程序加速
doc2vec和word2vec(zigbee简介及应用)
Pod调度策略:亲和性、污点与污点容忍
自己如何做小程序呢?
SQL函数 TRIM
太厉害了,终于有人能把TCP/IP 协议讲的明明白白了
Running yum reports Error: Cannot retrieve metalink for reposit
JSP中如何正确的填写include指令中的file路径呢?
大疆P4M云遮挡矫正
从幻核疑似裁撤看如何保证NFT的安全
Technology sharing | Description of the electronic fence function in the integrated dispatching system
手撸架构,网络 面试36问
力扣27-移除元素——简单题
雷克萨斯,锁死的安全,挡不住的心寒
npm run dev 和 npm run serve区别
Solve the problem of Chinese garbled characters in exporting excel file names
np.nan, np.isnan, None, pd.isnull, pd.isna 整理与小结
记录代码
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!