Linux 中makefile的命令包定義及使用
下面以/build/core/product.mk下面的內容為例介紹:
<span style="font-size:14px;">define _find-android-products-files $(shell test -d device && finddevice -maxdepth 6 -name AndroidProducts.mk) / $(shell test -d vendor && find vendor -maxdepth 6 -nameAndroidProducts.mk) / $(SRC_TARGET_DIR)/product/AndroidProducts.mk endef</span>
makefile文件中如出現一些相同的命令序列,可為這些相同的序列定義一個變量,不能和makefile文件中的變量重名,這里是_find-Android-products-files,定義這種命令序列的語法以define開始,以endef結束。
命令包的使用,就像使用變量一樣:
<span style="font-size:14px;">define get-all-product-makefiles $(call get-product-makefiles,$(_find-android-products-files)) endef</span>
$(_find-android-products-files),用$來使用命令包,就像使用函數和變量一樣
這里call是函數名,get-product-makefiles和$(_find-android-products-files)是函數的參數
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答