检查makefile中的文件大小,如果文件太短则停止 [英] Checking file size in makefile, stopping if file is too short

查看:364
本文介绍了检查makefile中的文件大小,如果文件太短则停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检查特定文件的大小是否小于某个常数?我在makefile中假设有关大小的事情,并且要确保如果不符合我的假设,我会得到一个错误.类似于assert,但是在makefile中.

Is there a way to check if the size of a particular file is less than some constant? I'm assuming things about size in the makefile and want to make sure I'll get an error if my assumptions are not met. Something like assert, but in makefile.

if filesize(file) > C then error
else continue compilation

推荐答案

将其放在您的规则中,即在编译之前:

Put this in your rule, somewhere before the compilation:

 test -n "$$(find filename -a -size +NNNc)"

其中filename是文件名,而NNN是字节的大小.当大小小于或等于NNN时,将返回false并暂停make.

where filename is the filename and NNN is the size in octets. This returns false and halts make when the size is less than or equal to NNN.

这篇关于检查makefile中的文件大小,如果文件太短则停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆