前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >zephyr笔记 1.3 开发环境的拓展了解

zephyr笔记 1.3 开发环境的拓展了解

作者头像
twowinter
发布2020-04-17 17:57:06
8060
发布2020-04-17 17:57:06
举报
文章被收录于专栏:twowintertwowinter

1 前言

前一节1.2 软件开发环境准备学习了软件开发环境的搭建,但部分细节还讳莫如深,择日不如撞日,我们赶紧认识一下。本节对编译过程中的 Cmake 和 Ninja 做个拓展了解,这也是官方教程没体现的部分。

我正在学习 Zephyr,一个很可能会用到很多物联网设备上的操作系统,如果你也感兴趣,可点此查看帖子zephyr学习笔记汇总

2 Cmake

Build 过程中有用到 Cmake 命令来配置生成 Ninja 编译所需的文件。

代码语言:javascript
复制
# Use cmake to configure a Ninja-based build system:
cmake -GNinja -DBOARD=nrf52_pca10040 ..

使用 Ninja 时需要生成 build.ninja 文件,对于大型项目来说一条一条地写配置文件是不可能的,可以使用Cmake来生成这个配置文件。

Cmake支持参数Camke -G Ninja,Cmake会根据用户给定的CMakeLists.txt来生成build.ninja文件,接着才能进行ninja编译。

CmakeLists文件的语法这里写不深究,结合build日志感受下。

代码语言:javascript
复制
D:\zephyr_path\zephyr\samples\basic\blinky\build>cmake -GNinja -DBOARD=nucleo_l073rz ..
CMake Deprecation Warning at D:/winter/resources/zephyr/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):
  The OLD behavior for policy CMP0000 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:1 (include)


-- Selected BOARD nucleo_l073rz
Zephyr version: 1.11.99
Parsing Kconfig tree in D:/winter/resources/zephyr/zephyr//Kconfig
Using D:/zephyr_path/zephyr/samples/basic/blinky/build/zephyr/.config as base
-- Generating zephyr/include/generated/generated_dts_board.h
nucleo_l073rz.dts_compiled: Warning (unit_address_vs_reg): Node /soc/pin-controller has a reg or ranges property, but no unit name
nucleo_l073rz.dts_compiled: Warning (unit_address_vs_reg): Node /soc/pin-controller/usart1@0 has a unit name, but no reg property
nucleo_l073rz.dts_compiled: Warning (unit_address_vs_reg): Node /soc/pin-controller/usart2@0 has a unit name, but no reg property
-- Configuring done
-- Generating done
-- Build files have been written to: D:/zephyr_path/zephyr/samples/basic/blinky/build

在 /zephyr/samples/basic/blinky/build 目录下,就看到了一堆 build 所需的文件。

3 ninja的基础用法

Ninja 官网点击这里。

不过我们使用 ninja -help 命令,也能看到 Ninja 常见命令,如下:

代码语言:javascript
复制
Cleaning targets:
  clean     - Remove most generated files but keep configuration and backup files
  pristine  - Remove all files in the build directory

Configuration targets:

  run <ninja kconfig-usage>

Other generic targets:
  all          - Build a zephyr application
  run          - Build a zephyr application and run it if the board supports emulation
  flash        - Build and flash an application
  debug        - Build and debug an application using GDB
  debugserver  - Build and start a GDB server (port 1234 for Qemu targets)
  ram_report   - Build and create RAM usage report
  rom_report   - Build and create ROM usage report
  usage        - Display this text

特别是 pristine 命令,如果工程要切换 board,那么就需要这么做。

4 总结

这篇笔记对工程编译用到的 Cmake 和 Ninja 做了个简单了解。

End

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 前言
  • 2 Cmake
  • 3 ninja的基础用法
  • 4 总结
  • End
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档