0

カバレッジ ファイルを生成するアクションを定義しました。いくつかのオプションが必要です。

actions coverage {
    echo coverage $(OPTIONS) >> $(<)
}

$(OPTIONS)変数を設定するルールが必要です:

rule coverage ( targets * : sources * : properties * ) {
    OPTIONS on $(targets) = ...  # Get from environment variables
}

これが完了したら、ルールを使用してカバレッジ ファイルを生成できます。

make cov.xml : : @coverage ;

私が欲しいのは$(OPTIONS)、同じアクションを使用する 2 番目のルール (別の方法で変数を計算する) です。アクション自体を複製せずにそれは可能ですか? つまり、2 つのルールを同じアクションに関連付けることは可能でしょうか?

私が欲しいのは次のようなものです:

actions coverage-from-features {
    # AVOID HAVING TO REPEAT THIS
    echo coverage $(OPTIONS) >> $(<)
}
rule coverage-from-features ( targets * : sources * : properties * ) {
    OPTIONS on $(targets) = ...  # Get from feature values
}
make cov2.xml : : @coverage-from-features ;

明らかに、アクション コマンド自体を繰り返さずに (DRY など)。

4

1 に答える 1

0

必要な重要な側面は次のとおりです。呼び出されたルールを反映するアクションを使用する必要はありません。ルールは、作業を行うために任意の複数のアクションを呼び出すことができます。あなたの場合、次のようなことができます:

actions coverage-action {
  echo coverage $(OPTIONS) >> $(<)
}

rule coverage ( targets * : sources * : properties * ) {
  OPTIONS on $(targets) = ... ; # Get from environment variables
  coverage-action $(target) : $(sources) ;
}

rule coverage-from-features ( targets * : sources * : properties * ) {
  OPTIONS on $(targets) = ... ; # Get from feature values
  coverage-action $(target) : $(sources) ;
}

make cov.xml : : @coverage ;
make cov2.xml : : @coverage-from-features ;
于 2016-04-27T15:18:21.627 に答える