diff --git a/samples/embedder/BUILD.gn b/samples/embedder/BUILD.gn index 0b416107c14..885be5f6ab6 100644 --- a/samples/embedder/BUILD.gn +++ b/samples/embedder/BUILD.gn @@ -70,14 +70,6 @@ _all_configs = [ dart_shared_lib = "../../runtime/engine:dart_engine_aot_shared" dart_static_lib = "../../runtime/engine:dart_engine_aot_static" snapshot_target = "aot_snapshot" - - # AOT snapshots as shared libraries on Windows are not - # supported, and in fact we don't build AOT samples on - # Windows. However, GN evaluation model will still - # evaluate the `aot_snapshot` template on Windows, - # and it will fail the assert if as_shared_library is - # true, and the current platform is Windows. - as_shared_library = !is_win }, ] diff --git a/utils/aot_snapshot.gni b/utils/aot_snapshot.gni index 25e84edfd56..48198a5b529 100644 --- a/utils/aot_snapshot.gni +++ b/utils/aot_snapshot.gni @@ -104,104 +104,39 @@ template("aot_snapshot") { } } - # Whether to build an AOT snapshot, which can be opened by dlopen. - # Ignore this option on Linux, as the default app-aot-elf AOT - # snapshot already can be used with dlopen on Linux. - as_shared_library = defined(invoker.as_shared_library) && - invoker.as_shared_library && !is_linux + # Create a snapshot from kernel built above. + gen_snapshot_action(target_name) { + if (defined(invoker.pool)) { + pool = invoker.pool + } + deps = extra_deps + [ ":${target_name}_dill" ] - assert(!(as_shared_library && is_win), - "AOT Snapshots as shared libraries are not supported on Windows") + inputs = extra_inputs - if (!as_shared_library) { - # Create a snapshot from kernel built above. - gen_snapshot_action(target_name) { - if (defined(invoker.pool)) { - pool = invoker.pool - } - deps = extra_deps + [ ":${target_name}_dill" ] + outputs = [ output ] - inputs = extra_inputs - - outputs = [ output ] - - abs_output = rebase_path(output) + abs_output = rebase_path(output) + # TODO(60813): Generate PE DLL on Windows. + if (is_mac) { + vm_args = [ + "--deterministic", + "--snapshot-kind=app-aot-macho-dylib", + "--macho=$abs_output", + ] + gen_snapshot_args + } else { vm_args = [ "--deterministic", "--snapshot-kind=app-aot-elf", "--elf=$abs_output", ] + gen_snapshot_args - if (defined(invoker.vm_args)) { - vm_args += invoker.vm_args - } - - args = [ rebase_path(dill) ] - - force_product_mode = product_mode } - } else { - assembly = "$target_gen_dir/$name.S" - dill_target_name = ":${target_name}_dill" - - # Create an assembly snapshot from kernel built above. - assembly_target_name = target_name + "_assembly" - gen_snapshot_action(assembly_target_name) { - if (defined(invoker.pool)) { - pool = invoker.pool - } - deps = extra_deps + [ dill_target_name ] - - inputs = extra_inputs - - outputs = [ assembly ] - - abs_output = rebase_path(assembly) - vm_args = [ - "--deterministic", - "--snapshot-kind=app-aot-assembly", - "--assembly=$abs_output", - ] + gen_snapshot_args - - args = [ rebase_path(dill) ] - - force_product_mode = product_mode + if (defined(invoker.vm_args)) { + vm_args += invoker.vm_args } - # build a shared library from assembly. - shared_library_target_name = target_name + "_shared_library" - shared_library(shared_library_target_name) { - sources = [ assembly ] - deps = [ ":${assembly_target_name}" ] - } + args = [ rebase_path(dill) ] - output_prefix = "lib" - output_extension = "" - - if (current_os == "mac" || current_os == "ios" || current_os == "watchos") { - output_extension = "dylib" - } else if (current_os == "win") { - output_extension = "dll" - output_prefix = "" - } else if (current_os == "unknown" && current_cpu == "wasm32") { - output_extension = "wasm" - } else { - output_extension = "so" - } - - shared_library_output_file_name = - "$output_prefix$shared_library_target_name" - if (output_extension != "") { - shared_library_output_file_name += ".$output_extension" - } - - # copy shared library to the same output, as when - # `as_shared_library` is False. - copy(target_name) { - sources = [ "$root_out_dir/$shared_library_output_file_name" ] - outputs = [ output ] - - deps = [ ":${shared_library_target_name}" ] - } + force_product_mode = product_mode } }