#NEWLINE# def fill_project_envs( ctx , platformio_ini , board_types , enable_auto_uploading , env_prefix , force_download ) : #NEWLINE# #INDENT# builtin_boards = get_boards ( ) #NEWLINE# content = [ ] #NEWLINE# used_boards = [ ] #NEWLINE# used_platforms = [ ] #NEWLINE# config = util . get_project_config ( platformio_ini ) #NEWLINE# for section in config . sections ( ) : #NEWLINE# #INDENT# if ( not all ( [ section . startswith ( 'env:' ) , config . has_option ( section , 'board' ) ] ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# used_boards . append ( config . get ( section , 'board' ) ) #NEWLINE# #UNINDENT# for type_ in board_types : #NEWLINE# #INDENT# data = builtin_boards [ type_ ] #NEWLINE# used_platforms . append ( data [ 'platform' ] ) #NEWLINE# if ( type_ in used_boards ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# content . append ( '' ) #NEWLINE# content . append ( ( '[env:%s%s]' % ( env_prefix , type_ ) ) ) #NEWLINE# content . append ( ( 'platform = %s' % data [ 'platform' ] ) ) #NEWLINE# frameworks = data . get ( 'frameworks' ) #NEWLINE# if frameworks : #NEWLINE# #INDENT# content . append ( ( 'framework = %s' % frameworks [ 0 ] ) ) #NEWLINE# #UNINDENT# content . append ( ( 'board = %s' % type_ ) ) #NEWLINE# if enable_auto_uploading : #NEWLINE# #INDENT# content . append ( 'targets = upload' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( force_download and used_platforms ) : #NEWLINE# #INDENT# _install_dependent_platforms ( ctx , used_platforms ) #NEWLINE# #UNINDENT# if ( not used_boards ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# with open ( platformio_ini , 'a' ) as f : #NEWLINE# #INDENT# content . append ( '' ) #NEWLINE# f . write ( '\n' . join ( content ) )