Skip to content

Commit d661e83

Browse files
author
Federico Fissore
committed
RUNTIME_PLATFORM_PATH and RUNTIME_HARDWARE_PATH point to target platform path,
not actual. Fixes #20 Signed-off-by: Federico Fissore <[email protected]>
1 parent 24ac2c1 commit d661e83

File tree

6 files changed

+48
-112
lines changed

6 files changed

+48
-112
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (s *IncludesToIncludeFolders) Run(context map[string]interface{}) error {
5656
if utils.MapHas(context, constants.CTX_IMPORTED_LIBRARIES) {
5757
previousImportedLibraries = context[constants.CTX_IMPORTED_LIBRARIES].([]*types.Library)
5858
}
59-
importedLibraries, err := resolveLibraries(includes, headerToLibraries, previousImportedLibraries, []*types.Platform{actualPlatform, platform}, debugLevel, logger)
59+
importedLibraries, err := resolveLibraries(includes, headerToLibraries, previousImportedLibraries, []*types.Platform{platform, actualPlatform}, debugLevel, logger)
6060
if err != nil {
6161
return utils.WrapError(err)
6262
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func (s *SetupBuildProperties) Run(context map[string]interface{}) error {
6464
buildProperties[constants.BUILD_PROPERTIES_BUILD_CORE] = context[constants.CTX_BUILD_CORE].(string)
6565
buildProperties[constants.BUILD_PROPERTIES_BUILD_CORE_PATH] = filepath.Join(actualPlatform.Folder, constants.FOLDER_CORES, buildProperties[constants.BUILD_PROPERTIES_BUILD_CORE])
6666
buildProperties[constants.BUILD_PROPERTIES_BUILD_SYSTEM_PATH] = filepath.Join(actualPlatform.Folder, constants.FOLDER_SYSTEM)
67-
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH] = actualPlatform.Folder
68-
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_HARDWARE_PATH] = filepath.Join(actualPlatform.Folder, "..")
67+
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH] = targetPlatform.Folder
68+
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_HARDWARE_PATH] = filepath.Join(targetPlatform.Folder, "..")
6969
buildProperties[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION].(string)
7070
buildProperties[constants.IDE_VERSION] = context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION].(string)
7171
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_OS] = utils.PrettyOSName()

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

-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,6 @@ func TestLoadHardwareMixingUserHardwareFolder(t *testing.T) {
126126
require.NotNil(t, packages["my_avr_platform"])
127127
myAVRPlatform := packages["my_avr_platform"].Platforms["avr"]
128128
require.Equal(t, "custom_yun", myAVRPlatform.Boards["custom_yun"].BoardId)
129-
require.Equal(t, "{path}/ctags", myAVRPlatform.Properties["tools.ctags.cmd.path"])
130-
require.Equal(t, "{runtime.tools.avr-gcc.path}/bin/", myAVRPlatform.Properties[constants.BUILD_PROPERTIES_COMPILER_PATH])
131-
require.Equal(t, "{runtime.tools.avrdude.path}", myAVRPlatform.Properties["tools.avrdude.path"])
132-
require.Equal(t, "{path}/bin/avrdude", myAVRPlatform.Properties["tools.avrdude.cmd.path"])
133-
require.Equal(t, "{path}/etc/avrdude.conf", myAVRPlatform.Properties["tools.avrdude.config.path"])
134-
135-
require.Equal(t, "-w -x c++ -M -MG -MP", myAVRPlatform.Properties["preproc.includes.flags"])
136-
require.Equal(t, "-w -x c++ -E -CC", myAVRPlatform.Properties["preproc.macros.flags"])
137129

138130
if runtime.GOOS != "windows" {
139131
require.NotNil(t, packages["my_symlinked_avr_platform"])

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

+39
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,42 @@ func TestSetupBuildPropertiesWithSomeCustomOverrides(t *testing.T) {
147147
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"])
148148
require.Equal(t, "non existent path with space and a =", buildProperties["tools.avrdude.config.path"])
149149
}
150+
151+
func TestSetupBuildPropertiesUserHardware(t *testing.T) {
152+
DownloadCoresAndToolsAndLibraries(t)
153+
154+
context := make(map[string]interface{})
155+
156+
buildPath := SetupBuildPath(t, context)
157+
defer os.RemoveAll(buildPath)
158+
159+
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600"
160+
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware", "user_hardware"}
161+
context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools", "./tools_builtin"}
162+
context[constants.CTX_FQBN] = "my_avr_platform:avr:custom_yun"
163+
context[constants.CTX_SKETCH_LOCATION] = filepath.Join("sketch1", "sketch.ino")
164+
165+
commands := []types.Command{
166+
&builder.SetupHumanLoggerIfMissing{},
167+
&builder.AddAdditionalEntriesToContext{},
168+
&builder.HardwareLoader{},
169+
&builder.ToolsLoader{},
170+
&builder.TargetBoardResolver{},
171+
&builder.SketchLoader{},
172+
&builder.SetupBuildProperties{},
173+
}
174+
175+
for _, command := range commands {
176+
err := command.Run(context)
177+
NoError(t, err)
178+
}
179+
180+
buildProperties := context[constants.CTX_BUILD_PROPERTIES].(map[string]string)
181+
182+
require.Equal(t, "ARDUINO", buildProperties[constants.BUILD_PROPERTIES_SOFTWARE])
183+
184+
require.Equal(t, "custom_yun", buildProperties[constants.ID])
185+
require.Equal(t, "caterina/Caterina-custom_yun.hex", buildProperties[constants.BUILD_PROPERTIES_BOOTLOADER_FILE])
186+
require.Equal(t, Abs(t, filepath.Join("user_hardware", "my_avr_platform", "avr")), buildProperties[constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH])
187+
require.Equal(t, Abs(t, filepath.Join("user_hardware", "my_avr_platform")), buildProperties[constants.BUILD_PROPERTIES_RUNTIME_HARDWARE_PATH])
188+
}

Diff for: src/arduino.cc/builder/test/user_hardware/my_avr_platform/avr/boards.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
custom_yun.name=Arduino Yún
22
custom_yun.upload.via_ssh=true
33

4+
custom_yun.build.core=arduino:arduino
5+
custom_yun.bootloader.tool=arduino:avrdude
6+
custom_yun.upload.tool=arduino:avrdude
7+
48
custom_yun.vid.0=0x2341
59
custom_yun.pid.0=0x0041
610
custom_yun.vid.1=0x2341
711
custom_yun.pid.1=0x8041
8-
custom_yun.upload.tool=avrdude
912
custom_yun.upload.protocol=avr109
1013
custom_yun.upload.maximum_size=28672
1114
custom_yun.upload.maximum_data_size=2560
@@ -14,7 +17,6 @@ custom_yun.upload.disable_flushing=true
1417
custom_yun.upload.use_1200bps_touch=true
1518
custom_yun.upload.wait_for_upload_port=true
1619

17-
custom_yun.bootloader.tool=avrdude
1820
custom_yun.bootloader.low_fuses=0xff
1921
custom_yun.bootloader.high_fuses=0xd8
2022
custom_yun.bootloader.extended_fuses=0xfb
@@ -28,7 +30,6 @@ custom_yun.build.vid=0x2341
2830
custom_yun.build.pid=0x8041
2931
custom_yun.build.usb_product="Arduino My"
3032
custom_yun.build.board=AVR_YUN
31-
custom_yun.build.core=arduino
3233
custom_yun.build.variant=yun
3334
custom_yun.build.extra_flags={build.usb_flags}
3435

Diff for: src/arduino.cc/builder/test/user_hardware/my_avr_platform/avr/platform.txt

+2-98
Original file line numberDiff line numberDiff line change
@@ -5,101 +5,5 @@
55
# For more info:
66
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
77

8-
name=Arduino AVR Boards
9-
version=1.6.0
10-
11-
# AVR compile variables
12-
# ---------------------
13-
14-
# Default "compiler.path" is correct, change only if you want to overidde the initial value
15-
compiler.path={runtime.ide.path}/hardware/tools/avr/bin/
16-
compiler.c.cmd=avr-gcc
17-
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
18-
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
19-
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
20-
compiler.c.elf.flags=-w -Os -Wl,--gc-sections
21-
compiler.c.elf.cmd=avr-gcc
22-
compiler.S.flags=-c -g -x assembler-with-cpp
23-
compiler.cpp.cmd=avr-g++
24-
compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
25-
compiler.ar.cmd=avr-ar
26-
compiler.ar.flags=rcs
27-
compiler.objcopy.cmd=avr-objcopy
28-
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
29-
compiler.elf2hex.flags=-O ihex -R .eeprom
30-
compiler.elf2hex.cmd=avr-objcopy
31-
compiler.ldflags=
32-
compiler.size.cmd=avr-size
33-
34-
# This can be overriden in boards.txt
35-
build.extra_flags=
36-
37-
# These can be overridden in platform.local.txt
38-
compiler.c.extra_flags=
39-
compiler.c.elf.extra_flags=
40-
compiler.S.extra_flags=
41-
compiler.cpp.extra_flags=
42-
compiler.ar.extra_flags=
43-
compiler.objcopy.eep.extra_flags=
44-
compiler.elf2hex.extra_flags=
45-
46-
# AVR compile patterns
47-
# --------------------
48-
49-
## Compile c files
50-
recipe.c.o.pattern="{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}"
51-
52-
## Compile c++ files
53-
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
54-
55-
## Compile S files
56-
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
57-
58-
## Create archives
59-
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
60-
61-
## Combine gc-sections, archives, and objects
62-
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
63-
64-
## Create eeprom
65-
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
66-
67-
## Create hex
68-
recipe.objcopy.output.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
69-
70-
## Compute size
71-
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
72-
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
73-
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
74-
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
75-
76-
77-
# AVR Uploader/Programmers tools
78-
# ------------------------------
79-
80-
tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude
81-
tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf
82-
83-
tools.avrdude.upload.params.verbose=-v
84-
tools.avrdude.upload.params.quiet=-q -q
85-
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
86-
87-
tools.avrdude.program.params.verbose=-v
88-
tools.avrdude.program.params.quiet=-q -q
89-
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
90-
91-
tools.avrdude.erase.params.verbose=-v
92-
tools.avrdude.erase.params.quiet=-q -q
93-
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
94-
95-
tools.avrdude.bootloader.params.verbose=-v
96-
tools.avrdude.bootloader.params.quiet=-q -q
97-
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
98-
99-
100-
# USB Default Flags
101-
# Default blank usb manufacturer will be filled it at compile time
102-
# - from numeric vendor ID, set to Unknown otherwise
103-
build.usb_manufacturer=
104-
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
105-
8+
name=My AVR Boards
9+
version=9.9.9

0 commit comments

Comments
 (0)