Skip to content

Support Chinese URL #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions example/simpleDemo/engineDownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/zip"
"bufio"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -202,6 +203,18 @@ func downloadFile(filepath string, url string) error {
}

func main() {
// Support flag
chinaPtr := flag.Bool("china", false, "Whether or not installation is in China")
flag.Parse()
var targetedDomain = ""

// If flag china is passse, targeted domain is changed (China partially blocking google)
if *chinaPtr {
targetedDomain = "https://storage.flutter-io.cn"
} else {
targetedDomain = "https://storage.googleapis.com"
}

// Execute flutter command to retrieve the version
out, err := exec.Command("flutter", "--version").Output()
if err != nil {
Expand Down Expand Up @@ -260,24 +273,24 @@ func main() {
switch runtime.GOOS {
case "darwin":
platform = "darwin-x64"
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform)
downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform)
endMessage = "export CGO_LDFLAGS=\"-F${PWD} -Wl,-rpath,@executable_path\""

case "linux":
platform = "linux-x64"
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
endMessage = "export CGO_LDFLAGS=\"-L${PWD}\""

case "windows":
platform = "windows-x64"
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder.zip", hashResponse.Items[0].Sha, platform, platform)
downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
endMessage = "set CGO_LDFLAGS=-L%cd%"

default:
log.Fatal("OS not supported")
}

downloadIcudtlURL := fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform)
downloadIcudtlURL := fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform)

err3 := downloadFile(dir+"/.build/temp.zip", downloadShareLibraryURL)
if err3 != nil {
Expand Down