関連記事
GitHub - devlights/blog-summary: ブログ「いろいろ備忘録日記」のまとめ
概要
これまでの Task に関する記事は上の関連記事をご参照ください。
v3.36.0 にて、Looping over dependencies という機能が追加されました。
これは、deps
にて依存タスクを指定時にループ処理が指定出来るというものです。
注意点として以下が記載されています。
It is important to note that as deps are run in parallel, the order in which the iterations are run is not guaranteed and the output may vary.
(depsは並列に実行されるため、反復の実行順序は保証されず、出力が異なる可能性があることに注意することが重要です)
サンプル
若干無理やり感が漂いますがサンプルってことで。。。
以下のようなタスクファイルを用意します。
# https://taskfile.dev version: "3" tasks: default: deps: - for: ["32", "64"] task: build vars: OPTION_CPU: '{{.ITEM}}' cmds: - task: show build: cmds: - gcc -m{{.OPTION_CPU}} -g -Wall -o main{{.OPTION_CPU}}.o -c main.c - gcc -m{{.OPTION_CPU}} -g -Wall -o app{{.OPTION_CPU}} main{{.OPTION_CPU}}.o show: cmds: - file ./app32 - file ./app64 install-libc32: cmds: - sudo apt-get install gcc-multilib
実行すると以下のように、パラメータが渡ってるのが確認できます。
$ task task: [build] gcc -m64 -g -Wall -o main64.o -c main.c task: [build] gcc -m32 -g -Wall -o main32.o -c main.c task: [build] gcc -m64 -g -Wall -o app64 main64.o task: [build] gcc -m32 -g -Wall -o app32 main32.o task: [show] file ./app32 ./app32: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=b2f47ccd92c87fc9ad086099543c4583b80f124a, for GNU/Linux 3.2.0, with debug_info, not stripped task: [show] file ./app64 ./app64: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=5b0532275712cb255ae1fd1b5ae75f7a57b537ba, for GNU/Linux 3.2.0, with debug_info, not stripped
参考情報
過去の記事については、以下のページからご参照下さい。
サンプルコードは、以下の場所で公開しています。