|
| 1 | +/* |
| 2 | + * This file is part of Arduino Builder. |
| 3 | + * |
| 4 | + * Arduino Builder is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program; if not, write to the Free Software |
| 16 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | + * |
| 18 | + * As a special exception, you may use this file as part of a free software |
| 19 | + * library without restriction. Specifically, if other files instantiate |
| 20 | + * templates or use macros or inline functions from this file, or you compile |
| 21 | + * this file and link it with other files to produce an executable, this |
| 22 | + * file does not by itself cause the resulting executable to be covered by |
| 23 | + * the GNU General Public License. This exception does not however |
| 24 | + * invalidate any other reasons why the executable file might be covered by |
| 25 | + * the GNU General Public License. |
| 26 | + * |
| 27 | + * Copyright 2015 Arduino LLC (http://www.arduino.cc/) |
| 28 | + */ |
| 29 | + |
| 30 | +package builder |
| 31 | + |
| 32 | +import ( |
| 33 | + "github.com/arduino/arduino-cli/legacy/builder/constants" |
| 34 | + "github.com/arduino/arduino-cli/legacy/builder/i18n" |
| 35 | + "github.com/arduino/arduino-cli/legacy/builder/types" |
| 36 | + "github.com/arduino/arduino-cli/arduino/cores" |
| 37 | +) |
| 38 | + |
| 39 | +type AddAdditionalEntriesToContext struct{} |
| 40 | + |
| 41 | +func (*AddAdditionalEntriesToContext) Run(ctx *types.Context) error { |
| 42 | + if ctx.BuildPath != nil { |
| 43 | + buildPath := ctx.BuildPath |
| 44 | + preprocPath, err := buildPath.Join(constants.FOLDER_PREPROC).Abs() |
| 45 | + if err != nil { |
| 46 | + return i18n.WrapError(err) |
| 47 | + } |
| 48 | + sketchBuildPath, err := buildPath.Join(constants.FOLDER_SKETCH).Abs() |
| 49 | + if err != nil { |
| 50 | + return i18n.WrapError(err) |
| 51 | + } |
| 52 | + librariesBuildPath, err := buildPath.Join("libraries").Abs() |
| 53 | + if err != nil { |
| 54 | + return i18n.WrapError(err) |
| 55 | + } |
| 56 | + coreBuildPath, err := buildPath.Join(constants.FOLDER_CORE).Abs() |
| 57 | + if err != nil { |
| 58 | + return i18n.WrapError(err) |
| 59 | + } |
| 60 | + |
| 61 | + ctx.PreprocPath = preprocPath |
| 62 | + ctx.SketchBuildPath = sketchBuildPath |
| 63 | + ctx.LibrariesBuildPath = librariesBuildPath |
| 64 | + ctx.CoreBuildPath = coreBuildPath |
| 65 | + } |
| 66 | + |
| 67 | + if ctx.BuildCachePath != nil { |
| 68 | + coreBuildCachePath, err := ctx.BuildCachePath.Join(constants.FOLDER_CORE).Abs() |
| 69 | + if err != nil { |
| 70 | + return i18n.WrapError(err) |
| 71 | + } |
| 72 | + |
| 73 | + ctx.CoreBuildCachePath = coreBuildCachePath |
| 74 | + } |
| 75 | + |
| 76 | + if ctx.WarningsLevel == "" { |
| 77 | + ctx.WarningsLevel = DEFAULT_WARNINGS_LEVEL |
| 78 | + } |
| 79 | + |
| 80 | + ctx.CollectedSourceFiles = &types.UniqueSourceFileQueue{} |
| 81 | + |
| 82 | + ctx.LibrariesResolutionResults = map[string]types.LibraryResolutionResult{} |
| 83 | + ctx.HardwareRewriteResults = map[*cores.PlatformRelease][]types.PlatforKeyRewrite{} |
| 84 | + |
| 85 | + return nil |
| 86 | +} |
0 commit comments