Skip to content

Commit 0e21b72

Browse files
committed
switch net via build tags
Signed-off-by: leongross <[email protected]>
1 parent 5f78ec4 commit 0e21b72

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@
3535
[submodule "lib/wasi-cli"]
3636
path = lib/wasi-cli
3737
url = https://github.com/WebAssembly/wasi-cli
38+
[submodule "src/net"]
39+
path = src/net
40+
url = https://github.com/tinygo-org/net

loader/goroot.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,16 @@ func linuxNetworking(buildTags []string) bool {
236236
return false
237237
}
238238

239-
// The boolean indicates whether to merge the subdirs. True means merge, false
240-
// means use the TinyGo version.
239+
// The boolean indicates whether to merge the subdirs.
240+
//
241+
// True: Merge the golang and tinygo source directories.
242+
// False: Uses the TinyGo version exclusively.
241243
func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
242244
paths := map[string]bool{
243-
"": true,
245+
"": true, // root
244246
"crypto/": true,
245247
"crypto/rand/": false,
246-
"crypto/tls/": false,
248+
"crypto/tls/": false, // necessary for embedded tls
247249
"device/": false,
248250
"examples/": false,
249251
"internal/": true,
@@ -256,7 +258,7 @@ func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
256258
"internal/task/": false,
257259
"internal/wasi/": false,
258260
"machine/": false,
259-
"net/": true, // this is important if the GOOS is not linux
261+
"net/": true, // this is important if the GOOS != linux
260262
"net/http/": false,
261263
"os/": true,
262264
"reflect/": false,
@@ -276,15 +278,12 @@ func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
276278
paths["syscall/"] = true // include syscall/js
277279
}
278280

281+
// To make sure the correct version of the net package is used, it is advised
282+
// to clean the go cache before building
279283
if linuxNetworking(buildTags) {
280284
for _, v := range []string{"crypto/tls/", "net/http/", "net/"} {
281285
delete(paths, v) // remove entries so go stdlib is used
282286
}
283-
284-
// ensure that the goroot path does not contain the the tinygo net package
285-
// path
286-
} else {
287-
// if the GOOS!=linux several tls files have to be for tls
288287
}
289288

290289
return paths

0 commit comments

Comments
 (0)