的谷歌巴澤勒構建工具可以很容易足以說明,在一個特定的目錄樹中的每個CoffeeScript的文件需要被編譯成相應的輸出的JavaScript文件:可以將需要重建的N個M文件批量批處理成單個命令嗎?
# Runs "coffee" 100 times if there are 100 files:
# will run slowly if most of them need rebuilding.
[genrule(
name = 'compile-' + f,
srcs = [f],
outs = [f.replace('src/', 'static/').replace('.coffee', '.js')],
cmd = 'coffee --compile --map --output $$(dirname [email protected]) $<',
) for f in glob(['src/**/*.coffee'])]
但考慮,比方說,100個的CoffeeScript文件,這將分開調用咖啡工具100,爲編譯過程增加許多秒。
或者,這可以寫成一個單一的命令,需要100個文件作爲輸入,併產生100個文件作爲輸出:
# Runs "coffee" once on all the files:
# very slow in the case that only 1 file was edited.
coffee_files = glob(['src/**/*.coffee'])
genrule(
name = 'compile-coffee-files',
srcs = coffee_files,
outs = [f.replace('src/', 'static/').replace('.coffee', '.js') for f in coffee_files],
cmd = 'coffee --compile --map --output @D $(SRCS)',
)
有什麼辦法來解釋BAZEL咖啡可以用許多文件被調用並且如果N個目標已過期,那麼只有N個源文件應該提供給coffee
命令,而不是所有目標的完整列表,而不管它們是否需要重建?