dart-sdk/utils/dart2wasm/BUILD.gn
Martin Kustermann 847c35612a [dart2wasm] Make dart compile wasm compiled apps disable dart.library.ffi
This is a follow-up to [0]. That CL changed dart2wasm's modular
transformer to issue an error if `dart:ffi` is imported.

Users of packages that have specialized code for the VM (which supports
FFI) use conditional imports based on `dart.library.ffi`. We don't want
the VM-specific code to be used for web in dart2wasm (as dart2wasm
doesn't support the entirety of `dart:ffi`).

As a result we're going to make `dart.library.ffi` be false in
coditional imports (as well as in
`const bool.fromEnvironment('dart.library.ffi')`).

[0] https://dart-review.googlesource.com/c/sdk/+/368568

Issue https://github.com/dart-lang/sdk/issues/55948
Issue https://github.com/flutter/flutter/issues/149984

Change-Id: I70a775278ab701d1fd2596521e378cb6364edac2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370580
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-06-11 09:28:40 +00:00

86 lines
2.3 KiB
Plaintext

# Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import("../aot_snapshot.gni")
import("../compile_platform.gni")
sdk_root = "../../sdk"
template("wasm_module") {
action(target_name) {
script = rebase_path("//build/gn_run_binary.py")
args = [
"compiled_action",
rebase_path("//third_party/emsdk/upstream/emscripten/emcc"),
"--no-entry",
rebase_path("//tests/web/wasm/ffi/${invoker.module_name}.c"),
"-o",
rebase_path("$root_out_dir/wasm/${invoker.module_name}.wasm"),
"-O",
]
outputs = [ "$root_out_dir/wasm/${invoker.module_name}.wasm" ]
}
}
aot_snapshot("dart2wasm_snapshot") {
main_dart = "../../pkg/dart2wasm/bin/dart2wasm.dart"
name = "dart2wasm"
}
aot_snapshot("dart2wasm_asserts_snapshot") {
main_dart = "../../pkg/dart2wasm/bin/dart2wasm.dart"
name = "dart2wasm_asserts"
gen_kernel_args = [ "--enable-asserts" ]
gen_snapshot_args = [ "--enable-asserts" ]
}
aot_snapshot("dart2wasm_product_snapshot") {
main_dart = "../../pkg/dart2wasm/bin/dart2wasm.dart"
name = "dart2wasm_product"
force_product_mode = true
}
compile_platform("compile_dart2wasm_platform") {
single_root_scheme = "org-dartlang-sdk"
single_root_base = rebase_path("$sdk_root/")
libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json"
outputs = [
"$root_out_dir/dart2wasm_platform.dill",
"$root_out_dir/dart2wasm_outline.dill",
]
args = [
"--target=dart2wasm",
"dart:core",
"--nnbd-strong",
]
}
compile_platform("compile_dart2wasm_js_compatibility_platform") {
single_root_scheme = "org-dartlang-sdk"
single_root_base = rebase_path("$sdk_root/")
libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json"
outputs = [
"$root_out_dir/dart2wasm_js_compatibility_platform.dill",
"$root_out_dir/dart2wasm_js_compatibility_outline.dill",
]
args = [
"--target=dart2wasm_js_compatibility",
"-Ddart.wasm.js_compatibility=true",
"dart:core",
"--nnbd-strong",
]
}
wasm_module("ffi_native_test_wasm_module") {
module_name = "ffi_native_test_module"
}
group("test_wasm_modules") {
deps = [ ":ffi_native_test_wasm_module" ]
}