build: make rclone build with wasm

Needed to drop
- azureblob backend
- cache backend
- qingstor backend
- cachestats command
- ncdu command
This commit is contained in:
Nick Craig-Wood 2020-07-31 19:57:48 +01:00
parent ac044b1c54
commit 3a14b1d5a9
34 changed files with 96 additions and 50 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
// +build !plan9,!solaris,go1.13
// +build !plan9,!solaris,!js,go1.13
package azureblob

View File

@ -1,6 +1,6 @@
// Test AzureBlob filesystem interface
// +build !plan9,!solaris,go1.13
// +build !plan9,!solaris,!js,go1.13
package azureblob

View File

@ -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

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
// +build !race
package cache_test

View File

@ -1,6 +1,6 @@
// Test Cache filesystem interface
// +build !plan9
// +build !plan9,!js
// +build !race
package cache_test

View File

@ -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

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
// +build !race
package cache_test

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cache

View File

@ -1,4 +1,4 @@
// +build windows plan9
// +build windows plan9 js
package local

View File

@ -1,4 +1,4 @@
// +build !windows,!plan9
// +build !windows,!plan9,!js
package local

View File

@ -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

View File

@ -1,6 +1,6 @@
// Test QingStor filesystem interface
// +build !plan9
// +build !plan9,!js
package qingstor

View File

@ -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

View File

@ -1,6 +1,6 @@
// Upload object to QingStor
// +build !plan9
// +build !plan9,!js
package qingstor

View File

@ -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

View File

@ -1,4 +1,4 @@
// +build !plan9
// +build !plan9,!js
package cachestats

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"
)

View File

@ -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.

View File

@ -1,6 +1,6 @@
// Log the panic under unix to the log file
// +build !windows,!solaris,!plan9
// +build !windows,!solaris,!plan9,!js
package log

View File

@ -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

View File

@ -1,6 +1,6 @@
// Fallback Alloc and Free for unsupported OSes
// +build plan9
// +build plan9 js
package mmap

View File

@ -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

View File

@ -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)
}

View File

@ -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")
}