Makefile使用全局脚本
我对使用makefile为自己编写命令相当陌生 我制作了一个Makefile来运行和格式化Flask应用程序。 内容是Makefile使用全局脚本,makefile,formatting,prettier,autopep8,Makefile,Formatting,Prettier,Autopep8,我对使用makefile为自己编写命令相当陌生 我制作了一个Makefile来运行和格式化Flask应用程序。 内容是 run: .\venv\Scripts\python.exe app.py format: prettier -w .\templates\ prettier -w .\static\ autopep8 --in-place --aggressive --aggressive .\app.py make run按预期工作,可能是因为我
run:
.\venv\Scripts\python.exe app.py
format:
prettier -w .\templates\
prettier -w .\static\
autopep8 --in-place --aggressive --aggressive .\app.py
make run
按预期工作,可能是因为我在同一目录中有虚拟环境。
运行make格式
❯ make format
prettier -w .\templates\
prettier -w .\static\
autopep8 --in-place --aggressive --aggressive .\app.py
[warn] Ignored unknown option --in-place.
[warn] Ignored unknown option --aggressive=.\app.py.
[error] No files matching the pattern were found: ".\templatesprettier".
[error] No files matching the pattern were found: ".\staticautopep8".
Makefile:4: recipe for target 'format' failed
make: *** [format] Error 2
但是手动执行格式的内容非常好。所以我猜这是makefile无法访问这些全局脚本的某种问题
我将如何着手解决这个问题,是否有一种更适合我的任务的替代方法(w/o makefile)我怀疑make接受基于Win的路径。make来自Unix世界,在那里它的工作做得很好。将其移动到Win,一种方法是使用minGW或Linux子系统。您考虑过其中一个吗?在makefiles中工作时,通常最好使用POSIX目录分隔符(正斜杠,/
),而不是DOS分隔符(反斜杠)。大多数Windows工具将接受其中一种。然而,在这样的配方中,反斜杠可能会起作用。如果启动一个全新的cmd.com窗口,将cd刻录到此处的目录,但不执行其他操作,然后键入autopep8--in-place--aggressive--aggressive.\app.py
是否有效?这就是make的基本功能。在运行此命令之前,可能必须先设置virtualenv。在终端中键入时,所有命令都有效。在make文件中,autopep8可以工作,但是更漂亮的不能工作。我找到了一种修复方法,将cd放入文件夹中,然后执行命令,即cd templates&&prettier-w*.html
,但没有修复,不确定为什么我原来的方法不起作用,即使它在终端中手动键入:P