Skip to content

Commit 1372f3c

Browse files
committed
Readded deprecated '-ide-version' for backward compatibility
Signed-off-by: Cristian Maglie <[email protected]>
1 parent 07504d7 commit 1372f3c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

main.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const FLAG_BUILT_IN_LIBRARIES = "built-in-libraries"
6060
const FLAG_LIBRARIES = "libraries"
6161
const FLAG_PREFS = "prefs"
6262
const FLAG_FQBN = "fqbn"
63-
const FLAG_IDE_VERSION = "core-api-version"
63+
const FLAG_IDE_VERSION = "ide-version"
64+
const FLAG_CORE_API_VERSION = "core-api-version"
6465
const FLAG_BUILD_PATH = "build-path"
6566
const FLAG_VERBOSE = "verbose"
6667
const FLAG_QUIET = "quiet"
@@ -108,6 +109,7 @@ var librariesBuiltInFoldersFlag slice
108109
var librariesFoldersFlag slice
109110
var customBuildPropertiesFlag slice
110111
var fqbnFlag *string
112+
var coreAPIVersionFlag *string
111113
var ideVersionFlag *string
112114
var buildPathFlag *string
113115
var verboseFlag *bool
@@ -129,7 +131,8 @@ func init() {
129131
flag.Var(&librariesFoldersFlag, FLAG_LIBRARIES, "Specify a 'libraries' folder. Can be added multiple times for specifying multiple 'libraries' folders")
130132
flag.Var(&customBuildPropertiesFlag, FLAG_PREFS, "Specify a custom preference. Can be added multiple times for specifying multiple custom preferences")
131133
fqbnFlag = flag.String(FLAG_FQBN, "", "fully qualified board name")
132-
ideVersionFlag = flag.String(FLAG_IDE_VERSION, "10600", "fake IDE version")
134+
coreAPIVersionFlag = flag.String(FLAG_CORE_API_VERSION, "10600", "version of core APIs (used to populate ARDUINO #define)")
135+
ideVersionFlag = flag.String(FLAG_IDE_VERSION, "10600", "[deprecated] use '"+FLAG_CORE_API_VERSION+"' instead")
133136
buildPathFlag = flag.String(FLAG_BUILD_PATH, "", "build path")
134137
verboseFlag = flag.Bool(FLAG_VERBOSE, false, "if 'true' prints lots of stuff")
135138
quietFlag = flag.Bool(FLAG_QUIET, false, "if 'true' doesn't print any warnings or progress or whatever")
@@ -274,13 +277,18 @@ func main() {
274277

275278
context[constants.CTX_VERBOSE] = *verboseFlag
276279

277-
ideVersion := ""
280+
coreAPIVersion := ""
278281
if utils.MapStringStringHas(buildOptions, constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION) {
279-
ideVersion = buildOptions[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION]
282+
coreAPIVersion = buildOptions[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION]
280283
} else {
281-
ideVersion = *ideVersionFlag
284+
// if deprecated 'ideVersionFlag' has been used...
285+
if *coreAPIVersionFlag == "10600" && *ideVersionFlag != "10600" {
286+
coreAPIVersion = *ideVersionFlag
287+
} else {
288+
coreAPIVersion = *coreAPIVersionFlag
289+
}
282290
}
283-
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = ideVersion
291+
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = coreAPIVersion
284292

285293
if *warningsLevelFlag != "" {
286294
context[constants.CTX_WARNINGS_LEVEL] = *warningsLevelFlag

0 commit comments

Comments
 (0)