Action.dhall
1 --| DICE Action Types 2 --| 3 --| The unit of computation in the build graph. 4 --| This is what Buck2 runs. 5 6 let Toolchain = ./Toolchain.dhall 7 let Target = ./Target.dhall 8 9 let Artifact = Toolchain.Artifact 10 11 let ActionCategory = 12 < Compile 13 | Link 14 | Archive 15 | Copy 16 | Write 17 | Run 18 | Test 19 | Custom : Text 20 > 21 22 let EnvVar = 23 { name : Text 24 , value : Text 25 } 26 27 let Input = 28 < Artifact : Artifact 29 | Source : Text -- Source file path 30 | Dep : Text -- Dependency target label 31 > 32 33 let Output = 34 { name : Text 35 , binding : Optional Text -- Environment variable to bind path to 36 } 37 38 let Action = 39 { category : ActionCategory 40 , identifier : Text 41 , inputs : List Input 42 , outputs : List Output 43 , command : List Text 44 , env : List EnvVar 45 , toolchain : Optional Toolchain.Toolchain 46 } 47 48 -- Action constructors 49 50 let compile 51 : Text -> List Text -> Text -> Toolchain.Toolchain -> Action 52 = \(identifier : Text) -> 53 \(srcs : List Text) -> 54 \(output : Text) -> 55 \(toolchain : Toolchain.Toolchain) -> 56 { category = ActionCategory.Compile 57 , identifier 58 , inputs = List/map Text Input (\(s : Text) -> Input.Source s) srcs 59 , outputs = [ { name = output, binding = Some "OUT" } ] 60 , command = [] : List Text -- Filled by rule 61 , env = [] : List EnvVar 62 , toolchain = Some toolchain 63 } 64 65 let link 66 : Text -> List Artifact -> Text -> Toolchain.Toolchain -> Action 67 = \(identifier : Text) -> 68 \(objects : List Artifact) -> 69 \(output : Text) -> 70 \(toolchain : Toolchain.Toolchain) -> 71 { category = ActionCategory.Link 72 , identifier 73 , inputs = List/map Artifact Input (\(a : Artifact) -> Input.Artifact a) objects 74 , outputs = [ { name = output, binding = Some "OUT" } ] 75 , command = [] : List Text 76 , env = [] : List EnvVar 77 , toolchain = Some toolchain 78 } 79 80 let copy 81 : Text -> Artifact -> Text -> Action 82 = \(identifier : Text) -> 83 \(src : Artifact) -> 84 \(dst : Text) -> 85 { category = ActionCategory.Copy 86 , identifier 87 , inputs = [ Input.Artifact src ] 88 , outputs = [ { name = dst, binding = None Text } ] 89 , command = [ "cp", "-r", src.name, dst ] 90 , env = [] : List EnvVar 91 , toolchain = None Toolchain.Toolchain 92 } 93 94 let write 95 : Text -> Text -> Text -> Action 96 = \(identifier : Text) -> 97 \(content : Text) -> 98 \(output : Text) -> 99 { category = ActionCategory.Write 100 , identifier 101 , inputs = [] : List Input 102 , outputs = [ { name = output, binding = None Text } ] 103 , command = [] : List Text -- Content written directly 104 , env = [] : List EnvVar 105 , toolchain = None Toolchain.Toolchain 106 } 107 108 let run 109 : Text -> List Text -> List EnvVar -> Action 110 = \(identifier : Text) -> 111 \(command : List Text) -> 112 \(env : List EnvVar) -> 113 { category = ActionCategory.Run 114 , identifier 115 , inputs = [] : List Input 116 , outputs = [] : List Output 117 , command 118 , env 119 , toolchain = None Toolchain.Toolchain 120 } 121 122 in { ActionCategory 123 , EnvVar 124 , Input 125 , Output 126 , Action 127 , compile 128 , link 129 , copy 130 , write 131 , run 132 }