当前位置: 首页 > news >正文

makefile - NXP - busybox环境下makefile中调用系统命令的方法

文章目录

    • makefile - NXP - busybox环境下makefile中调用系统命令的方法
    • 概述
    • 笔记
    • 环境准备
    • 用一个makefile来实验
    • END

makefile - NXP - busybox环境下makefile中调用系统命令的方法

概述

前面实验(debug - MCUXpresso - 从NXP工程做一个makefile工程出来), 在makefile中居然不能调用clear命令,好惊讶。

刚才搞明白了,在busybox环境下,clear命令都是busybox的内建命令,并不是一个外部命令(没法找到clear.exe)。必须用busybox来调用clear命令。

笔记

环境准备

用的是MCUXpresso的命令行编译环境

@echo off
rem @file mcu_expresso_cmd_env.bat
rem @breif MCUXpresso IDE v25.6.136 的命令行环境
set path=C:\nxp\MCUXpressoIDE_25.6.136\ide\plugins\com.nxp.mcuxpresso.tools.win32_25.6.0.202501151204\buildtools\bin;%path%
set path=C:\nxp\MCUXpressoIDE_25.6.136\ide\plugins\com.nxp.mcuxpresso.tools.win32_25.6.0.202501151204\tools\bin;%path%
cmd /k "sh"

运行mcu_expresso_cmd_env.bat, 看一下sh的版本

D:/my_dev/my_test/nxp-build-test/v0.1 $ where sh
C:\nxp\MCUXpressoIDE_25.6.136\ide\plugins\com.nxp.mcuxpresso.tools.win32_25.6.0.202501151204\buildtools\bin\sh.exe
D:/my_dev/my_test/nxp-build-test/v0.1 $ sh --help
BusyBox v1.37.0.git (2023-11-14 08:47:30 UTC)Usage: sh [-il] [-|+Cabefmnuvx] [-|+o OPT]... [-c 'SCRIPT' [ARG0 ARGS] | FILE ARGS | -s ARGS]Unix shell interpreter

可知,nxp中用的sh, 是busybox的一个程序。

在这里插入图片描述
在sh环境中,用clear命令来清屏,是可以的。
找clear在哪来?找不到,说明clear命令是一个busybox内部命令。也有可能是win10 cmd的一个内建命令。

D:/my_dev/my_test/nxp-build-test/v0.1 $ where clear
信息: 用提供的模式无法找到文件。
D:/my_dev/my_test/nxp-build-test/v0.1 $ where where
C:\Windows\System32\where.exe

但是在makefile中调用clear, 会失败的。
在这里插入图片描述
这说明,在makefile中调用的命令,都是外部命令才行。
因为sh就是一个busybox环境下的程序,那么看看busybox有哪些内部命令

D:/my_dev/my_test/nxp-build-test/v0.1 $ where sh
C:\nxp\MCUXpressoIDE_25.6.136\ide\plugins\com.nxp.mcuxpresso.tools.win32_25.6.0.202501151204\buildtools\bin\sh.exe
D:/my_dev/my_test/nxp-build-test/v0.1 $ ls C:\nxp\MCUXpressoIDE_25.6.136\ide\plugins\com.nxp.mcuxpresso.tools.win32_25.6.0.202501151204\buildtools\bin
ls: C:nxpMCUXpressoIDE_25.6.136idepluginscom.nxp.mcuxpresso.tools.win32_25.6.0.202501151204buildtoolsbin: No such file or directory
D:/my_dev/my_test/nxp-build-test/v0.1 $ busybox --help
BusyBox v1.37.0.git (2023-11-14 08:47:30 UTC)
(glob)
D:/my_dev/my_test/nxp-build-test/v0.1 $ busybox --help
BusyBox v1.37.0.git (2023-11-14 08:47:30 UTC)
(glob)BusyBox is copyrighted by many authors between 1998-2023.
Licensed under GPLv2. See source distribution for detailed
copyright notices.Usage: busybox [function [arguments]...]or: busybox --list[-full]or: busybox --install [-s] [-u|DIR]or: busybox --uninstall [-n] fileor: function [arguments]...BusyBox is a multi-call binary that combines many common Unixutilities into a single executable.  The shell in this buildis configured to run built-in utilities without $PATH search.You don't need to install a link to busybox for each utility.To run external program, use full path (/sbin/ip instead of ip).Currently defined functions:[, [[, ar, arch, ascii, ash, awk, base32, base64, basename, bash, bc, bunzip2, busybox, bzcat, bzip2, cal, cat,cdrop, chattr, chmod, cksum, clear, cmp, comm, cp, cpio, crc32, cut, date, dc, dd, df, diff, dirname, dos2unix,dpkg, dpkg-deb, drop, du, echo, ed, egrep, env, expand, expr, factor, false, fgrep, find, fold, free, fsync,ftpget, ftpput, getopt, grep, groups, gunzip, gzip, hd, head, hexdump, httpd, iconv, id, inotifyd, install,ipcalc, jn, kill, killall, less, link, ln, logname, ls, lsattr, lzcat, lzma, lzop, lzopcat, man, md5sum, mkdir,mktemp, mv, nc, nl, nproc, od, paste, patch, pdrop, pgrep, pidof, pipe_progress, pkill, printenv, printf, ps,pwd, readlink, realpath, reset, rev, rm, rmdir, rpm, rpm2cpio, sed, seq, sh, sha1sum, sha256sum, sha3sum,sha512sum, shred, shuf, sleep, sort, split, ssl_client, stat, strings, su, sum, sync, tac, tail, tar, tee,test, time, timeout, touch, tr, true, truncate, ts, tsort, ttysize, uname, uncompress, unexpand, uniq,unix2dos, unlink, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vi, watch, wc, wget, which,whoami, whois, xargs, xxd, xz, xzcat, yes, zcat
D:/my_dev/my_test/nxp-build-test/v0.1 $

可以看到busybox有内建的clear命令

那就可以在makefile中调用 busybox clear, 而不是直接调用clear. 其他busybox内建命令同理。

用一个makefile来实验

# @file makefile
# @brief 从build.bat进化出来的makefile
#	v0.1 最简单的makefile, 从.bat直接改过来# makefile_obj : depend(可选)
#	action
# makefile_obj从行首开始
# action必须从TAB键开始
# 命令之前加@, 就关掉了echo回显all:@busybox clear
#	clear@echo ----------@echo END@echo ----------

在busyboxy的环境中,执行这个makefile
在这里插入图片描述
在这里插入图片描述
到此,就可以调用系统命令了。但是这些命令不能按照普通的写法,必须用busybox来调用.
等于是这些系统命令,都是busybox实现的内建命令。
在makefile中能执行的命令,都必须是外部命令才行。

END

http://www.dtcms.com/a/499764.html

相关文章:

  • 13 pyflink/scala 进行 csv 文件的批处理
  • java ThreadPoolExecurtor源码解读 --- Worker
  • 20251018在ubuntu24.04下解压缩gz压缩包
  • 做赚钱的网站有哪些园林绿化
  • 静态网站开发用到的技术产品报价网
  • 【小学教辅】新版一年级上册语文第四单元课课贴 一年级语文复韵母学习资料 小学拼音考点练习电子版可下载打印|夸克网盘
  • 企业网站空间不足怎么办商标设计logo免费生成器网站
  • python 字典 列表 类比c++【python】
  • plsql developer 无法跟踪调试
  • Collections 工具类 15 个常用方法源码:sort、binarySearch、reverse、shuffle、unmodifiableXxx
  • mb与使用场景
  • 建设通网站是什么时间成立加入google广告wordpress
  • AI Coding 基础实践01 - TickTalk的MarsCode-Trae AI(Trae 插件)在Pycharm中的配置
  • [SCADE编译原理] 因果性分析原理(2001)
  • 网站建设pc指什么软件佛山新网站建设策划
  • RDEx:一种效果驱动的混合单目标优化器,自适应选择与融合多种算子与策略
  • JavaScript学习第三天:运算符
  • C++进阶之操作符重载函数operator[]:用法实例(四百三十五)
  • 《小白学随机过程》第一章:随机过程——定义和形式(附录2. 随机变量和随机过程公式解读)
  • 近代通信技术的发展
  • 实用网站的设计与实现wordpress简介
  • 如何微信做演讲视频网站Wordpress刷新CDN缓存
  • macos虚拟机-演示篇一制作可启动iso文件
  • 论坛类网站备案今天东营发生的重大新闻
  • Aspect的AOP实现
  • Orleans Stream SubscriptionId 生成机制详解
  • FMIT,一款专业的乐器调音助手
  • 医疗器械招商网站大全建一个信息 类网站
  • 不用域名推广网站开源网站后台管理系统
  • 欧司朗与日亚签署广泛的知识产权协议