@@ -241,29 +241,87 @@ func ValidateOrUpdateEngine(targetOS, cachePath, requiredEngineVersion string, m
241241
242242 log .Printf ("Downloading engine for platform %s at version %s..." , EngineConfig (targetOS , mode ), requiredEngineVersion )
243243
244- file := ""
245- switch targetOS {
246- case "linux" :
247- file += "linux"
248- case "darwin" :
249- file += "macosx"
250- case "windows" :
251- file += "windows"
252- }
253- file += fmt .Sprintf ("_x64-host_%s.zip" , mode .Name )
254- engineDownloadURL := fmt .Sprintf ("https://github.com/flutter-rs/engine-builds/releases/download/f-%s/%s" , requiredEngineVersion , file )
244+ if mode == build .DebugMode {
245+ targetedDomain := "https://storage.googleapis.com"
246+ envURLFlutter := os .Getenv ("FLUTTER_STORAGE_BASE_URL" )
247+ if envURLFlutter != "" {
248+ targetedDomain = envURLFlutter
249+ }
250+ var engineDownloadURL = fmt .Sprintf (targetedDomain + "/flutter_infra/flutter/%s/%s-x64/" , requiredEngineVersion , targetOS )
251+ switch targetOS {
252+ case "darwin" :
253+ engineDownloadURL += "FlutterEmbedder.framework.zip"
254+ case "linux" :
255+ engineDownloadURL += targetOS + "-x64-embedder"
256+ case "windows" :
257+ engineDownloadURL += targetOS + "-x64-embedder.zip"
258+ default :
259+ log .Errorf ("Cannot run on %s, download engine not implemented." , targetOS )
260+ os .Exit (1 )
261+ }
262+
263+ artifactsZipPath := filepath .Join (dir , "artifacts.zip" )
264+ artifactsDownloadURL := fmt .Sprintf (targetedDomain + "/flutter_infra/flutter/%s/%s-x64/artifacts.zip" , requiredEngineVersion , targetOS )
265+
266+ err = downloadFile (engineZipPath , engineDownloadURL )
267+ if err != nil {
268+ log .Errorf ("Failed to download engine: %v" , err )
269+ os .Exit (1 )
270+ }
271+ _ , err = unzip (engineZipPath , engineExtractPath )
272+ if err != nil {
273+ log .Warnf ("%v" , err )
274+ }
275+
276+ err = downloadFile (artifactsZipPath , artifactsDownloadURL )
277+ if err != nil {
278+ log .Errorf ("Failed to download artifacts: %v" , err )
279+ os .Exit (1 )
280+ }
281+ _ , err = unzip (artifactsZipPath , engineExtractPath )
282+ if err != nil {
283+ log .Warnf ("%v" , err )
284+ }
285+ if targetOS == "darwin" {
286+ frameworkZipPath := filepath .Join (engineExtractPath , "FlutterEmbedder.framework.zip" )
287+ frameworkDestPath := filepath .Join (engineExtractPath , "FlutterEmbedder.framework" )
288+ _ , err = unzip (frameworkZipPath , frameworkDestPath )
289+ if err != nil {
290+ log .Errorf ("Failed to unzip engine framework: %v" , err )
291+ os .Exit (1 )
292+ }
293+ createSymLink ("A" , frameworkDestPath + "/Versions/Current" )
294+ createSymLink ("Versions/Current/FlutterEmbedder" , frameworkDestPath + "/FlutterEmbedder" )
295+ createSymLink ("Versions/Current/Headers" , frameworkDestPath + "/Headers" )
296+ createSymLink ("Versions/Current/Modules" , frameworkDestPath + "/Modules" )
297+ createSymLink ("Versions/Current/Resources" , frameworkDestPath + "/Resources" )
298+ }
299+ } else {
300+ file := ""
301+ switch targetOS {
302+ case "linux" :
303+ file += "linux"
304+ case "darwin" :
305+ file += "macosx"
306+ case "windows" :
307+ file += "windows"
308+ }
309+ file += fmt .Sprintf ("_x64-host_%s.zip" , mode .Name )
310+ engineDownloadURL := fmt .Sprintf ("https://github.com/flutter-rs/engine-builds/releases/download/f-%s/%s" , requiredEngineVersion , file )
311+
312+ err = downloadFile (engineZipPath , engineDownloadURL )
313+ if err != nil {
314+ log .Errorf ("Failed to download engine: %v" , err )
315+ log .Errorf ("Engine builds are a bit delayed after they are published in flutter." )
316+ log .Errorf ("You can either try again later or switch the flutter channel to beta, because these engines are more likely to be already built." )
317+ log .Errorf ("To dig into the already built engines look at https://github.com/flutter-rs/engine-builds/releases and https://github.com/flutter-rs/engine-builds/actions" )
318+ os .Exit (1 )
319+ }
320+ _ , err = unzip (engineZipPath , engineExtractPath )
321+ if err != nil {
322+ log .Warnf ("%v" , err )
323+ }
255324
256- err = downloadFile (engineZipPath , engineDownloadURL )
257- if err != nil {
258- log .Errorf ("Failed to download engine: %v" , err )
259- log .Errorf ("Engine builds are a bit delayed after they are published in flutter." )
260- log .Errorf ("You can either try again later or switch the flutter channel to beta, because these engines are more likely to be already built." )
261- log .Errorf ("To dig into the already built engines look at https://github.com/flutter-rs/engine-builds/releases and https://github.com/flutter-rs/engine-builds/actions" )
262- os .Exit (1 )
263- }
264- _ , err = unzip (engineZipPath , engineExtractPath )
265- if err != nil {
266- log .Warnf ("%v" , err )
267325 }
268326
269327 for _ , engineFile := range build .EngineFiles (targetOS , mode ) {
@@ -288,11 +346,16 @@ func ValidateOrUpdateEngine(targetOS, cachePath, requiredEngineVersion string, m
288346 }
289347
290348 files := []string {
291- "dart" + build .ExecutableExtension (targetOS ),
292- "gen_snapshot" + build .ExecutableExtension (targetOS ),
293349 "icudtl.dat" ,
294- "gen" ,
295- "flutter_patched_sdk" ,
350+ }
351+ if mode != build .DebugMode {
352+ files = append (
353+ files ,
354+ "dart" + build .ExecutableExtension (targetOS ),
355+ "gen_snapshot" + build .ExecutableExtension (targetOS ),
356+ "gen" ,
357+ "flutter_patched_sdk" ,
358+ )
296359 }
297360 for _ , file := range files {
298361 err = copy .Copy (
0 commit comments