|
4 | 4 | "archive/zip"
|
5 | 5 | "bufio"
|
6 | 6 | "encoding/json"
|
| 7 | + "flag" |
7 | 8 | "fmt"
|
8 | 9 | "io"
|
9 | 10 | "io/ioutil"
|
@@ -202,6 +203,18 @@ func downloadFile(filepath string, url string) error {
|
202 | 203 | }
|
203 | 204 |
|
204 | 205 | func main() {
|
| 206 | + // Support flag |
| 207 | + chinaPtr := flag.Bool("china", false, "Whether or not installation is in China") |
| 208 | + flag.Parse() |
| 209 | + var targetedDomain = "" |
| 210 | + |
| 211 | + // If flag china is passse, targeted domain is changed (China partially blocking google) |
| 212 | + if *chinaPtr { |
| 213 | + targetedDomain = "https://storage.flutter-io.cn" |
| 214 | + } else { |
| 215 | + targetedDomain = "https://storage.googleapis.com" |
| 216 | + } |
| 217 | + |
205 | 218 | // Execute flutter command to retrieve the version
|
206 | 219 | out, err := exec.Command("flutter", "--version").Output()
|
207 | 220 | if err != nil {
|
@@ -260,24 +273,24 @@ func main() {
|
260 | 273 | switch runtime.GOOS {
|
261 | 274 | case "darwin":
|
262 | 275 | platform = "darwin-x64"
|
263 |
| - downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform) |
| 276 | + downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform) |
264 | 277 | endMessage = "export CGO_LDFLAGS=\"-F${PWD} -Wl,-rpath,@executable_path\""
|
265 | 278 |
|
266 | 279 | case "linux":
|
267 | 280 | platform = "linux-x64"
|
268 |
| - downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform) |
| 281 | + downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform) |
269 | 282 | endMessage = "export CGO_LDFLAGS=\"-L${PWD}\""
|
270 | 283 |
|
271 | 284 | case "windows":
|
272 | 285 | platform = "windows-x64"
|
273 |
| - downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder.zip", hashResponse.Items[0].Sha, platform, platform) |
| 286 | + downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform) |
274 | 287 | endMessage = "set CGO_LDFLAGS=-L%cd%"
|
275 | 288 |
|
276 | 289 | default:
|
277 | 290 | log.Fatal("OS not supported")
|
278 | 291 | }
|
279 | 292 |
|
280 |
| - downloadIcudtlURL := fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform) |
| 293 | + downloadIcudtlURL := fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform) |
281 | 294 |
|
282 | 295 | err3 := downloadFile(dir+"/.build/temp.zip", downloadShareLibraryURL)
|
283 | 296 | if err3 != nil {
|
|
0 commit comments