@@ -18,7 +18,6 @@ package sketch
1818import (
1919 "crypto/md5"
2020 "encoding/hex"
21- "encoding/json"
2221 "fmt"
2322 "sort"
2423 "strings"
@@ -38,23 +37,9 @@ type Sketch struct {
3837 OtherSketchFiles paths.PathList // Sketch files that end in .ino other than main file
3938 AdditionalFiles paths.PathList
4039 RootFolderFiles paths.PathList // All files that are in the Sketch root
41- Metadata * Metadata
4240 Project * Project
4341}
4442
45- // Metadata is the kind of data associated to a project such as the connected board
46- type Metadata struct {
47- CPU BoardMetadata `json:"cpu,omitempty"`
48- }
49-
50- // BoardMetadata represents the board metadata for the sketch
51- type BoardMetadata struct {
52- Fqbn string `json:"fqbn"`
53- Name string `json:"name,omitempty"`
54- Port string `json:"port,omitempty"`
55- Protocol string `json:"protocol,omitempty"`
56- }
57-
5843var tr = i18n .Tr
5944
6045// New creates an Sketch instance by reading all the files composing a sketch and grouping them
@@ -100,7 +85,6 @@ func New(path *paths.Path) (*Sketch, error) {
10085 OtherSketchFiles : paths.PathList {},
10186 AdditionalFiles : paths.PathList {},
10287 RootFolderFiles : paths.PathList {},
103- Metadata : new (Metadata ),
10488 Project : & Project {},
10589 }
10690
@@ -170,9 +154,6 @@ func New(path *paths.Path) (*Sketch, error) {
170154 sort .Sort (& sketch .OtherSketchFiles )
171155 sort .Sort (& sketch .RootFolderFiles )
172156
173- if err := sketch .importMetadata (); err != nil {
174- return nil , fmt .Errorf (tr ("importing sketch metadata: %s" ), err )
175- }
176157 return sketch , nil
177158}
178159
@@ -197,46 +178,6 @@ func (s *Sketch) supportedFiles() (*paths.PathList, error) {
197178
198179}
199180
200- // ImportMetadata imports metadata into the sketch from a sketch.json file in the root
201- // path of the sketch.
202- func (s * Sketch ) importMetadata () error {
203- sketchJSON := s .FullPath .Join ("sketch.json" )
204- if sketchJSON .NotExist () {
205- // File doesn't exist, nothing to import
206- return nil
207- }
208-
209- content , err := sketchJSON .ReadFile ()
210- if err != nil {
211- return fmt .Errorf (tr ("reading sketch metadata %[1]s: %[2]s" ), sketchJSON , err )
212- }
213- var meta Metadata
214- err = json .Unmarshal (content , & meta )
215- if err != nil {
216- if s .Metadata == nil {
217- s .Metadata = new (Metadata )
218- }
219- return fmt .Errorf (tr ("encoding sketch metadata: %s" ), err )
220- }
221- s .Metadata = & meta
222- return nil
223- }
224-
225- // ExportMetadata writes sketch metadata into a sketch.json file in the root path of
226- // the sketch
227- func (s * Sketch ) ExportMetadata () error {
228- d , err := json .MarshalIndent (& s .Metadata , "" , " " )
229- if err != nil {
230- return fmt .Errorf (tr ("decoding sketch metadata: %s" ), err )
231- }
232-
233- sketchJSON := s .FullPath .Join ("sketch.json" )
234- if err := sketchJSON .WriteFile (d ); err != nil {
235- return fmt .Errorf (tr ("writing sketch metadata %[1]s: %[2]s" ), sketchJSON , err )
236- }
237- return nil
238- }
239-
240181// GetProfile returns the requested profile or nil if the profile
241182// is not found.
242183func (s * Sketch ) GetProfile (profileName string ) * Profile {
0 commit comments