其他動作規則

回報問題 查看原始碼 夜間 7.2 7.1 7.0 6.5 6.4

規則

action_listener

查看規則來源
action_listener(name, compatible_with, deprecation, distribs, exec_compatible_with, exec_properties, extra_actions, features, licenses, mnemonics, restricted_to, tags, target_compatible_with, testonly, visibility)

警告:額外動作已淘汰。使用 切面

action_listener 規則本身不會產生任何輸出內容。 反之,這個 API 可讓工具開發人員 extra_action 傳入建構系統中。 提供動作與 extra_action 的對應關係

這項規則的引數會將該動作的記憶法對應至 extra_action 規則。

透過指定 選項 --experimental_action_listener=<label>, 建構作業會使用指定的 action_listener extra_action 寫入建構圖表。

範例

action_listener(
    name = "index_all_languages",
    mnemonics = [
        "Javac",
        "CppCompile",
        "Python",
    ],
    extra_actions = [":indexer"],
)

action_listener(
    name = "index_java",
    mnemonics = ["Javac"],
    extra_actions = [":indexer"],
)

extra_action(
    name = "indexer",
    tools = ["//my/tools:indexer"],
    cmd = "$(location //my/tools:indexer)" +
          "--extra_action_file=$(EXTRA_ACTION_FILE)",
)

引數

屬性
name

名稱;必選

此目標的專屬名稱。

extra_actions

標籤清單;必選

包含 extra_action 個目標的清單 這個 action_listener 應該加入建構圖表中。 例如:[ "//my/tools:analyzer" ]
mnemonics

字串清單;必選

這個action_listener應監聽的動作記憶法清單 ,例如[ "Javac" ]

記憶術不是公開介面, 我們無法保證記憶力和其行動不會有所改變。

extra_action

查看規則來源
extra_action(name, data, cmd, compatible_with, deprecation, distribs, exec_compatible_with, exec_properties, features, licenses, out_templates, requires_action_output, restricted_to, tags, target_compatible_with, testonly, toolchains, tools, visibility)

警告:額外動作已淘汰。使用 切面

extra_action 規則不會產生任何有意義的輸出內容 當指定為一般建構目標時不過,這些工具可以 讓工具開發人員 將其他動作插入建構圖表,隱藏現有的動作。

詳情請參閱 action_listener 瞭解如何啟用 extra_action

extra_action 會以指令列的形式執行。指令列工具會取得 對包含通訊協定緩衝區的檔案使用 $(EXTRA_ACTION_FILE) 權限 。 此外,還能存取原始動作可存取的所有輸入檔案。 請參閱 extra_actions_base.proto ,進一步瞭解儲存在通訊協定緩衝區中的資料。每個 proto 檔案 包含 ExtraActionInfo 訊息。

和其他動作一樣,額外動作也採用沙箱機制,且應設計可處理這類動作。

引數

屬性
name

名稱;必選

此目標的專屬名稱。

你可以在 extra_actions 引數中依 label 參照這項規則 (共 action_listener 項規則)。
cmd

String;必選

要執行的指令。

與含有下列的 genrule cmd 屬性類似 差異:

  1. 無法擴展標籤。僅展開使用 $(location ...) 的標籤。

  2. 額外票證會套用至字串,以取代全部 使用 out_templates 建立的輸出內容時 屬性。與「$(output out_template)」相符的所有結果 會以 label 表示的檔案路徑取代。

    例如:out_template $(ACTION_ID).analysis 可與 $(output $(ACTION_ID).analysis) 配對。

    實際上,這與 $(location) 替代相同 但範圍不同

out_templates

字串清單;預設值為 []

列出 extra_action 指令產生的檔案範本清單。

範本可使用下列變數:

  • $(ACTION_ID),用來識別這個 extra_action 的專屬 ID。 用於產生不重複的輸出檔案。

requires_action_output

Boolean;預設值為 False

表示這個 extra_action 需要 呈現為此extra_action的輸入欄位。

如果為 true (預設為 false), extra_action 可以假設 原始動作輸出內容會做為輸入內容的一部分。

tools

標籤清單;預設為 []

這項規則的 tool 依附元件清單。

詳情請參閱依附元件的定義 可能不準確或不適當

建構系統會確保在執行 extra_action 指令;都是以 execconfiguration 因為它們必須在建構期間做為工具執行。特定的個人路徑 tools 目標 //x:y 可透過以下方式取得 $(location //x:y)

所有工具及其資料依附元件都會合併為單一樹狀結構 當中可使用相對路徑工作目錄將 會是該統一樹狀圖的根