@@ -42,19 +42,31 @@ type CreateBuildOptionsMap struct{}
4242func (s * CreateBuildOptionsMap ) Run (context map [string ]interface {}) error {
4343 buildOptions := make (map [string ]string )
4444
45- for _ , key := range []string {constants .CTX_HARDWARE_FOLDERS , constants .CTX_TOOLS_FOLDERS , constants .CTX_LIBRARIES_FOLDERS , constants .CTX_FQBN , constants .CTX_SKETCH_LOCATION , constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION } {
46- originalValue := context [key ]
47- value := constants .EMPTY_STRING
48- kindOfValue := reflect .TypeOf (originalValue ).Kind ()
49- if kindOfValue == reflect .Slice {
50- value = strings .Join (originalValue .([]string ), "," )
51- } else if kindOfValue == reflect .String {
52- value = originalValue .(string )
53- } else {
54- return utils .Errorf (context , constants .MSG_UNHANDLED_TYPE_IN_CONTEXT , kindOfValue .String (), key )
55- }
45+ buildOptionsMapKeys := []string {
46+ constants .CTX_HARDWARE_FOLDERS ,
47+ constants .CTX_TOOLS_FOLDERS ,
48+ constants .CTX_LIBRARIES_FOLDERS ,
49+ constants .CTX_FQBN ,
50+ constants .CTX_SKETCH_LOCATION ,
51+ constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ,
52+ constants .CTX_CUSTOM_BUILD_PROPERTIES ,
53+ }
5654
57- buildOptions [key ] = value
55+ for _ , key := range buildOptionsMapKeys {
56+ if utils .MapHas (context , key ) {
57+ originalValue := context [key ]
58+ value := constants .EMPTY_STRING
59+ kindOfValue := reflect .TypeOf (originalValue ).Kind ()
60+ if kindOfValue == reflect .Slice {
61+ value = strings .Join (originalValue .([]string ), "," )
62+ } else if kindOfValue == reflect .String {
63+ value = originalValue .(string )
64+ } else {
65+ return utils .Errorf (context , constants .MSG_UNHANDLED_TYPE_IN_CONTEXT , kindOfValue .String (), key )
66+ }
67+
68+ buildOptions [key ] = value
69+ }
5870 }
5971
6072 context [constants .CTX_BUILD_OPTIONS ] = buildOptions
0 commit comments