MCPcopy Create free account
hub / github.com/celer-pkg/celer / findMatchedConfig

Method findMatchedConfig

configs/port.go:353–386  ·  view source on GitHub ↗
(buildType string)

Source from the content-addressed store, hash-verified

351}
352
353func (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
388func (p *Port) putExprVars(config buildsystems.BuildConfig) {
389 p.exprVars = p.ctx.ExprVars().Clone()

Callers 2

initBuildConfigMethod · 0.95
InitMethod · 0.95

Calls 5

matchBuildConfigMethod · 0.95
NameVersionMethod · 0.95
currentSystemNameMethod · 0.95
putExprVarsMethod · 0.95

Tested by

no test coverage detected