我目前正在一个项目上,该项目明确要求我不要使用Makefile来构建所有依赖项,因为它们的整个仓库都使用bazel来构建文件。我对MakeFile零知识。我想知道如何将以下Makefile转换为命令行参数,然后将其放入简单的Python脚本中。先感谢您!非常感谢您的解决方案!
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
答案 0 :(得分:0)
如果执行“ make”或“ make help”,它将执行:
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2019, 5, 14),
'retries': 0,
}
dag = DAG('print', catchup=False, default_args=default_args, schedule_interval='*/1 * * * *')
t1 = BashOperator(
task_id='print_date',
bash_command='echo `date` , ',
dag=dag)
如果您致电Make与其他任何目标,例如“ make foo”,并且该目标dos不存在(或存在但比sphinx-build -M help . _build
更旧),它将执行:
Makefile
答案 1 :(得分:0)
删除@
,然后将为您打印所有make命令(@
取消make echo使用它的命令):
help:
$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
%: Makefile
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
然后运行make
或make help
并查看make使用的确切行...将复制/粘贴到脚本中...或显式地回显它们:
help:
echo $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
%: Makefile
echo $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
然后什么也不会实际运行,但是会打印出将要运行的命令...