Skip to content

Commit 58963e4

Browse files
committed
Use specified package_index name to filter results
1 parent 538317c commit 58963e4

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/arduino.cc/builder/add_missing_build_properties_from_parent_platform_txt_files.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"arduino.cc/builder/constants"
3434
"arduino.cc/builder/types"
3535
"arduino.cc/json_package_index"
36+
"strings"
3637
)
3738

3839
type AddMissingBuildPropertiesFromParentPlatformTxtFiles struct{}
@@ -57,7 +58,8 @@ func (s *OverridePropertiesWithJsonInfo) Run(ctx *types.Context) error {
5758

5859
if ctx.JsonFolders != nil {
5960

60-
jsonProperties, err := json_package_index.PackageIndexFoldersToPropertiesMap(ctx.Hardware, ctx.JsonFolders)
61+
allowedJsons := strings.Split(ctx.BuildProperties[constants.ADDITIONALE_BOARD_MANAGER_JSON], ",")
62+
jsonProperties, err := json_package_index.PackageIndexFoldersToPropertiesMap(ctx.Hardware, ctx.JsonFolders, allowedJsons)
6163

6264
if err != nil {
6365
// doesn't matter, log the broken package in verbose mode

src/arduino.cc/builder/constants/constants.go

+1
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,6 @@ const SKETCH_FOLDER_SRC = "src"
210210
const TOOL_NAME = "name"
211211
const TOOL_URL = "url"
212212
const TOOL_VERSION = "version"
213+
const ADDITIONALE_BOARD_MANAGER_JSON = "boardsmanager.additional.urls"
213214
const HACK_PROPERTIES_AVR_GCC_NEW = BUILD_PROPERTIES_RUNTIME_TOOLS_PREFIX + "avr-gcc-arduino-4.9.2-atmel3.5.3-arduino2" + BUILD_PROPERTIES_RUNTIME_TOOLS_SUFFIX
214215
const HACK_PROPERTIES_AVR_GCC_OLD = BUILD_PROPERTIES_RUNTIME_TOOLS_PREFIX + "avr-gcc-arduino-4.8.1-arduino5" + BUILD_PROPERTIES_RUNTIME_TOOLS_SUFFIX

src/arduino.cc/json_package_index/package_index.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"arduino.cc/builder/constants"
3434
_ "arduino.cc/builder/i18n"
3535
"arduino.cc/builder/types"
36+
"arduino.cc/builder/utils"
3637
"arduino.cc/properties"
3738
"encoding/json"
3839
"errors"
@@ -99,7 +100,7 @@ var systems = map[string]string{
99100

100101
var globalProperties map[string]properties.Map
101102

102-
func PackageIndexFoldersToPropertiesMap(packages *types.Packages, folders []string) (map[string]properties.Map, error) {
103+
func PackageIndexFoldersToPropertiesMap(packages *types.Packages, folders []string, specifiedFilenames []string) (map[string]properties.Map, error) {
103104

104105
var paths []string
105106

@@ -111,7 +112,13 @@ func PackageIndexFoldersToPropertiesMap(packages *types.Packages, folders []stri
111112
files, _ := ioutil.ReadDir(folder)
112113
for _, f := range files {
113114
if strings.HasPrefix(f.Name(), "package") && strings.HasSuffix(f.Name(), "index.json") {
114-
paths = append(paths, filepath.Join(folder, f.Name()))
115+
// if a list of required json has been provided only add them
116+
if specifiedFilenames != nil && len(specifiedFilenames) > 1 &&
117+
!utils.SliceContains(specifiedFilenames, f.Name()) {
118+
continue
119+
} else {
120+
paths = append(paths, filepath.Join(folder, f.Name()))
121+
}
115122
}
116123
}
117124
}

0 commit comments

Comments
 (0)