{"id":3801,"date":"2022-02-28T19:57:51","date_gmt":"2022-02-28T11:57:51","guid":{"rendered":"https:\/\/blog.coderfan.org\/?p=3801"},"modified":"2023-04-06T19:03:43","modified_gmt":"2023-04-06T11:03:43","slug":"android-makefile-compose","status":"publish","type":"post","link":"https:\/\/blog.coderfan.org\/en\/android-makefile-compose.html","title":{"rendered":"Android Makefile\u7f16\u5199"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>2 Minute, 36 Second                <\/div>\n\n            <\/div>\n<p class=\"has-text-align-justify\">\u5f53\u524dAndroid\u7cfb\u7edf\u4e2dNative\u539f\u751f\u5f00\u53d1\u7684\u7f16\u8bd1\u53ef\u4ee5\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f\u501f\u52a9makefile\u6587\u4ef6\uff0c\u5728Andorid\u6e90\u7801\u5185\u4ee5Android.mk\u6587\u4ef6\u547d\u540d\u8fdb\u884c\u8868\u793a\uff0c\u800c\u53e6\u5916\u4e00\u79cd\u5219\u662f\u4ee5Android.bp\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1\u63a7\u5236\u3002\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u8bb2\u8bb2\u4f7f\u7528Android.mk\u6765\u7f16\u5199\u7f16\u8bd1\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u901a\u8fc7Android.mk\u6587\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6211\u4eec\u7684\u6e90\u7801\u7f16\u8bd1\u6210\u6a21\u5757\u3002\u8fd9\u4e2a\u6a21\u5757\u53ef\u4ee5\u662fstatic library\u9759\u6001\u5e93\uff08.a\u540e\u7f00\u7ed3\u5c3e\uff09\u3001shared library\u5171\u4eab\u5e93\uff08.so\u540e\u7f00\u7ed3\u5c3e\uff09\u6216\u8005\u662f\u72ec\u7acb\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08.bin\u540e\u7f00\u7ed3\u5c3e\uff09\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u4e00\u4e2aAndroid.mk\u5185\u5b9a\u4e49\u591a\u4e2a\u6a21\u5757\uff0c\u4e5f\u53ef\u4ee5\u5728\u591a\u4e2a\u6a21\u5757\u5185\u5f15\u7528\u540c\u4e00\u4efd\u6e90\u7801\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u5173\u4e8eAndroid.mk\u7f16\u5199\uff0c\u6bd4\u8f83\u57fa\u7840\u7684\u90e8\u5206\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-justify\">1\uff09<strong> \u83b7\u53d6mk\u6240\u5728\u6587\u4ef6\u7684\u8def\u5f84<\/strong>\uff1a<br>LOCAL_PATH :=$(call my-dir)<br>\u901a\u5e38\u6211\u4eec\u4f1a\u5c06\u6211\u4eec\u7684mk\u6587\u4ef6\u653e\u5728\u6211\u4eec\u6a21\u5757\u6e90\u7801\u76ee\u5f55\u7684\u9876\u5c42\uff0c\u8fd9\u6837\u5f53\u6211\u4eec\u5f15\u7528\u6211\u4eec\u7684\u6e90\u7801\u6587\u4ef6\u65f6\u53ef\u4ee5\u65b9\u4fbf\u5730\u901a\u8fc7LOCAL_PATH\u7d22\u5f15\u5230\u5177\u4f53\u7684\u6e90\u7801\u6587\u4ef6\u3002\u5728\u8fd9\u91cc\uff0cmy-dir\u662f\u7531\u7f16\u8bd1\u7cfb\u7edf\u63d0\u4f9b\u7684\u51fd\u6570\u3002<br>2\uff09 <strong>\u6e05\u9664\u6240\u6709\u7f16\u8bd1\u76f8\u5173\u53d8\u91cf<\/strong>\uff1a<br>include $(CLEAR_VARS)<br>\u5728\u6211\u4eec\u7f16\u8bd1\u524d\uff0c\u6211\u4eec\u9700\u8981\u901a\u8fc7\u8be5\u547d\u4ee4\u5c06\u7f16\u8bd1\u53d8\u91cf\u6e05\u9664\uff0c\u56e0\u4e3a\u6709\u53ef\u80fd\u5728\u4f60\u7f16\u8bd1\u4e4b\u524d\u6709\u4eba\u5728\u540c\u4e00\u4e2a\u7f16\u8bd1\u73af\u5883\u4e0b\u7f16\u8bd1\u8fc7\uff0c\u5176\u53ef\u80fd\u8bbe\u7f6e\u4e86\u4e0d\u540c\u7684\u7f16\u8bd1\u53d8\u91cf\uff0c\u6240\u4ee5\u4e3a\u4e86\u4fdd\u9669\u8d77\u89c1\u6700\u597d\u5728\u6b63\u5f0f\u5f00\u59cb\u7f16\u8bd1\u524d\u90fd\u6e05\u9664\u4e00\u4e0b\u76f8\u5173\u53d8\u91cf\uff08\u4e3b\u8981\u662fLOCAL_\u5f00\u5934\u7684\u8fd9\u4e9b\u53d8\u91cf\uff09\u3002<br>3\uff09 <strong>\u5b9a\u4e49\u7f16\u8bd1\u6a21\u5757<\/strong>\uff1a<br>LOCAL_MODULE := ModuleName<br>\u901a\u8fc7\u8be5\u8bed\u53e5\u53ef\u4ee5\u5b9a\u4e49\u4f60\u7f16\u8bd1\u751f\u6210\u6a21\u5757\u7684\u540d\u79f0\uff0c\u9700\u8981\u8bf4\u660e\u7684\u662f\uff0c\u5373\u4f7f\u4f60\u5bf9\u7f16\u8bd1\u540e\u7684\u6587\u4ef6\u8fdb\u884c\u91cd\u547d\u540d\uff0c\u662f\u65e0\u6cd5\u6539\u53d8\u6a21\u5757\u540d\u79f0\u7684\u3002\u67e5\u770b\u771f\u6b63\u7684\u6a21\u5757\u540d\u79f0\u53ef\u4ee5\u4f7f\u7528readelf\u5de5\u5177\u3002\u7f16\u8bd1\u7cfb\u7edf\u4f1a\u81ea\u52a8\u4e3a\u7f16\u8bd1\u540e\u751f\u6210\u7684\u6587\u4ef6\u8bbe\u5b9a\u76f8\u5e94\u7684\u524d\u7f00\u4e0e\u540e\u7f00\u3002<br>\u5173\u4e8e\u7f16\u8bd1\u6a21\u5757\u76f8\u5173\u7684\u914d\u7f6e\u9879\u8fd8\u5305\u62ec\uff1aLOCAL_MODULE_PATH\uff0c\u53ef\u4ee5\u914d\u7f6e\u7f16\u8bd1\u540e\u7684\u6587\u4ef6\u6240\u5728\u7684\u4f4d\u7f6e\u3002<br>4\uff09 <strong>\u5f15\u5165\u6e90\u7801\u6587\u4ef6<\/strong>\uff1a<br>LOCAL_SRC_FILES := sourcefiles<br>\u901a\u8fc7LOCAL_SRC_FILES\u53ef\u4ee5\u6307\u5b9a\u6211\u4eec\u6a21\u5757\u9700\u8981\u7f16\u8bd1\u7684\u6e90\u7801\u6587\u4ef6\uff0c\u5728\u8fd9\u91cc\u4e00\u822c\u6709\u4e24\u79cd\u5199\u6cd5\uff0c\u4e00\u79cd\u662f\u5f53\u6e90\u4ee3\u7801\u6587\u4ef6\u8f83\u5c11\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u6e90\u7801\u6587\u4ef6\u4e00\u4e00\u5217\u51fa\uff0c\u5982\u4e0b\u6240\u793a\uff1a<br>LOCAL_SRC_FILES :=\\<br>..\/test1.c \\<br>..\/test2.c \\<br>\u2026.<br>\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u662f\u901a\u8fc7\u7f16\u8bd1\u7cfb\u7edf\u63d0\u4f9b\u7684\u51fd\u6570\u6765\u5feb\u901f\u5305\u542b\u6240\u6709\u7684\u6e90\u7801\u6587\u4ef6\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p>\u5f15\u7528\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709c\u6587\u4ef6,\u201c.\u201d\u4ee3\u8868\u5f53\u524d\u76ee\u5f55<\/p>\n\n\n\n<p>LOCAL_SRC_FILES += $(call all-c-files-under, .)<\/p>\n\n\n\n<p>\u5f15\u7528\u5f53\u524d\u6587\u4ef6\u5939\u7684\u4e0a\u5c42\u76ee\u5f55\u4e0b\u7684common\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709c\u6587\u4ef6,\u201c..\u201d\u4ee3\u8868\u4e0a\u5c42\u76ee\u5f55<\/p>\n\n\n\n<p>LOCAL_SRC_FILES += $(call all-c-files-under, ..\/common)<\/p>\n\n\n\n<p>\u5f15\u7528\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709cpp\u6587\u4ef6<\/p>\n\n\n\n<p>LOCAL_SRC_FILES += $(call all-cpp-files-under, .)<br>5\uff09<strong> \u6307\u5b9a\u7f16\u8bd1\u5934\u6587\u4ef6<\/strong>\uff1a<br>LOCAL_C_INCLUDES := pathname\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p>LOCAL_PATH\u4e3acall my-dir\u83b7\u53d6\u7684\u8def\u5f84<\/p>\n\n\n\n<p>LOCAL_C_INCLUDES := $(LOCAL_PATH)\/..\/common<br>\u5173\u4e8e\u5934\u6587\u4ef6\u7684\u7f16\u8bd1\u8bbe\u5b9a\uff0c\u6211\u4eec\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u76f8\u5173\u7684\u8bbe\u5b9a\u9879\uff0c\u90a3\u5c31\u662fLOCAL_EXPORT_C_INCLUDES\uff0c\u901a\u8fc7\u8be5\u8bbe\u5b9a\u9879\uff0c\u53ef\u4ee5\u5c06\u8be5\u6a21\u5757\u7684\u5934\u6587\u4ef6\u8fdb\u884c\u638f\u51fa\uff0c\u5982\u679c\u8be5\u6a21\u5757\u88ab\u5176\u4ed6\u6a21\u5757\uff0c\u901a\u8fc7\u8be5\u8bbe\u7f6e\u9879\u53ef\u4ee5\u8fd0\u884c\u5176\u4ed6\u4f9d\u8d56\u4e8e\u8be5\u6a21\u5757\u7684\u6a21\u5757\u76f4\u63a5\u5f15\u7528\u5176\u5934\u6587\u4ef6\u5185\u7684\u5b9a\u4e49\u3002<br>6\uff09 <strong>\u6307\u5b9a\u4f9d\u8d56\u5e93<\/strong>\uff1a<br>\u5982\u679c\u4f60\u7684\u6a21\u5757\u4f9d\u8d56\u4e8e\u7b2c\u4e09\u65b9\u7684\u5e93\uff0c\u9700\u8981\u5728makefile\u5185\u8fdb\u884c\u6307\u5b9a\uff0c\u5305\u62ec\uff1a<br>\u4f9d\u8d56\u7684\u9759\u6001\u5e93\uff1aLOCAL_STATIC_LIBRARIES :=<br>\u4f9d\u8d56\u7684\u5171\u4eab\u5e93\uff1aLOCAL_SHARED_LIBRARIES :=<br>7\uff09 <strong>\u8bbe\u5b9a\u7f16\u8bd1\u9009\u9879<\/strong>\uff1a<br>LOCAL_CFLAGS :=<br>LOCAL_CPPFLAGS :=<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u8fd9\u4e9b\u7f16\u8bd1\u9009\u9879\u53ef\u4ee5\u4f5c\u4e3a\u7f16\u8bd1\u4f18\u5316\u9009\u9879<\/p>\n\n\n\n<p>LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter<\/p>\n\n\n\n<p>\u9664\u4e86\u7f16\u8bd1\u9009\u9879\u5916\uff0c\u6211\u4eec\u8fd8\u7ecf\u5e38\u7528\u7684\u5c31\u662f\u5c31\u4f20\u9012\u7f16\u8bd1\u5b8f\uff0c\u4f20\u9012\u7f16\u8bd1\u5b8f\u5e38\u89c1\u7684\u6709\u4e24\u79cd\uff0c\u5982\u4f60\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>if defined \uff08MACRO_DEBUG_TEST\uff09 \u6216\u8005 #ifdef MACRO_DEBUG_TEST<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u2026\u2026<br>\u6b64\u65f6\uff0c\u6211\u4eec\u5728\u7f16\u8bd1\u65f6\u53ef\u4ee5\u901a\u8fc7LOCAL_CFLAGS+= -DMACRO_DEBUG_TEST\u6765\u4f20\u9012\u8be5\u7f16\u8bd1\u5b8f\u3002<\/p>\n\n\n\n<p>\u6b64\u5916\u8fd8\u6709\u4e00\u79cd\u5f62\u5f0f\uff0c\u5982\u4f60\u7684\u4ee3\u7801\u4e2d\u9700\u8981\u7f16\u8bd1\u7684\u65f6\u95f4\u6233\u76f8\u5173\u4fe1\u606f\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifndef  TIME_STAMP_DEBUG\n#define  TIME_STAMP_DEBUG  \"\"\n#endif\n<\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u5728\u7f16\u8bd1\u65f6\u53ef\u4ee5\u901a\u8fc7LOCAL_CFLAGS+= -DTIME_STAMP_DEBUG=\\\u201d2020-01-01\\\u201d\u5728\u7f16\u8bd1\u65f6\u5c062020-01-01\u8fd9\u4e2a\u503c\u4f20\u9012\u7ed9TIME_STAMP_DEBUG\u5b8f\u3002<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u5173\u4e8e\u7f16\u8bd1\u5b8f\uff0c\u6211\u4eec\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u7684\u8bbe\u7f6e\u9879\uff0c\u5982:LOCAL_EXPORT_CFLAGS:\u901a\u8fc7\u8be5\u8bbe\u7f6e\u9879\u53ef\u4ee5\u5c06\u8be5\u6a21\u5757\u4e2d\u5b9a\u4e49\u7684\u5b8f\u4f20\u9012\u7ed9\u5176\u4ed6\u4f9d\u8d56\u4e8e\u8be5\u6a21\u5757\u7684\u6a21\u5757\uff08\u76f8\u5f53\u4e8e\u5728\u5176\u4ed6\u6a21\u5757\u7684makefile\u4e2d\u589e\u52a0LOCAL_CFLAGS\u9009\u9879\uff09\uff0c\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> For example, consider the module 'foo' with the following definition:\n include $(CLEAR_VARS)\n LOCAL_MODULE := foo\n LOCAL_SRC_FILES := foo\/foo.c\n LOCAL_EXPORT_CFLAGS := -DFOO=1\n include $(BUILD_STATIC_LIBRARY)\n And another module, named 'bar' that depends on it as:\n include $(CLEAR_VARS)\n LOCAL_MODULE := bar\n LOCAL_SRC_FILES := bar.c\n LOCAL_CFLAGS := -DBAR=2\n LOCAL_STATIC_LIBRARIES := foo\n include $(BUILD_SHARED_LIBRARY)\n Then, the flags '-DFOO=1 -DBAR=2' will be passed to the compiler when\n building bar.c\n<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-justify\">8\uff09<strong>\u6307\u5b9a\u7f16\u8bd1\u7c7b\u578b\uff0c\u8fde\u63a5\u4e0a\u8ff0\u6240\u6709\u7f16\u8bd1\u76f8\u5173\u8bbe\u7f6e<\/strong>\uff1a<br>include $(BUILD_SHARED_LIBRARY)\uff0c\u8fd9\u4e00\u53e5\u4e00\u5b9a\u8981\u5728\u6574\u4e2amakefile\u7684\u7ed3\u5c3e\u3002<br>\u5728\u8fd9\u91cc\u8868\u660e\u7f16\u8bd1\u4e3a\u52a8\u6001\u5e93\uff0c\u5982\u679c\u8981\u7f16\u8bd1\u4e3a\u4e8c\u8fdb\u5236\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5219\u4f7f\u7528include $(BUILD_EXECUTABLE)\uff0c\u7f16\u8bd1\u4e3a\u9759\u6001\u5e93\u65f6\uff0c\u5219\u4f7f\u7528include $(BUILD_STATIC_LIBRARY),\u5982\u679c\u662f\u9884\u7f16\u8bd1\u5e93\uff0c\u5219\u4f7f\u7528include $(PREBUILT_SHARED_LIBRARY)<br>9\uff09<strong> \u4f7f\u7528\u7f16\u8bd1\u7cfb\u7edf\u5185\u7f6e\u51fd\u6570<\/strong>\uff1a<br>\u5728Android\u7f16\u8bd1\u7cfb\u7edf\u4e2d\u6709\u4e00\u4e9b\u7f16\u8bd1\u7cfb\u7edf\u63d0\u4f9b\u7684\u51fd\u6570\uff0c\u5728mk\u6587\u4ef6\u4e2d\u53ef\u4ee5\u901a\u8fc7call \u51fd\u6570\u540d\u6765\u5b9e\u73b0\u8c03\u7528\u3002<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u5982 MY_LOCAL_PATH := $(call my-dir)\u5c31\u662f\u901a\u8fc7call my-dir\u51fd\u6570\u8fdb\u884c\u83b7\u53d6\u5f53\u524dmk\u6240\u5728\u7684\u6587\u4ef6\u8def\u5f84\u3002<br>\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\uff0c\u5982\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-justify\">#call all-subdir-makefiles \u53ef\u4ee5\u7f16\u8bd1\u5f53\u524dmakefile\u4e0b\u7684\u6240\u6709\u5b50makefile<\/p>\n\n\n\n<p><strong>all-subdir-makefiles<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">#call this-makefile \u8fd4\u56de\u5f53\u524dmakefile\u7684\u6587\u4ef6\u8def\u5f84<\/p>\n\n\n\n<p><strong>this-makefile<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">#call parent-makefile \u8fd4\u56de\u5f53\u524dmakefile\u7684\u7236makefile\u7684\u8def\u5f84<\/p>\n\n\n\n<p>parent-makefile<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u62d3\u5c55\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-justify\">1.\u5728makefile\u8f93\u51fa\u65e5\u5fd7\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528warning\u6216\u8005info\u6216\u8005error\u3002<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u4f7f\u7528warning\uff1a$(warning \u201chere add the <a href=\"https:\/\/so.csdn.net\/so\/search?q=debug&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">debug<\/a> info\u201d) \/\/\u53ef\u4ee5\u4e0d\u7528\u52a0\u201d\u201d\u53f7<\/p>\n\n\n\n<p>\u4f7f\u7528error\uff1a$(error \u201cerror: this will stop the compile\u201d)\/\/error\u4f1a\u505c\u6b62\u7f16\u8bd1<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u4f7f\u7528info: $(info $(TARGET_DEVICE) )<\/p>\n\n\n\n<p class=\"has-text-align-justify\">2.\u5728makefile\u4e2d\u53ef\u4ee5\u8c03\u7528shell\u811a\u672c\u6216\u8005\u8c03\u7528shell\u547d\u4ee4\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-justify\">#\u4e3atest.sh\u811a\u672c\u8d4b\u4e88x\u6743\u9650<\/p>\n\n\n\n<p>shell_script=$( LOCAL_PATH)\/test.sh<br>$(shell chmod +x $(shell_script))<\/p>\n\n\n\n<p>#\u76f4\u63a5\u8c03\u7528test.sh\u811a\u672c<\/p>\n\n\n\n<p class=\"has-text-align-justify\">$(shell $(shell_script))<br>3.\u5728makefile\u4e2d\u53ef\u4ee5\u4f7f\u7528ifeq\u6765\u5224\u65ad\u4e24\u4e2a\u53c2\u6570\u662f\u5426\u76f8\u7b49\uff0c\u5e76\u6267\u884c\u76f8\u5e94\u903b\u8f91\uff0c\u5982\uff1a<br>Ifeq (\u201cisDebug\u201d,\u201dtrue\u201d)<br>\u903b\u8f91\u5757<br>endif<br>4.\u5e38\u7528\u51fd\u6570\uff1amakefike\u4e2d\u8c03\u7528\u51fd\u6570\u7528\u6cd5\uff1a$( )<br>\u4e00\u4e9b\u5e38\u7528\u7684\u51fd\u6570\u5305\u62ec\uff1a<br><strong>$(subst ,, )<\/strong>\uff1a\u5c06text\u5b57\u7b26\u4e32\u4e2d\u7684from\u5185\u5bb9\u66ff\u6362\u4e3ato\u5185\u5bb9\uff0c\u8fd4\u56de\u66ff\u6362\u540e\u7684\u5b57\u7b26\u4e32<br>\u5982\uff1a$(subst ee,EE,feet on the street)\uff0c\u8fd4\u56de\u7ed3\u679c\u4e3afEEt on the street<br>$<strong>(strip )<\/strong>\uff1a\u5c06string\u5b57\u7b26\u4e32\u4e2d\u5f00\u5934\u4e0e\u7ed3\u5c3e\u7684\u7a7a\u683c\u53bb\u6389\uff0c\u8fd4\u56de\u65b0\u7684\u5b57\u7b26\u4e32<br><strong>$(findstring , )<\/strong>\uff1a\u5728in\u5b57\u7b26\u4e32\u4e2d\u5bfb\u627efind\u5185\u5bb9\uff0c\u5982\u679c\u627e\u5230\u5219\u8fd4\u56defind\u5185\u5bb9\uff0c\u5982\u627e\u4e0d\u5230\u5219\u8fd4\u56de\u7a7a\u5b57\u7b26\u4e32<br><strong>$(dir )<\/strong>\uff1a\u4ece\u6587\u4ef6\u540d\u5e8f\u5217\u4e2d\u53d6\u51fa\u76ee\u5f55\u90e8\u5206\u3002\u76ee\u5f55\u90e8\u5206\u662f\u6307\u6700\u540e\u4e00\u4e2a\u53cd\u659c\u6760\uff08\u201c\/\u201d\uff09\u4e4b\u524d\u7684\u90e8\u5206\u3002\u5982\u679c\u6ca1\u6709\u53cd\u659c\u6760\uff0c\u90a3\u4e48\u8fd4\u56de\u201c.\/\u201d\u3002<br><strong>$(call function,\u2026.)<\/strong>:\u8c03\u7528\u51fd\u6570<br><strong>$(eval var1:=value)<\/strong>:\u5c06value\u8d4b\u503c\u7ed9\u53d8\u91cfvar1\uff0c\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$(if $(findstring OK, $(shell_script_result)), \\\n$(eval result := TRUE), \\\n$(eval result := FALSE) \\\n) \\<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-justify\">5.\u7f16\u5199\u81ea\u5df1\u7684\u51fd\u6570\uff1a<br>\u4ee5define\u5f00\u5934\u5b9a\u4e49\u81ea\u5df1\u7684\u51fd\u6570\u540d\uff0c\u4ee5endef\u7ed3\u5c3e\u5982\u4e0b\u4f8b\u5b50\u6240\u793a\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u83b7\u53d6commitId\uff0c\u901a\u8fc7\u8c03\u7528shell\u811a\u672c\u83b7\u53d6commitId\uff0c\u4ee5$(commit_id)\u4f5c\u4e3a\u8fd4\u56de\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define get_commit_id\n$(strip \\\n$(eval local_path := $(call my-dir)) \\\n$(shell chmod +x $(local_path)\/test.sh)\\\n$(eval commit_id := $(shell $(local_path)\/ test.sh \"GetCommitID\")) \\\n$(warning commit_id:$(ca_evs_commit_id)) \\\n$(commit_id) \\\n)\nendef<\/code><\/pre>\n        <div class=\"booster-block booster-reactions-block\">\n            <div class=\"twp-reactions-icons\">\n                \n                <div class=\"twp-reacts-wrap\">\n                    <a react-data=\"be-react-1\" post-id=\"3801\" class=\"be-face-icons un-reacted\" href=\"javascript:void(0)\">\n                        <img decoding=\"async\" src=\"https:\/\/blog.coderfan.org\/wp-content\/plugins\/booster-extension\/\/assets\/icon\/happy.svg\" alt=\"Happy\">\n                    <\/a>\n                    <div class=\"twp-reaction-title\">\n                        Happy                    <\/div>\n                    <div class=\"twp-count-percent\">\n                                                    <span style=\"display: none;\" class=\"twp-react-count\">2<\/span>\n                        \n                                                <span class=\"twp-react-percent\"><span>100<\/span> %<\/span>\n                                            <\/div>\n                <\/div>\n\n                <div class=\"twp-reacts-wrap\">\n                    <a react-data=\"be-react-2\" post-id=\"3801\" class=\"be-face-icons un-reacted\" href=\"javascript:void(0)\">\n                        <img decoding=\"async\" src=\"https:\/\/blog.coderfan.org\/wp-content\/plugins\/booster-extension\/\/assets\/icon\/sad.svg\" alt=\"Sad\">\n                    <\/a>\n                    <div class=\"twp-reaction-title\">\n                        Sad                    <\/div>\n                    <div class=\"twp-count-percent\">\n                                                    <span style=\"display: none;\" class=\"twp-react-count\">0<\/span>\n                                                                        <span class=\"twp-react-percent\"><span>0<\/span> %<\/span>\n                                            <\/div>\n                <\/div>\n\n                <div class=\"twp-reacts-wrap\">\n                    <a react-data=\"be-react-3\" post-id=\"3801\" class=\"be-face-icons un-reacted\" href=\"javascript:void(0)\">\n                        <img decoding=\"async\" src=\"https:\/\/blog.coderfan.org\/wp-content\/plugins\/booster-extension\/\/assets\/icon\/excited.svg\" alt=\"Excited\">\n                    <\/a>\n                    <div class=\"twp-reaction-title\">\n                        Excited                    <\/div>\n                    <div class=\"twp-count-percent\">\n                                                    <span style=\"display: none;\" class=\"twp-react-count\">0<\/span>\n                                                                        <span class=\"twp-react-percent\"><span>0<\/span> %<\/span>\n                                            <\/div>\n                <\/div>\n\n                <div class=\"twp-reacts-wrap\">\n                    <a react-data=\"be-react-6\" post-id=\"3801\" class=\"be-face-icons un-reacted\" href=\"javascript:void(0)\">\n                        <img decoding=\"async\" src=\"https:\/\/blog.coderfan.org\/wp-content\/plugins\/booster-extension\/\/assets\/icon\/sleepy.svg\" alt=\"Sleepy\">\n                    <\/a>\n                    <div class=\"twp-reaction-title\">\n                        Sleepy                    <\/div>\n                    <div class=\"twp-count-percent\">\n                                                    <span style=\"display: none;\" class=\"twp-react-count\">0<\/span>\n                        \n                                                <span class=\"twp-react-percent\"><span>0<\/span> %<\/span>\n                                            <\/div>\n                <\/div>\n\n                <div class=\"twp-reacts-wrap\">\n                    <a react-data=\"be-react-4\" post-id=\"3801\" class=\"be-face-icons un-reacted\" href=\"javascript:void(0)\">\n                        <img decoding=\"async\" src=\"https:\/\/blog.coderfan.org\/wp-content\/plugins\/booster-extension\/\/assets\/icon\/angry.svg\" alt=\"Angry\">\n                    <\/a>\n                    <div class=\"twp-reaction-title\">Angry<\/div>\n                    <div class=\"twp-count-percent\">\n                                                    <span style=\"display: none;\" class=\"twp-react-count\">0<\/span>\n                                                                        <span class=\"twp-react-percent\"><span>0<\/span> %<\/span>\n                        \n                    <\/div>\n                <\/div>\n\n                <div class=\"twp-reacts-wrap\">\n                    <a react-data=\"be-react-5\" post-id=\"3801\" class=\"be-face-icons un-reacted\" href=\"javascript:void(0)\">\n                        <img decoding=\"async\" src=\"https:\/\/blog.coderfan.org\/wp-content\/plugins\/booster-extension\/\/assets\/icon\/surprise.svg\" alt=\"Surprise\">\n                    <\/a>\n                    <div class=\"twp-reaction-title\">Surprise<\/div>\n                    <div class=\"twp-count-percent\">\n                                                    <span style=\"display: none;\" class=\"twp-react-count\">0<\/span>\n                                                                        <span class=\"twp-react-percent\"><span>0<\/span> %<\/span>\n                                            <\/div>\n                <\/div>\n\n            <\/div>\n        <\/div>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u6587\u7b80\u5355\u603b\u7ed3Android\u7cfb\u7edfmakefile\u7684\u7f16\u5199\uff0cMark\u4e00\u4e0b~<\/p>","protected":false},"author":1,"featured_media":3777,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":1,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[18],"tags":[46,56],"class_list":["post-3801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-operating-system","tag-android","tag-makefile"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[]}},"aioseo_notices":[],"featured_image_urls":{"full":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"thumbnail":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android-150x150.jpg",150,150,true],"medium":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android-300x158.jpg",300,158,true],"medium_large":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"large":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"1536x1536":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"2048x2048":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"trp-custom-language-flag":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android-18x9.jpg",18,9,true]},"post_excerpt_stackable":"<p>\u4e00\u6587\u7b80\u5355\u603b\u7ed3Android\u7cfb\u7edfmakefile\u7684\u7f16\u5199\uff0cMark\u4e00\u4e0b~<\/p>\n","category_list":"<a href=\"https:\/\/blog.coderfan.org\/en\/category\/operating-system\" rel=\"category tag\">\u64cd\u4f5c\u7cfb\u7edf<\/a>","author_info":{"name":"FranzKafka95","url":"https:\/\/blog.coderfan.org\/en\/author\/yushenglonely95"},"comments_num":"0 comments","featured_image_urls_v2":{"full":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"thumbnail":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android-150x150.jpg",150,150,true],"medium":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android-300x158.jpg",300,158,true],"medium_large":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"large":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"1536x1536":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"2048x2048":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android.jpg",512,269,false],"trp-custom-language-flag":["https:\/\/blog.coderfan.org\/wp-content\/uploads\/2022\/02\/android-18x9.jpg",18,9,true]},"post_excerpt_stackable_v2":"<p>\u4e00\u6587\u7b80\u5355\u603b\u7ed3Android\u7cfb\u7edfmakefile\u7684\u7f16\u5199\uff0cMark\u4e00\u4e0b~<\/p>\n","category_list_v2":"<a href=\"https:\/\/blog.coderfan.org\/en\/category\/operating-system\" rel=\"category tag\">\u64cd\u4f5c\u7cfb\u7edf<\/a>","author_info_v2":{"name":"FranzKafka95","url":"https:\/\/blog.coderfan.org\/en\/author\/yushenglonely95"},"comments_num_v2":"0 comments","_links":{"self":[{"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/posts\/3801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/comments?post=3801"}],"version-history":[{"count":8,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/posts\/3801\/revisions"}],"predecessor-version":[{"id":4508,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/posts\/3801\/revisions\/4508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/media\/3777"}],"wp:attachment":[{"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/media?parent=3801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/categories?post=3801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coderfan.org\/en\/wp-json\/wp\/v2\/tags?post=3801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}