Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | "os/exec" |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 7 | "path/filepath" |
Fumitoshi Ukai | 3e5161e | 2015-04-01 22:42:10 +0900 | [diff] [blame] | 8 | "strings" |
Fumitoshi Ukai | 772fe1a | 2015-04-01 23:28:26 +0900 | [diff] [blame] | 9 | "syscall" |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 10 | "time" |
| 11 | ) |
| 12 | |
| 13 | type Executor struct { |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 14 | rules map[string]*Rule |
| 15 | implicitRules []*Rule |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 16 | suffixRules map[string][]*Rule |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 17 | firstRule *Rule |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | func newExecutor() *Executor { |
| 21 | return &Executor{ |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 22 | rules: make(map[string]*Rule), |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 23 | suffixRules: make(map[string][]*Rule), |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 24 | } |
| 25 | } |
| 26 | |
Fumitoshi Ukai | cf2b038 | 2015-03-30 17:48:54 +0900 | [diff] [blame] | 27 | // TODO(ukai): use time.Time? |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 28 | func getTimestamp(filename string) int64 { |
| 29 | st, err := os.Stat(filename) |
| 30 | if err != nil { |
| 31 | return -2 |
| 32 | } |
| 33 | return st.ModTime().Unix() |
| 34 | } |
| 35 | |
Shinichiro Hamaji | 894bb82 | 2015-04-01 00:54:46 +0900 | [diff] [blame] | 36 | func (ex *Executor) runCommands(cmds []string, output string) error { |
Fumitoshi Ukai | 772fe1a | 2015-04-01 23:28:26 +0900 | [diff] [blame] | 37 | Loop: |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 38 | for _, cmd := range cmds { |
Fumitoshi Ukai | 772fe1a | 2015-04-01 23:28:26 +0900 | [diff] [blame] | 39 | echo := true |
| 40 | ignoreErr := false |
| 41 | for { |
| 42 | if cmd == "" { |
| 43 | continue Loop |
| 44 | } |
| 45 | switch cmd[0] { |
| 46 | case '@': |
| 47 | echo = false |
| 48 | cmd = cmd[1:] |
| 49 | continue |
| 50 | case '-': |
| 51 | ignoreErr = true |
| 52 | cmd = cmd[1:] |
| 53 | continue |
| 54 | } |
| 55 | break |
| 56 | } |
| 57 | if echo { |
| 58 | fmt.Printf("%s\n", cmd) |
| 59 | } |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 60 | |
| 61 | args := []string{"/bin/sh", "-c", cmd} |
| 62 | cmd := exec.Cmd{ |
| 63 | Path: args[0], |
| 64 | Args: args, |
| 65 | } |
| 66 | out, err := cmd.CombinedOutput() |
Fumitoshi Ukai | 772fe1a | 2015-04-01 23:28:26 +0900 | [diff] [blame] | 67 | exit := 0 |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 68 | if err != nil { |
Fumitoshi Ukai | 772fe1a | 2015-04-01 23:28:26 +0900 | [diff] [blame] | 69 | exit = 1 |
| 70 | if err, ok := err.(*exec.ExitError); ok { |
| 71 | if w, ok := err.ProcessState.Sys().(syscall.WaitStatus); ok { |
| 72 | exit = w.ExitStatus() |
| 73 | } |
| 74 | } else { |
| 75 | return err |
| 76 | } |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 77 | } |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 78 | fmt.Printf("%s", out) |
Fumitoshi Ukai | 772fe1a | 2015-04-01 23:28:26 +0900 | [diff] [blame] | 79 | if exit != 0 { |
| 80 | if ignoreErr { |
| 81 | fmt.Printf("[%s] Error %d (ignored)\n", output, exit) |
| 82 | continue |
| 83 | } |
| 84 | return fmt.Errorf("command failed: %q. Error %d", cmd, exit) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 85 | } |
| 86 | } |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 87 | return nil |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 88 | } |
| 89 | |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 90 | func replaceSuffix(s string, newsuf string) string { |
| 91 | // TODO: Factor out the logic around suffix rules and use |
| 92 | // it from substitution references. |
| 93 | // http://www.gnu.org/software/make/manual/make.html#Substitution-Refs |
| 94 | oldsuf := filepath.Ext(s) |
| 95 | return fmt.Sprintf("%s.%s", s[:len(s)-len(oldsuf)], newsuf) |
| 96 | } |
| 97 | |
Shinichiro Hamaji | 0d0af5b | 2015-04-02 05:17:23 +0900 | [diff] [blame] | 98 | func (ex *Executor) canPickImplicitRule(rule *Rule, output string) bool { |
| 99 | outputPattern := rule.outputPatterns[0] |
| 100 | if !matchPattern(outputPattern, output) { |
| 101 | return false |
| 102 | } |
| 103 | for _, input := range rule.inputs { |
| 104 | input = substPattern(outputPattern, input, output) |
| 105 | if !exists(input) { |
| 106 | return false |
| 107 | } |
| 108 | } |
| 109 | return true |
| 110 | } |
| 111 | |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 112 | func (ex *Executor) pickRule(output string) (*Rule, bool) { |
| 113 | rule, present := ex.rules[output] |
| 114 | if present { |
| 115 | return rule, true |
| 116 | } |
| 117 | |
| 118 | for _, rule := range ex.implicitRules { |
Shinichiro Hamaji | 0d0af5b | 2015-04-02 05:17:23 +0900 | [diff] [blame] | 119 | if ex.canPickImplicitRule(rule, output) { |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 120 | return rule, true |
| 121 | } |
| 122 | } |
| 123 | |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 124 | outputSuffix := filepath.Ext(output) |
| 125 | if len(outputSuffix) > 0 && outputSuffix[0] == '.' { |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 126 | rules, present := ex.suffixRules[outputSuffix[1:]] |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 127 | if present { |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 128 | for _, rule := range rules { |
| 129 | if len(rule.inputs) != 1 { |
| 130 | panic(fmt.Sprintf("unexpected number of input for a suffix rule (%d)", len(rule.inputs))) |
| 131 | } |
| 132 | if exists(replaceSuffix(output, rule.inputs[0])) { |
| 133 | return rule, true |
| 134 | } |
| 135 | } |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 139 | return nil, false |
| 140 | } |
| 141 | |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 142 | func (ex *Executor) build(vars *VarTab, output string) (int64, error) { |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 143 | Log("Building: %s", output) |
Fumitoshi Ukai | cf2b038 | 2015-03-30 17:48:54 +0900 | [diff] [blame] | 144 | outputTs := getTimestamp(output) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 145 | |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 146 | rule, present := ex.pickRule(output) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 147 | if !present { |
Fumitoshi Ukai | cf2b038 | 2015-03-30 17:48:54 +0900 | [diff] [blame] | 148 | if outputTs >= 0 { |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 149 | return outputTs, nil |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 150 | } |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 151 | return outputTs, fmt.Errorf("no rule to make target %q", output) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | latest := int64(-1) |
Shinichiro Hamaji | 57aff98 | 2015-04-02 02:15:38 +0900 | [diff] [blame] | 155 | var actualInputs []string |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 156 | for _, input := range rule.inputs { |
Shinichiro Hamaji | 7b203b2 | 2015-04-01 03:44:57 +0900 | [diff] [blame] | 157 | if len(rule.outputPatterns) > 0 { |
| 158 | if len(rule.outputPatterns) > 1 { |
| 159 | panic("TODO: multiple output pattern is not supported yet") |
| 160 | } |
| 161 | input = substPattern(rule.outputPatterns[0], input, output) |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 162 | } else if rule.isSuffixRule { |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 163 | input = replaceSuffix(output, input) |
Shinichiro Hamaji | 7b203b2 | 2015-04-01 03:44:57 +0900 | [diff] [blame] | 164 | } |
Shinichiro Hamaji | 57aff98 | 2015-04-02 02:15:38 +0900 | [diff] [blame] | 165 | actualInputs = append(actualInputs, input) |
Shinichiro Hamaji | 7b203b2 | 2015-04-01 03:44:57 +0900 | [diff] [blame] | 166 | |
Fumitoshi Ukai | 3e5161e | 2015-04-01 22:42:10 +0900 | [diff] [blame] | 167 | ts, err := ex.build(vars, input) |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 168 | if err != nil { |
| 169 | return outputTs, err |
| 170 | } |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 171 | if latest < ts { |
| 172 | latest = ts |
| 173 | } |
| 174 | } |
| 175 | |
Shinichiro Hamaji | 5c53b57 | 2015-04-02 05:36:42 +0900 | [diff] [blame] | 176 | for _, input := range rule.orderOnlyInputs { |
| 177 | if exists(input) { |
| 178 | continue |
| 179 | } |
| 180 | ts, err := ex.build(vars, input) |
| 181 | if err != nil { |
| 182 | return outputTs, err |
| 183 | } |
| 184 | if latest < ts { |
| 185 | latest = ts |
| 186 | } |
| 187 | } |
| 188 | |
Fumitoshi Ukai | cf2b038 | 2015-03-30 17:48:54 +0900 | [diff] [blame] | 189 | if outputTs >= latest { |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 190 | return outputTs, nil |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 191 | } |
| 192 | |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 193 | localVars := NewVarTab(vars) |
Fumitoshi Ukai | 3e5161e | 2015-04-01 22:42:10 +0900 | [diff] [blame] | 194 | // automatic variables. |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 195 | localVars.Assign("@", SimpleVar{value: output, origin: "automatic"}) |
Shinichiro Hamaji | 57aff98 | 2015-04-02 02:15:38 +0900 | [diff] [blame] | 196 | if len(actualInputs) > 0 { |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 197 | localVars.Assign("<", SimpleVar{ |
| 198 | value: actualInputs[0], |
| 199 | origin: "automatic", |
| 200 | }) |
| 201 | localVars.Assign("^", SimpleVar{ |
| 202 | value: strings.Join(actualInputs, " "), |
| 203 | origin: "automatic", |
| 204 | }) |
Shinichiro Hamaji | 57aff98 | 2015-04-02 02:15:38 +0900 | [diff] [blame] | 205 | } |
Fumitoshi Ukai | 3e5161e | 2015-04-01 22:42:10 +0900 | [diff] [blame] | 206 | ev := newEvaluator(localVars) |
| 207 | var cmds []string |
| 208 | for _, cmd := range rule.cmds { |
| 209 | if strings.IndexByte(cmd, '$') < 0 { |
| 210 | // fast path. |
| 211 | cmds = append(cmds, cmd) |
| 212 | continue |
| 213 | } |
| 214 | ecmd := ev.evalExpr(cmd) |
| 215 | Log("build eval:%q => %q", cmd, ecmd) |
| 216 | cmds = append(cmds, strings.Split(ecmd, "\n")...) |
| 217 | } |
| 218 | |
| 219 | err := ex.runCommands(cmds, output) |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 220 | if err != nil { |
| 221 | return outputTs, err |
| 222 | } |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 223 | |
Fumitoshi Ukai | cf2b038 | 2015-03-30 17:48:54 +0900 | [diff] [blame] | 224 | outputTs = getTimestamp(output) |
| 225 | if outputTs < 0 { |
| 226 | outputTs = time.Now().Unix() |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 227 | } |
Fumitoshi Ukai | f8efa0a | 2015-03-30 18:10:11 +0900 | [diff] [blame] | 228 | return outputTs, nil |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 229 | } |
| 230 | |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 231 | func (ex *Executor) populateSuffixRule(rule *Rule, output string) bool { |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 232 | if len(output) == 0 || output[0] != '.' { |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 233 | return false |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 234 | } |
| 235 | rest := output[1:] |
| 236 | dotIndex := strings.IndexByte(rest, '.') |
| 237 | // If there is only a single dot or the third dot, this is not a |
| 238 | // suffix rule. |
| 239 | if dotIndex < 0 || strings.IndexByte(rest[dotIndex+1:], '.') >= 0 { |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 240 | return false |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | // This is a suffix rule. |
| 244 | inputSuffix := rest[:dotIndex] |
| 245 | outputSuffix := rest[dotIndex+1:] |
| 246 | r := &Rule{} |
| 247 | *r = *rule |
| 248 | r.inputs = []string{inputSuffix} |
| 249 | r.isSuffixRule = true |
Shinichiro Hamaji | 20a4376 | 2015-04-02 02:42:25 +0900 | [diff] [blame] | 250 | ex.suffixRules[outputSuffix] = append([]*Rule{r}, ex.suffixRules[outputSuffix]...) |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 251 | return true |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 252 | } |
| 253 | |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 254 | func (ex *Executor) populateExplicitRule(rule *Rule) { |
| 255 | for _, output := range rule.outputs { |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 256 | isSuffixRule := ex.populateSuffixRule(rule, output) |
Shinichiro Hamaji | abc80d2 | 2015-04-02 01:56:32 +0900 | [diff] [blame] | 257 | |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 258 | if oldRule, present := ex.rules[output]; present { |
Shinichiro Hamaji | cc3abc3 | 2015-04-02 04:46:49 +0900 | [diff] [blame] | 259 | if oldRule.isDoubleColon != rule.isDoubleColon { |
| 260 | Error(rule.filename, rule.lineno, "*** target file %q has both : and :: entries.", output) |
| 261 | } |
| 262 | if len(oldRule.cmds) > 0 && len(rule.cmds) > 0 && !isSuffixRule && !rule.isDoubleColon { |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 263 | Warn(rule.filename, rule.cmdLineno, "overriding commands for target %q", output) |
| 264 | Warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", output) |
| 265 | } |
| 266 | r := &Rule{} |
| 267 | *r = *rule |
Shinichiro Hamaji | cc3abc3 | 2015-04-02 04:46:49 +0900 | [diff] [blame] | 268 | if rule.isDoubleColon { |
| 269 | r.cmds = append(oldRule.cmds, r.cmds...) |
| 270 | } |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 271 | r.inputs = append(r.inputs, oldRule.inputs...) |
| 272 | ex.rules[output] = r |
| 273 | } else { |
| 274 | ex.rules[output] = rule |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 275 | if ex.firstRule == nil && !isSuffixRule { |
| 276 | ex.firstRule = rule |
| 277 | } |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | func (ex *Executor) populateImplicitRule(rule *Rule) { |
| 283 | for _, outputPattern := range rule.outputPatterns { |
| 284 | r := &Rule{} |
| 285 | *r = *rule |
| 286 | r.outputPatterns = []string{outputPattern} |
| 287 | ex.implicitRules = append(ex.implicitRules, r) |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | func (ex *Executor) populateRules(er *EvalResult) { |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 292 | for _, rule := range er.rules { |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 293 | ex.populateExplicitRule(rule) |
| 294 | |
| 295 | if len(rule.outputs) == 0 { |
| 296 | ex.populateImplicitRule(rule) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 297 | } |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 298 | } |
| 299 | |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 300 | // Reverse the implicit rule for easier lookup. |
| 301 | for i, r := range ex.implicitRules { |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 302 | if i >= len(ex.implicitRules)/2 { |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 303 | break |
| 304 | } |
Fumitoshi Ukai | 8edcb79 | 2015-04-02 11:23:23 +0900 | [diff] [blame] | 305 | j := len(ex.implicitRules) - i - 1 |
Shinichiro Hamaji | 9b7d462 | 2015-04-02 01:37:04 +0900 | [diff] [blame] | 306 | ex.implicitRules[i] = ex.implicitRules[j] |
| 307 | ex.implicitRules[j] = r |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | func (ex *Executor) exec(er *EvalResult, targets []string) error { |
| 312 | ex.populateRules(er) |
| 313 | |
Shinichiro Hamaji | b13f3d5 | 2015-03-30 19:29:44 +0900 | [diff] [blame] | 314 | if len(targets) == 0 { |
Shinichiro Hamaji | 26fe957 | 2015-04-02 02:31:32 +0900 | [diff] [blame] | 315 | if ex.firstRule == nil { |
| 316 | ErrorNoLocation("*** No targets.") |
| 317 | } |
| 318 | targets = append(targets, ex.firstRule.outputs[0]) |
Shinichiro Hamaji | b13f3d5 | 2015-03-30 19:29:44 +0900 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | for _, target := range targets { |
Fumitoshi Ukai | 3e5161e | 2015-04-01 22:42:10 +0900 | [diff] [blame] | 322 | _, err := ex.build(er.vars, target) |
Shinichiro Hamaji | b13f3d5 | 2015-03-30 19:29:44 +0900 | [diff] [blame] | 323 | if err != nil { |
| 324 | return err |
| 325 | } |
| 326 | } |
| 327 | return nil |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 328 | } |
| 329 | |
Shinichiro Hamaji | b13f3d5 | 2015-03-30 19:29:44 +0900 | [diff] [blame] | 330 | func Exec(er *EvalResult, targets []string) error { |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 331 | ex := newExecutor() |
Shinichiro Hamaji | b13f3d5 | 2015-03-30 19:29:44 +0900 | [diff] [blame] | 332 | return ex.exec(er, targets) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 333 | } |