Skip to content

Commit 0e5e6fa

Browse files
facchinmcmaglie
authored andcommitted
Use specified package_index name to filter results
1 parent e0804ac commit 0e5e6fa

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

add_missing_build_properties_from_parent_platform_txt_files.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
package builder
3131

3232
import (
33+
"strings"
34+
3335
"github.com/arduino/arduino-builder/constants"
3436
"github.com/arduino/arduino-builder/json_package_index"
3537
"github.com/arduino/arduino-builder/types"
@@ -57,7 +59,8 @@ func (s *OverridePropertiesWithJsonInfo) Run(ctx *types.Context) error {
5759

5860
if ctx.JsonFolders != nil {
5961

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

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

constants/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,6 @@ const SKETCH_FOLDER_SRC = "src"
232232
const TOOL_NAME = "name"
233233
const TOOL_URL = "url"
234234
const TOOL_VERSION = "version"
235+
const ADDITIONALE_BOARD_MANAGER_JSON = "boardsmanager.additional.urls"
235236
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
236237
const HACK_PROPERTIES_AVR_GCC_OLD = BUILD_PROPERTIES_RUNTIME_TOOLS_PREFIX + "avr-gcc-arduino-4.8.1-arduino5" + BUILD_PROPERTIES_RUNTIME_TOOLS_SUFFIX

json_package_index/package_index.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import (
4343
"github.com/arduino/arduino-builder/constants"
4444
_ "github.com/arduino/arduino-builder/i18n"
4545
"github.com/arduino/arduino-builder/types"
46-
properties "github.com/arduino/go-properties-map"
46+
"github.com/arduino/arduino-builder/utils"
47+
"github.com/arduino/go-properties-map"
4748
)
4849

4950
type core struct {
@@ -101,7 +102,7 @@ var systems = map[string]string{
101102

102103
var globalProperties map[string]properties.Map
103104

104-
func PackageIndexFoldersToPropertiesMap(packages *types.Packages, folders []string) (map[string]properties.Map, error) {
105+
func PackageIndexFoldersToPropertiesMap(packages *types.Packages, folders []string, specifiedFilenames []string) (map[string]properties.Map, error) {
105106

106107
var paths []string
107108

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

0 commit comments

Comments
 (0)