Skip to content

Commit 1ab82ed

Browse files
committed
Added builtin:mdns-discovery
1 parent c5159d1 commit 1ab82ed

File tree

3 files changed

+122
-1
lines changed

3 files changed

+122
-1
lines changed

Diff for: arduino/cores/packagemanager/loader.go

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ func (pm *PackageManager) loadPlatformRelease(platform *cores.PlatformRelease, p
325325
platform.PluggableDiscoveryAware = true
326326
} else {
327327
platform.Properties.Set("discovery.required.0", "builtin:serial-discovery")
328+
platform.Properties.Set("discovery.required.1", "builtin:mdns-discovery")
328329
}
329330

330331
if platform.Platform.Name == "" {

Diff for: commands/bundled_tools_mdns_discovery.go

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2021 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to license@arduino.cc.
15+
16+
package commands
17+
18+
import (
19+
"fmt"
20+
21+
"github.com/arduino/arduino-cli/arduino/cores"
22+
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
23+
"github.com/arduino/arduino-cli/arduino/resources"
24+
semver "go.bug.st/relaxed-semver"
25+
)
26+
27+
var (
28+
mdnsDiscoveryVersion = semver.ParseRelaxed("1.0.0")
29+
mdnsDiscoveryFlavors = []*cores.Flavor{
30+
{
31+
OS: "i686-pc-linux-gnu",
32+
Resource: &resources.DownloadResource{
33+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_32bit.tar.bz2", mdnsDiscoveryVersion),
34+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_32bit.tar.gz", mdnsDiscoveryVersion),
35+
Size: 0,
36+
Checksum: "SHA-256:",
37+
CachePath: "tools",
38+
},
39+
},
40+
{
41+
OS: "x86_64-pc-linux-gnu",
42+
Resource: &resources.DownloadResource{
43+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_64bit.tar.bz2", mdnsDiscoveryVersion),
44+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_64bit.tar.gz", mdnsDiscoveryVersion),
45+
Size: 0,
46+
Checksum: "SHA-256:",
47+
CachePath: "tools",
48+
},
49+
},
50+
{
51+
OS: "i686-mingw32",
52+
Resource: &resources.DownloadResource{
53+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Windows_32bit.zip", mdnsDiscoveryVersion),
54+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Windows_32bit.zip", mdnsDiscoveryVersion),
55+
Size: 0,
56+
Checksum: "SHA-256:",
57+
CachePath: "tools",
58+
},
59+
},
60+
{
61+
OS: "x86_64-mingw32",
62+
Resource: &resources.DownloadResource{
63+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Windows_64bit.zip", mdnsDiscoveryVersion),
64+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Windows_64bit.zip", mdnsDiscoveryVersion),
65+
Size: 0,
66+
Checksum: "SHA-256:",
67+
CachePath: "tools",
68+
},
69+
},
70+
{
71+
OS: "x86_64-apple-darwin",
72+
Resource: &resources.DownloadResource{
73+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_macOS_64bit.tar.bz2", mdnsDiscoveryVersion),
74+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_macOS_64bit.tar.gz", mdnsDiscoveryVersion),
75+
Size: 0,
76+
Checksum: "SHA-256:",
77+
CachePath: "tools",
78+
},
79+
},
80+
{
81+
OS: "arm-linux-gnueabihf",
82+
Resource: &resources.DownloadResource{
83+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_ARMv6.tar.bz2", mdnsDiscoveryVersion),
84+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_ARMv6.tar.gz", mdnsDiscoveryVersion),
85+
Size: 0,
86+
Checksum: "SHA-256:",
87+
CachePath: "tools",
88+
},
89+
},
90+
{
91+
OS: "arm64-linux-gnueabihf",
92+
Resource: &resources.DownloadResource{
93+
ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_ARM64.tar.bz2", mdnsDiscoveryVersion),
94+
URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_ARM64.tar.gz", mdnsDiscoveryVersion),
95+
Size: 0,
96+
Checksum: "SHA-256:",
97+
CachePath: "tools",
98+
},
99+
},
100+
}
101+
)
102+
103+
func getBuiltinMDNSDiscoveryTool(pm *packagemanager.PackageManager) *cores.ToolRelease {
104+
builtinPackage := pm.Packages.GetOrCreatePackage("builtin")
105+
mdnsDiscoveryTool := builtinPackage.GetOrCreateTool("mdns-discovery")
106+
mdnsDiscoveryToolRel := mdnsDiscoveryTool.GetOrCreateRelease(mdnsDiscoveryVersion)
107+
mdnsDiscoveryToolRel.Flavors = mdnsDiscoveryFlavors
108+
return mdnsDiscoveryToolRel
109+
}

Diff for: commands/instances.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) *sta
183183
instance.PackageManager.Clear()
184184
ctagsTool := getBuiltinCtagsTool(instance.PackageManager)
185185
serialDiscoveryTool := getBuiltinSerialDiscoveryTool(instance.PackageManager)
186+
mdnsDiscoveryTool := getBuiltinMDNSDiscoveryTool(instance.PackageManager)
186187

187188
// Load Platforms
188189
urls := []string{globals.DefaultIndexURL}
@@ -276,7 +277,17 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) *sta
276277
})
277278
}
278279

279-
if ctagsHasBeenInstalled || serialHasBeenInstalled {
280+
mdnsHasBeenInstalled, err := instance.installToolIfMissing(mdnsDiscoveryTool, downloadCallback, taskCallback)
281+
if err != nil {
282+
s := status.Newf(codes.Internal, err.Error())
283+
responseCallback(&rpc.InitResponse{
284+
Message: &rpc.InitResponse_Error{
285+
Error: s.Proto(),
286+
},
287+
})
288+
}
289+
290+
if ctagsHasBeenInstalled || serialHasBeenInstalled || mdnsHasBeenInstalled {
280291
// We installed at least one new tool after loading hardware
281292
// so we must reload again otherwise we would never found them.
282293
for _, err := range instance.PackageManager.LoadHardware() {

0 commit comments

Comments
 (0)