Skip to content

Commit 1059719

Browse files
facchinmcmaglie
authored andcommitted
Add -package-index optional CLI switch
Will be used to pass folders containing package_index jsons
1 parent 8b1c1eb commit 1059719

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

arduino-builder/main.go

+10
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const FLAG_HARDWARE = "hardware"
5959
const FLAG_TOOLS = "tools"
6060
const FLAG_BUILT_IN_LIBRARIES = "built-in-libraries"
6161
const FLAG_LIBRARIES = "libraries"
62+
const FLAG_PACKAGE_JSON = "package-index"
6263
const FLAG_PREFS = "prefs"
6364
const FLAG_FQBN = "fqbn"
6465
const FLAG_IDE_VERSION = "ide-version"
@@ -123,6 +124,7 @@ var hardwareFoldersFlag foldersFlag
123124
var toolsFoldersFlag foldersFlag
124125
var librariesBuiltInFoldersFlag foldersFlag
125126
var librariesFoldersFlag foldersFlag
127+
var jsonFoldersFlag foldersFlag
126128
var customBuildPropertiesFlag propertiesFlag
127129
var fqbnFlag *string
128130
var coreAPIVersionFlag *string
@@ -146,6 +148,7 @@ func init() {
146148
flag.Var(&toolsFoldersFlag, FLAG_TOOLS, "Specify a 'tools' folder. Can be added multiple times for specifying multiple 'tools' folders")
147149
flag.Var(&librariesBuiltInFoldersFlag, FLAG_BUILT_IN_LIBRARIES, "Specify a built-in 'libraries' folder. These are low priority libraries. Can be added multiple times for specifying multiple built-in 'libraries' folders")
148150
flag.Var(&librariesFoldersFlag, FLAG_LIBRARIES, "Specify a 'libraries' folder. Can be added multiple times for specifying multiple 'libraries' folders")
151+
flag.Var(&jsonFoldersFlag, FLAG_PACKAGE_JSON, "Specify a folder containing package_index json files. Can be added multiple times for specifying multiple folders")
149152
flag.Var(&customBuildPropertiesFlag, FLAG_PREFS, "Specify a custom preference. Can be added multiple times for specifying multiple custom preferences")
150153
fqbnFlag = flag.String(FLAG_FQBN, "", "fully qualified board name")
151154
coreAPIVersionFlag = flag.String(FLAG_CORE_API_VERSION, "10600", "version of core APIs (used to populate ARDUINO #define)")
@@ -217,6 +220,13 @@ func main() {
217220
ctx.OtherLibrariesFolders = librariesFolders
218221
}
219222

223+
// FLAG_PACKAGE_JSON
224+
if jsonFolders, err := toSliceOfUnquoted(jsonFoldersFlag); err != nil {
225+
printCompleteError(err)
226+
} else if len(jsonFolders) > 0 {
227+
ctx.JsonFolders = jsonFolders
228+
}
229+
220230
// FLAG_BUILT_IN_LIBRARIES
221231
if librariesBuiltInFolders, err := toSliceOfUnquoted(librariesBuiltInFoldersFlag); err != nil {
222232
printCompleteError(err)

types/context.go

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Context struct {
1515
LibrariesFolders []string
1616
BuiltInLibrariesFolders []string
1717
OtherLibrariesFolders []string
18+
JsonFolders []string
1819
SketchLocation string
1920
ArduinoAPIVersion string
2021
FQBN string

0 commit comments

Comments
 (0)