Skip to content

Commit 00364c0

Browse files
author
Federico Fissore
committed
Better error message when platform.txt misses compiler.path. Fixes #11
Signed-off-by: Federico Fissore <[email protected]>
1 parent 3bc17ae commit 00364c0

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

Diff for: src/arduino.cc/builder/constants/constants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const MSG_LIBRARY_CAN_USE_SRC_AND_UTILITY_FOLDERS = "Library can't use both 'src
199199
const MSG_LIBRARY_INCOMPATIBLE_ARCH = "WARNING: library {0} claims to run on {1} architecture(s) and may be incompatible with your current board which runs on {2} architecture(s)."
200200
const MSG_LOOKING_FOR_RECIPES = "Looking for recipes like {0}*{1}"
201201
const MSG_MISSING_BUILD_BOARD = "Board {0}:{1}:{2} doesn''t define a ''build.board'' preference. Auto-set to: {3}"
202-
const MSG_MISSING_COMPILER_PATH = "Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer."
202+
const MSG_MISSING_COMPILER_PATH = "Third-party platform.txt (package '{0}' platform '{1}') does not define compiler.path. Please report this to the third-party hardware maintainer."
203203
const MSG_MISSING_CORE_FOR_BOARD = "Selected board depends on '{0}' core (not installed)."
204204
const MSG_MUST_BE_A_FOLDER = "{0} must be a folder"
205205
const MSG_PACKAGE_UNKNOWN = "{0}: Unknown package"

Diff for: src/arduino.cc/builder/setup_build_properties.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func (s *SetupBuildProperties) Run(context map[string]interface{}) error {
6161
buildProperties[constants.BUILD_PROPERTIES_BUILD_ARCH] = strings.ToUpper(targetPlatform.PlatformId)
6262

6363
if buildProperties[constants.BUILD_PROPERTIES_COMPILER_PATH] == constants.EMPTY_STRING {
64-
return utils.Errorf(context, constants.MSG_MISSING_COMPILER_PATH)
64+
targetPackage := context[constants.CTX_TARGET_PACKAGE].(*types.Package)
65+
return utils.Errorf(context, constants.MSG_MISSING_COMPILER_PATH, targetPackage.PackageId, actualPlatform.PlatformId)
6566
}
6667

6768
buildProperties[constants.BUILD_PROPERTIES_BUILD_CORE] = context[constants.CTX_BUILD_CORE].(string)

Diff for: src/arduino.cc/builder/test/setup_build_properties_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package test
3232
import (
3333
"arduino.cc/builder"
3434
"arduino.cc/builder/constants"
35+
"arduino.cc/builder/i18n"
3536
"arduino.cc/builder/props"
3637
"arduino.cc/builder/types"
3738
"arduino.cc/builder/utils"
@@ -147,3 +148,42 @@ func TestSetupBuildPropertiesWithSomeCustomOverrides(t *testing.T) {
147148
require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties["recipe.c.o.pattern"])
148149
require.Equal(t, "non existent path with space and a =", buildProperties["tools.avrdude.config.path"])
149150
}
151+
152+
func TestSetupBuildPropertiesWithMissingCompilerPath(t *testing.T) {
153+
DownloadCoresAndToolsAndLibraries(t)
154+
155+
context := make(map[string]interface{})
156+
157+
buildPath := SetupBuildPath(t, context)
158+
defer os.RemoveAll(buildPath)
159+
160+
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600"
161+
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}
162+
context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools", "./tools_builtin"}
163+
context[constants.CTX_FQBN] = "arduino:avr:uno"
164+
context[constants.CTX_SKETCH_LOCATION] = filepath.Join("sketch1", "sketch.ino")
165+
context[constants.CTX_CUSTOM_BUILD_PROPERTIES] = []string{"name=fake name", "tools.avrdude.config.path=non existent path with space and a ="}
166+
167+
commands := []types.Command{
168+
&builder.SetupHumanLoggerIfMissing{},
169+
&builder.AddAdditionalEntriesToContext{},
170+
&builder.HardwareLoader{},
171+
&builder.ToolsLoader{},
172+
&builder.TargetBoardResolver{},
173+
&builder.SketchLoader{},
174+
}
175+
176+
for _, command := range commands {
177+
err := command.Run(context)
178+
NoError(t, err)
179+
}
180+
181+
targetPlatform := context[constants.CTX_TARGET_PLATFORM].(*types.Platform)
182+
delete(targetPlatform.Properties, constants.BUILD_PROPERTIES_COMPILER_PATH)
183+
184+
command := builder.SetupBuildProperties{}
185+
err := command.Run(context)
186+
require.Error(t, err)
187+
188+
require.Equal(t, i18n.Format(constants.MSG_MISSING_COMPILER_PATH, "arduino", "avr"), err.Error())
189+
}

0 commit comments

Comments
 (0)