()
| 171 | } |
| 172 | |
| 173 | func (b *BuildTool) validate() error { |
| 174 | // Validate download url. |
| 175 | if b.Url == "" { |
| 176 | return fmt.Errorf("url of %s is empty", b.Name) |
| 177 | } |
| 178 | |
| 179 | // Validate version. |
| 180 | if b.Version == "" { |
| 181 | return fmt.Errorf("version of %s is empty", b.Name) |
| 182 | } |
| 183 | |
| 184 | // Validate url. |
| 185 | if b.Url == "" { |
| 186 | return fmt.Errorf("url of %s is empty", b.Name) |
| 187 | } |
| 188 | |
| 189 | // Set rootDir and paths based on tool type. |
| 190 | // Archive tools (has paths) are extracted to subdirectories. |
| 191 | if len(b.Paths) > 0 { |
| 192 | // Archive with paths specified: extract to subdirectory. |
| 193 | folderName := strings.Split(b.Paths[0], "/")[0] |
| 194 | b.rootDir = filepath.Join(b.ctx.Downloads(), "tools", folderName) |
| 195 | for _, path := range b.Paths { |
| 196 | b.abspaths = append(b.abspaths, filepath.Join(b.ctx.Downloads(), "tools", path)) |
| 197 | } |
| 198 | os.Setenv("PATH", env.JoinPaths("PATH", b.abspaths...)) |
| 199 | } else { |
| 200 | // Single-file tool: use directly from /downloads/ |
| 201 | b.rootDir = b.ctx.Downloads() |
| 202 | } |
| 203 | |
| 204 | // Check and fix tool. |
| 205 | if err := b.checkAndFix(); err != nil { |
| 206 | return err |
| 207 | } |
| 208 | |
| 209 | return nil |
| 210 | } |
| 211 | |
| 212 | func (b *BuildTool) checkAndFix() error { |
| 213 | var ( |
no test coverage detected