(buildType string)
| 351 | } |
| 352 | |
| 353 | func (p *Port) findMatchedConfig(buildType string) (*buildsystems.BuildConfig, error) { |
| 354 | matchedIndexes := make([]int, 0, len(p.BuildConfigs)) |
| 355 | |
| 356 | for index, config := range p.BuildConfigs { |
| 357 | if p.matchBuildConfig(config) { |
| 358 | matchedIndexes = append(matchedIndexes, index) |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if len(matchedIndexes) == 0 { |
| 363 | return nil, nil |
| 364 | } |
| 365 | if len(matchedIndexes) > 1 { |
| 366 | return nil, fmt.Errorf( |
| 367 | "port %s has %d build_configs matching current platform (%s/%s), please keep only one", |
| 368 | p.NameVersion(), |
| 369 | len(matchedIndexes), |
| 370 | p.currentSystemName(), |
| 371 | p.currentSystemProcessor(), |
| 372 | ) |
| 373 | } |
| 374 | |
| 375 | index := matchedIndexes[0] |
| 376 | |
| 377 | // If build type is not specified in port.toml, then set it to the build type defined in celer.toml. |
| 378 | if p.BuildConfigs[index].BuildType == "" { |
| 379 | p.BuildConfigs[index].BuildType = buildType |
| 380 | } |
| 381 | |
| 382 | // Placeholder variables. |
| 383 | p.putExprVars(p.BuildConfigs[index]) |
| 384 | p.BuildConfigs[index].ExprVars = p.exprVars |
| 385 | return &p.BuildConfigs[index], nil |
| 386 | } |
| 387 | |
| 388 | func (p *Port) putExprVars(config buildsystems.BuildConfig) { |
| 389 | p.exprVars = p.ctx.ExprVars().Clone() |
no test coverage detected