func (s *TargetBoardResolver) Run(ctx *types.Context) error { logger := ctx.GetLogger() fqbn := ctx.FQBN fqbnParts := strings.Split(fqbn, ":") if len(fqbnParts) < 3 { return i18n.ErrorfWithLogger(logger, constants.MSG_FQBN_INVALID, fqbn) } targetPackageName := fqbnParts[0] targetPlatformName := fqbnParts[1] targetBoardName := fqbnParts[2] packages := ctx.Hardware targetPackage := packages.Packages[targetPackageName] if targetPackage == nil { return i18n.ErrorfWithLogger(logger, constants.MSG_PACKAGE_UNKNOWN, targetPackageName) } targetPlatform := targetPackage.Platforms[targetPlatformName] if targetPlatform == nil { return i18n.ErrorfWithLogger(logger, constants.MSG_PLATFORM_UNKNOWN, targetPlatformName, targetPackageName) } targetBoard := targetPlatform.Boards[targetBoardName] if targetBoard == nil { return i18n.ErrorfWithLogger(logger, constants.MSG_BOARD_UNKNOWN, targetBoardName, targetPlatformName, targetPackageName) } ctx.TargetPackage = targetPackage ctx.TargetPlatform = targetPlatform ctx.TargetBoard = targetBoard if len(fqbnParts) > 3 { addAdditionalPropertiesToTargetBoard(targetBoard, fqbnParts[3]) } core := targetBoard.Properties[constants.BUILD_PROPERTIES_BUILD_CORE] if core == constants.EMPTY_STRING { core = DEFAULT_BUILD_CORE } var corePlatform *types.Platform coreParts := strings.Split(core, ":") if len(coreParts) > 1 { core = coreParts[1] if packages.Packages[coreParts[0]] == nil { return i18n.ErrorfWithLogger(logger, constants.MSG_MISSING_CORE_FOR_BOARD, coreParts[0]) } corePlatform = packages.Packages[coreParts[0]].Platforms[targetPlatform.PlatformId] } var actualPlatform *types.Platform if corePlatform != nil { actualPlatform = corePlatform } else { actualPlatform = targetPlatform } ctx.BuildCore = core ctx.ActualPlatform = actualPlatform return nil }