From 209742e19eb48d4e514b0094d64132d6d0f38a09 Mon Sep 17 00:00:00 2001 From: Godofredo Contreras Date: Wed, 7 Sep 2022 21:26:47 -0700 Subject: [PATCH 1/4] Gn target to generate gen_snapshot for windows. Adds a new target to archive gen_snapshot for windows platforms. A new target is required because the naming convention is completely different from the one used for linux or mac. Bug: https://github.com/flutter/flutter/issues/81855 --- build/archives/BUILD.gn | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build/archives/BUILD.gn b/build/archives/BUILD.gn index 81f2e537ea268..d2f055e9da052 100644 --- a/build/archives/BUILD.gn +++ b/build/archives/BUILD.gn @@ -274,3 +274,16 @@ if (is_mac) { ] } } + +if (is_win) { + zip_bundle("archive_win_gen_snapshot") { + deps = [ "//third_party/dart/runtime/bin:gen_snapshot" ] + output = "$target_platform_name-$android_cpu-$flutter_runtime_mode/windows-x64.zip" + files = [ + { + source = "$root_out_dir/gen_snapshot.exe" + destination = "gen_snapshot.exe" + }, + ] + } +} From 3081fb3cb1d1041f21ef22309cc6975b7deec699 Mon Sep 17 00:00:00 2001 From: Godofredo Contreras Date: Wed, 7 Sep 2022 21:40:23 -0700 Subject: [PATCH 2/4] Use target cpu. --- build/archives/BUILD.gn | 2 +- tools/gn | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/build/archives/BUILD.gn b/build/archives/BUILD.gn index d2f055e9da052..4395228240961 100644 --- a/build/archives/BUILD.gn +++ b/build/archives/BUILD.gn @@ -278,7 +278,7 @@ if (is_mac) { if (is_win) { zip_bundle("archive_win_gen_snapshot") { deps = [ "//third_party/dart/runtime/bin:gen_snapshot" ] - output = "$target_platform_name-$android_cpu-$flutter_runtime_mode/windows-x64.zip" + output = "$target_platform_name-$target_cpu-$flutter_runtime_mode/windows-x64.zip" files = [ { source = "$root_out_dir/gen_snapshot.exe" diff --git a/tools/gn b/tools/gn index 7b218ff116802..2a5ae5766cadb 100755 --- a/tools/gn +++ b/tools/gn @@ -288,12 +288,6 @@ def to_gn_args(args): gn_args['target_cpu'] = get_target_cpu(args) gn_args['dart_target_arch'] = gn_args['target_cpu'] - # No cross-compilation on Windows (for now). Use host toolchain that - # matches the bit-width of the target architecture. - if sys.platform.startswith(('cygwin', 'win')) and args.target_os != 'win': - gn_args['host_cpu'] = cpu_for_target_arch(gn_args['target_cpu']) - gn_args['target_cpu'] = cpu_for_target_arch(gn_args['target_cpu']) - # macOS host builds (whether x64 or arm64) must currently be built under # Rosetta on Apple Silicon Macs. # TODO(cbracken): https://github.com/flutter/flutter/issues/103386 From d604d34bf314f5d2bd5f8e8c6c0638e6ca5259ee Mon Sep 17 00:00:00 2001 From: Godofredo Contreras Date: Thu, 8 Sep 2022 12:35:38 -0700 Subject: [PATCH 3/4] Move to flutter/lib/snapshot file. --- build/archives/BUILD.gn | 13 ------------- lib/snapshot/BUILD.gn | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/archives/BUILD.gn b/build/archives/BUILD.gn index 4395228240961..81f2e537ea268 100644 --- a/build/archives/BUILD.gn +++ b/build/archives/BUILD.gn @@ -274,16 +274,3 @@ if (is_mac) { ] } } - -if (is_win) { - zip_bundle("archive_win_gen_snapshot") { - deps = [ "//third_party/dart/runtime/bin:gen_snapshot" ] - output = "$target_platform_name-$target_cpu-$flutter_runtime_mode/windows-x64.zip" - files = [ - { - source = "$root_out_dir/gen_snapshot.exe" - destination = "gen_snapshot.exe" - }, - ] - } -} diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index 618640efe53be..e29a1299a3f81 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -290,3 +290,16 @@ compile_platform("strong_platform") { group("kernel_platform_files") { public_deps = [ ":strong_platform" ] } + +if (is_win) { + zip_bundle("archive_win_gen_snapshot") { + deps = [ "//third_party/dart/runtime/bin:gen_snapshot" ] + output = "$target_platform_name-$target_cpu-$flutter_runtime_mode/windows-x64.zip" + files = [ + { + source = "$root_out_dir/gen_snapshot.exe" + destination = "gen_snapshot.exe" + }, + ] + } +} From 4a50c14ea2434de3c82a8b5e72b5dd7ed5380565 Mon Sep 17 00:00:00 2001 From: Godofredo Contreras Date: Thu, 8 Sep 2022 13:01:59 -0700 Subject: [PATCH 4/4] Add zip gni dep. --- lib/snapshot/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index e29a1299a3f81..ee98f51d68708 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -4,6 +4,7 @@ import("//build/compiled_action.gni") import("//build/fuchsia/sdk.gni") +import("//flutter/build/zip_bundle.gni") import("//flutter/common/config.gni") import("//flutter/lib/ui/dart_ui.gni") import("//flutter/sky/tools/macos_snapshots.gni")