Skip to content

Commit

Permalink
switch net via build tags
Browse files Browse the repository at this point in the history
Signed-off-by: leongross <leon.gross@9elements.com>
  • Loading branch information
leongross committed Oct 4, 2024
1 parent 5f78ec4 commit 0e21b72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
[submodule "lib/wasi-cli"]
path = lib/wasi-cli
url = https://github.com/WebAssembly/wasi-cli
[submodule "src/net"]
path = src/net
url = https://github.com/tinygo-org/net
19 changes: 9 additions & 10 deletions loader/goroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,16 @@ func linuxNetworking(buildTags []string) bool {
return false
}

// The boolean indicates whether to merge the subdirs. True means merge, false
// means use the TinyGo version.
// The boolean indicates whether to merge the subdirs.
//
// True: Merge the golang and tinygo source directories.
// False: Uses the TinyGo version exclusively.
func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
paths := map[string]bool{
"": true,
"": true, // root
"crypto/": true,
"crypto/rand/": false,
"crypto/tls/": false,
"crypto/tls/": false, // necessary for embedded tls
"device/": false,
"examples/": false,
"internal/": true,
Expand All @@ -256,7 +258,7 @@ func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
"internal/task/": false,
"internal/wasi/": false,
"machine/": false,
"net/": true, // this is important if the GOOS is not linux
"net/": true, // this is important if the GOOS != linux
"net/http/": false,
"os/": true,
"reflect/": false,
Expand All @@ -276,15 +278,12 @@ func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
paths["syscall/"] = true // include syscall/js
}

// To make sure the correct version of the net package is used, it is advised
// to clean the go cache before building
if linuxNetworking(buildTags) {
for _, v := range []string{"crypto/tls/", "net/http/", "net/"} {
delete(paths, v) // remove entries so go stdlib is used
}

// ensure that the goroot path does not contain the the tinygo net package
// path
} else {
// if the GOOS!=linux several tls files have to be for tls
}

return paths
Expand Down

0 comments on commit 0e21b72

Please sign in to comment.