【发布时间】:2019-11-11 10:39:47
【问题描述】:
很可能从嵌入在 makefile 中的目标中的规则运行 python 脚本(以便对 mkaefile 组件的输出进行后处理)。但是是否有可能从 python 脚本返回一些值到 makefile 并将其分配给 makefile 中的一些变量。
所以我认为可以通过两种方式完成: 过程1: 1.从makefile调用python脚本 2.允许python脚本将输出存储在某个已知文件中 3. 从makefile中读取值并赋值给里面的变量
我已经尝试过这种方法,并且已经能够执行 Step1 和 Step2 但无法执行 Step 3。
过程 2: 1.从makefile调用python脚本 2.让python脚本返回一些值,这些值被分配给makefile中的一个变量
我无法尝试,因为我找不到任何示例
----------------- makefile----------------
help: detect_term_type
file := term_type
TERM_TYPE := $(cat ${file})
detect_term_type:
python configure_things.py
-------configure_things.py-----
import platform
class TerminalType:
def __init__(self):
self.find_terminal_name()
def find_terminal_name(self):
f= open("term_type","w+")
f.write(platform.system())
f.write('\n')
f.close()
我希望将可能是“Linux”或“Cygwin”的python脚本的输出分配给makefile变量TERM_TYPE。
【问题讨论】: