Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

build: make rclone build with wasm

Nick Craig-Wood3a14b1d5a980
diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index cb54f94fd..96a20fde1 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -1,6 +1,6 @@
// Package azureblob provides an interface to the Microsoft Azure blob object storage system
-// +build !plan9,!solaris,go1.13
+// +build !plan9,!solaris,!js,go1.13
package azureblob
diff --git a/backend/azureblob/azureblob_internal_test.go b/backend/azureblob/azureblob_internal_test.go
index 954c08fe8..59bec6841 100644
--- a/backend/azureblob/azureblob_internal_test.go
+++ b/backend/azureblob/azureblob_internal_test.go
@@ -1,4 +1,4 @@
-// +build !plan9,!solaris,go1.13
+// +build !plan9,!solaris,!js,go1.13
package azureblob
diff --git a/backend/azureblob/azureblob_test.go b/backend/azureblob/azureblob_test.go
index b05020ab8..22496e817 100644
--- a/backend/azureblob/azureblob_test.go
+++ b/backend/azureblob/azureblob_test.go
@@ -1,6 +1,6 @@
// Test AzureBlob filesystem interface
-// +build !plan9,!solaris,go1.13
+// +build !plan9,!solaris,!js,go1.13
package azureblob
diff --git a/backend/azureblob/azureblob_unsupported.go b/backend/azureblob/azureblob_unsupported.go
index 9b246edf2..63671fddf 100644
--- a/backend/azureblob/azureblob_unsupported.go
+++ b/backend/azureblob/azureblob_unsupported.go
@@ -1,6 +1,6 @@
// Build for azureblob for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// +build plan9 solaris !go1.13
+// +build plan9 solaris js !go1.13
package azureblob
diff --git a/backend/cache/cache.go b/backend/cache/cache.go
index 01140c358..08fd83034 100644
--- a/backend/cache/cache.go
+++ b/backend/cache/cache.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/cache/cache_internal_test.go b/backend/cache/cache_internal_test.go
index becbfd92b..515849a26 100644
--- a/backend/cache/cache_internal_test.go
+++ b/backend/cache/cache_internal_test.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
// +build !race
package cache_test
diff --git a/backend/cache/cache_test.go b/backend/cache/cache_test.go
index 56a9ba918..009cd347e 100644
--- a/backend/cache/cache_test.go
+++ b/backend/cache/cache_test.go
@@ -1,6 +1,6 @@
// Test Cache filesystem interface
-// +build !plan9
+// +build !plan9,!js
// +build !race
package cache_test
diff --git a/backend/cache/cache_unsupported.go b/backend/cache/cache_unsupported.go
index 05a39fa8b..7a242035d 100644
--- a/backend/cache/cache_unsupported.go
+++ b/backend/cache/cache_unsupported.go
@@ -1,6 +1,6 @@
// Build for cache for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// +build plan9
+// +build plan9 js
package cache
diff --git a/backend/cache/cache_upload_test.go b/backend/cache/cache_upload_test.go
index f1e3252c3..7e66c0a44 100644
--- a/backend/cache/cache_upload_test.go
+++ b/backend/cache/cache_upload_test.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
// +build !race
package cache_test
diff --git a/backend/cache/directory.go b/backend/cache/directory.go
index 2f03eb938..ab009738d 100644
--- a/backend/cache/directory.go
+++ b/backend/cache/directory.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/cache/handle.go b/backend/cache/handle.go
index 96e8fd89d..efab3ee49 100644
--- a/backend/cache/handle.go
+++ b/backend/cache/handle.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/cache/object.go b/backend/cache/object.go
index 6db9fcde9..f0b148ff1 100644
--- a/backend/cache/object.go
+++ b/backend/cache/object.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/cache/plex.go b/backend/cache/plex.go
index 8b8a2c0b6..0ce76b724 100644
--- a/backend/cache/plex.go
+++ b/backend/cache/plex.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/cache/storage_memory.go b/backend/cache/storage_memory.go
index fb0d9dba7..6faf0472a 100644
--- a/backend/cache/storage_memory.go
+++ b/backend/cache/storage_memory.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/cache/storage_persistent.go b/backend/cache/storage_persistent.go
index 054857c24..6f5d2b4f6 100644
--- a/backend/cache/storage_persistent.go
+++ b/backend/cache/storage_persistent.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cache
diff --git a/backend/local/lchtimes.go b/backend/local/lchtimes.go
index 2684beee5..a845e3a40 100644
--- a/backend/local/lchtimes.go
+++ b/backend/local/lchtimes.go
@@ -1,4 +1,4 @@
-// +build windows plan9
+// +build windows plan9 js
package local
diff --git a/backend/local/lchtimes_unix.go b/backend/local/lchtimes_unix.go
index c7f570eac..9aec5c431 100644
--- a/backend/local/lchtimes_unix.go
+++ b/backend/local/lchtimes_unix.go
@@ -1,4 +1,4 @@
-// +build !windows,!plan9
+// +build !windows,!plan9,!js
package local
diff --git a/backend/qingstor/qingstor.go b/backend/qingstor/qingstor.go
index 34fa276ed..20de9ae6e 100644
--- a/backend/qingstor/qingstor.go
+++ b/backend/qingstor/qingstor.go
@@ -1,7 +1,7 @@
// Package qingstor provides an interface to QingStor object storage
// Home: https://www.qingcloud.com/
-// +build !plan9
+// +build !plan9,!js
package qingstor
diff --git a/backend/qingstor/qingstor_test.go b/backend/qingstor/qingstor_test.go
index cd84ab35d..8910744b6 100644
--- a/backend/qingstor/qingstor_test.go
+++ b/backend/qingstor/qingstor_test.go
@@ -1,6 +1,6 @@
// Test QingStor filesystem interface
-// +build !plan9
+// +build !plan9,!js
package qingstor
diff --git a/backend/qingstor/qingstor_unsupported.go b/backend/qingstor/qingstor_unsupported.go
index a2980237a..8406b8346 100644
--- a/backend/qingstor/qingstor_unsupported.go
+++ b/backend/qingstor/qingstor_unsupported.go
@@ -1,6 +1,6 @@
// Build for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// +build plan9
+// +build plan9 js
package qingstor
diff --git a/backend/qingstor/upload.go b/backend/qingstor/upload.go
index 642a47c84..7fa0e3321 100644
--- a/backend/qingstor/upload.go
+++ b/backend/qingstor/upload.go
@@ -1,6 +1,6 @@
// Upload object to QingStor
-// +build !plan9
+// +build !plan9,!js
package qingstor
diff --git a/bin/cross-compile.go b/bin/cross-compile.go
index be83be6bb..bb0faea37 100644
--- a/bin/cross-compile.go
+++ b/bin/cross-compile.go
@@ -66,6 +66,7 @@ var osarches = []string{
"plan9/386",
"plan9/amd64",
"solaris/amd64",
+ "js/wasm",
}
// Special environment flags for a given arch
@@ -320,14 +321,16 @@ func compileArch(version, goos, goarch, dir string) bool {
return false
}
if !*compileOnly {
- artifacts := []string{buildZip(dir)}
- // build a .deb and .rpm if appropriate
- if goos == "linux" {
- artifacts = append(artifacts, buildDebAndRpm(dir, version, goarch)...)
- }
- if *copyAs != "" {
- for _, artifact := range artifacts {
- run("ln", artifact, strings.Replace(artifact, "-"+version, "-"+*copyAs, 1))
+ if goos != "js" {
+ artifacts := []string{buildZip(dir)}
+ // build a .deb and .rpm if appropriate
+ if goos == "linux" {
+ artifacts = append(artifacts, buildDebAndRpm(dir, version, goarch)...)
+ }
+ if *copyAs != "" {
+ for _, artifact := range artifacts {
+ run("ln", artifact, strings.Replace(artifact, "-"+version, "-"+*copyAs, 1))
+ }
}
}
// tidy up
diff --git a/cmd/cachestats/cachestats.go b/cmd/cachestats/cachestats.go
index d1be2dc27..0e7ea6119 100644
--- a/cmd/cachestats/cachestats.go
+++ b/cmd/cachestats/cachestats.go
@@ -1,4 +1,4 @@
-// +build !plan9
+// +build !plan9,!js
package cachestats
diff --git a/cmd/cachestats/cachestats_unsupported.go b/cmd/cachestats/cachestats_unsupported.go
index aded32895..9a53d1a9e 100644
--- a/cmd/cachestats/cachestats_unsupported.go
+++ b/cmd/cachestats/cachestats_unsupported.go
@@ -1,6 +1,6 @@
// Build for cache for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// +build plan9
+// +build plan9 js
package cachestats
diff --git a/cmd/ncdu/ncdu.go b/cmd/ncdu/ncdu.go
index 1e62cd86f..007c46ceb 100644
--- a/cmd/ncdu/ncdu.go
+++ b/cmd/ncdu/ncdu.go
@@ -1,6 +1,6 @@
// Package ncdu implements a text based user interface for exploring a remote
-//+build !plan9,!solaris
+//+build !plan9,!solaris,!js
package ncdu
diff --git a/cmd/ncdu/ncdu_unsupported.go b/cmd/ncdu/ncdu_unsupported.go
index b5248e791..fac52d63f 100644
--- a/cmd/ncdu/ncdu_unsupported.go
+++ b/cmd/ncdu/ncdu_unsupported.go
@@ -1,6 +1,6 @@
// Build for ncdu for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// +build plan9 solaris
+// +build plan9 solaris js
package ncdu
diff --git a/cmd/serve/restic/restic.go b/cmd/serve/restic/restic.go
index 1d74ef1d0..c490f5e54 100644
--- a/cmd/serve/restic/restic.go
+++ b/cmd/serve/restic/restic.go
@@ -21,8 +21,8 @@ import (
"github.com/rclone/rclone/fs/fserrors"
"github.com/rclone/rclone/fs/operations"
"github.com/rclone/rclone/fs/walk"
+ "github.com/rclone/rclone/lib/terminal"
"github.com/spf13/cobra"
- "golang.org/x/crypto/ssh/terminal"
"golang.org/x/net/http2"
)
diff --git a/fs/config/config_read_password.go b/fs/config/config_read_password.go
index 9baf3793a..023053c7e 100644
--- a/fs/config/config_read_password.go
+++ b/fs/config/config_read_password.go
@@ -11,7 +11,7 @@ import (
"log"
"os"
- "golang.org/x/crypto/ssh/terminal"
+ "github.com/rclone/rclone/lib/terminal"
)
// ReadPassword reads a password without echoing it to the terminal.
diff --git a/fs/log/redirect_stderr_unix.go b/fs/log/redirect_stderr_unix.go
index fca8e982f..8ca90f6ad 100644
--- a/fs/log/redirect_stderr_unix.go
+++ b/fs/log/redirect_stderr_unix.go
@@ -1,6 +1,6 @@
// Log the panic under unix to the log file
-// +build !windows,!solaris,!plan9
+// +build !windows,!solaris,!plan9,!js
package log
diff --git a/lib/mmap/mmap_unix.go b/lib/mmap/mmap_unix.go
index 5a2cb9f80..a5129261f 100644
--- a/lib/mmap/mmap_unix.go
+++ b/lib/mmap/mmap_unix.go
@@ -1,7 +1,7 @@
// Package mmap implements a large block memory allocator using
// anonymous memory maps.
-// +build !plan9,!windows
+// +build !plan9,!windows,!js
package mmap
diff --git a/lib/mmap/mmap_unsupported.go b/lib/mmap/mmap_unsupported.go
index 937d40536..7f956c7b8 100644
--- a/lib/mmap/mmap_unsupported.go
+++ b/lib/mmap/mmap_unsupported.go
@@ -1,6 +1,6 @@
// Fallback Alloc and Free for unsupported OSes
-// +build plan9
+// +build plan9 js
package mmap
diff --git a/lib/terminal/terminal.go b/lib/terminal/terminal.go
index 9a7c1ab7b..d29931380 100644
--- a/lib/terminal/terminal.go
+++ b/lib/terminal/terminal.go
@@ -9,7 +9,6 @@ import (
"sync"
colorable "github.com/mattn/go-colorable"
- "golang.org/x/crypto/ssh/terminal"
)
// VT100 codes
@@ -72,7 +71,7 @@ var (
func Start() {
once.Do(func() {
f := os.Stdout
- if !terminal.IsTerminal(int(f.Fd())) {
+ if !IsTerminal(int(f.Fd())) {
// If stdout not a tty then remove escape codes
Out = colorable.NewNonColorable(f)
} else if runtime.GOOS == "windows" && os.Getenv("TERM") != "" {
@@ -89,16 +88,6 @@ func WriteString(s string) {
Write([]byte(s))
}
-// GetSize reads the dimensions of the current terminal or returns a
-// sensible default
-func GetSize() (w, h int) {
- w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
- if err != nil {
- w, h = 80, 25
- }
- return w, h
-}
-
// Out is an io.Writer which can be used to write to the terminal
// eg for use with fmt.Fprintf(terminal.Out, "terminal fun: %d\n", n)
var Out io.Writer
diff --git a/lib/terminal/terminal_normal.go b/lib/terminal/terminal_normal.go
new file mode 100644
index 000000000..787054eed
--- /dev/null
+++ b/lib/terminal/terminal_normal.go
@@ -0,0 +1,31 @@
+//+build !js
+
+package terminal
+
+import (
+ "os"
+
+ "golang.org/x/crypto/ssh/terminal"
+)
+
+// GetSize reads the dimensions of the current terminal or returns a
+// sensible default
+func GetSize() (w, h int) {
+ w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
+ if err != nil {
+ w, h = 80, 25
+ }
+ return w, h
+}
+
+// IsTerminal returns whether the fd passed in is a terminal or not
+func IsTerminal(fd int) bool {
+ return terminal.IsTerminal(fd)
+}
+
+// ReadPassword reads a line of input from a terminal without local echo. This
+// is commonly used for inputting passwords and other sensitive data. The slice
+// returned does not include the \n.
+func ReadPassword(fd int) ([]byte, error) {
+ return terminal.ReadPassword(fd)
+}
diff --git a/lib/terminal/terminal_unsupported.go b/lib/terminal/terminal_unsupported.go
new file mode 100644
index 000000000..bd70d3409
--- /dev/null
+++ b/lib/terminal/terminal_unsupported.go
@@ -0,0 +1,23 @@
+//+build js
+
+package terminal
+
+import "errors"
+
+// GetSize reads the dimensions of the current terminal or returns a
+// sensible default
+func GetSize() (w, h int) {
+ return 80, 25
+}
+
+// IsTerminal returns whether the fd passed in is a terminal or not
+func IsTerminal(fd int) bool {
+ return false
+}
+
+// ReadPassword reads a line of input from a terminal without local echo. This
+// is commonly used for inputting passwords and other sensitive data. The slice
+// returned does not include the \n.
+func ReadPassword(fd int) ([]byte, error) {
+ return nil, errors.New("can't read password")
+}