diff --git a/src/arduino.cc/builder/builder_utils/utils.go b/src/arduino.cc/builder/builder_utils/utils.go index 40d2f099..9c89209f 100644 --- a/src/arduino.cc/builder/builder_utils/utils.go +++ b/src/arduino.cc/builder/builder_utils/utils.go @@ -170,6 +170,7 @@ func ArchiveCompiledFiles(buildPath string, archiveFile string, objectFiles []st for _, objectFile := range objectFiles { properties := utils.MergeMapsOfStrings(make(map[string]string), buildProperties) properties[constants.BUILD_PROPERTIES_ARCHIVE_FILE] = filepath.Base(archiveFilePath) + properties[constants.BUILD_PROPERTIES_ARCHIVE_FILE_PATH] = archiveFilePath properties[constants.BUILD_PROPERTIES_OBJECT_FILE] = objectFile _, err := ExecRecipe(properties, constants.RECIPE_AR_PATTERN, false, verbose, verbose, logger) diff --git a/src/arduino.cc/builder/hardware/platform.keys.rewrite.txt b/src/arduino.cc/builder/hardware/platform.keys.rewrite.txt index 02bdf64f..4eb8c6c1 100644 --- a/src/arduino.cc/builder/hardware/platform.keys.rewrite.txt +++ b/src/arduino.cc/builder/hardware/platform.keys.rewrite.txt @@ -23,3 +23,6 @@ new.6.recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -mcpu={buil #specific to RFduino 1.6.3 old.7.recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} {build.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" -Wl,--cref -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group "{build.path}/syscalls.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.variant.path}/libRFduino.a" "{build.variant.path}/libRFduinoBLE.a" "{build.variant.path}/libRFduinoGZLL.a" "{build.path}/{archive_file}" -Wl,--end-group new.7.recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} {build.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" -Wl,--cref -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group "{build.path}/core/syscalls.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.variant.path}/libRFduino.a" "{build.variant.path}/libRFduinoBLE.a" "{build.variant.path}/libRFduinoGZLL.a" "{build.path}/{archive_file}" -Wl,--end-group + +old.8.recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}" +new.8.recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" \ No newline at end of file diff --git a/src/arduino.cc/builder/phases/libraries_builder.go b/src/arduino.cc/builder/phases/libraries_builder.go index 6cf1d855..d2626518 100644 --- a/src/arduino.cc/builder/phases/libraries_builder.go +++ b/src/arduino.cc/builder/phases/libraries_builder.go @@ -93,6 +93,13 @@ func compileLibrary(objectFiles []string, library *types.Library, buildPath stri if err != nil { return nil, utils.WrapError(err) } + if library.DotALinkage { + archiveFile, err := builder_utils.ArchiveCompiledFiles(libraryBuildPath, library.Name+".a", objectFiles, buildProperties, verbose, logger) + if err != nil { + return nil, utils.WrapError(err) + } + objectFiles = []string{archiveFile} + } } else { utilitySourcePath := filepath.Join(library.SrcFolder, constants.LIBRARY_FOLDER_UTILITY) _, utilitySourcePathErr := os.Stat(utilitySourcePath) diff --git a/src/arduino.cc/builder/phases/linker.go b/src/arduino.cc/builder/phases/linker.go index a45e9c5c..ec055e0b 100644 --- a/src/arduino.cc/builder/phases/linker.go +++ b/src/arduino.cc/builder/phases/linker.go @@ -49,13 +49,18 @@ func (s *Linker) Run(context map[string]interface{}) error { objectFiles = append(objectFiles, objectFilesLibraries...) coreArchiveFilePath := context[constants.CTX_ARCHIVE_FILE_PATH_CORE].(string) + buildPath := context[constants.CTX_BUILD_PATH].(string) + coreDotARelPath, err := filepath.Rel(buildPath, coreArchiveFilePath) + if err != nil { + return utils.WrapError(err) + } buildProperties := context[constants.CTX_BUILD_PROPERTIES].(map[string]string) verbose := context[constants.CTX_VERBOSE].(bool) warningsLevel := context[constants.CTX_WARNINGS_LEVEL].(string) logger := context[constants.CTX_LOGGER].(i18n.Logger) - err := link(objectFiles, coreArchiveFilePath, buildProperties, verbose, warningsLevel, logger) + err = link(objectFiles, coreDotARelPath, buildProperties, verbose, warningsLevel, logger) if err != nil { return utils.WrapError(err) } @@ -72,8 +77,7 @@ func link(objectFiles []string, coreArchiveFilePath string, buildProperties map[ properties := utils.MergeMapsOfStrings(make(map[string]string), buildProperties) properties[constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS] = properties[constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS] + optRelax properties[constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS] = properties[constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS+"."+warningsLevel] - properties[constants.BUILD_PROPERTIES_ARCHIVE_FILE] = filepath.Base(coreArchiveFilePath) - properties[constants.BUILD_PROPERTIES_ARCHIVE_FILE_PATH] = coreArchiveFilePath + properties[constants.BUILD_PROPERTIES_ARCHIVE_FILE] = coreArchiveFilePath properties[constants.BUILD_PROPERTIES_OBJECT_FILES] = objectFileList _, err := builder_utils.ExecRecipe(properties, constants.RECIPE_C_COMBINE_PATTERN, false, verbose, verbose, logger) diff --git a/src/arduino.cc/builder/test/platform_keys_rewrite_loader_test.go b/src/arduino.cc/builder/test/platform_keys_rewrite_loader_test.go index 49af842d..ef42503e 100644 --- a/src/arduino.cc/builder/test/platform_keys_rewrite_loader_test.go +++ b/src/arduino.cc/builder/test/platform_keys_rewrite_loader_test.go @@ -48,7 +48,7 @@ func TestLoadPlatformKeysRewrite(t *testing.T) { platformKeysRewrite := context[constants.CTX_PLATFORM_KEYS_REWRITE].(types.PlatforKeysRewrite) - require.Equal(t, 8, len(platformKeysRewrite.Rewrites)) + require.Equal(t, 9, len(platformKeysRewrite.Rewrites)) require.Equal(t, constants.BUILD_PROPERTIES_COMPILER_PATH, platformKeysRewrite.Rewrites[0].Key) require.Equal(t, "{runtime.ide.path}/hardware/tools/avr/bin/", platformKeysRewrite.Rewrites[0].OldValue) require.Equal(t, "{runtime.tools.avr-gcc.path}/bin/", platformKeysRewrite.Rewrites[0].NewValue)