| # 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("../../sdk_args.gni") |
| |
| config("binaryen_flags") { |
| cflags = [] |
| if (is_clang || !is_win) { |
| # Clang or GCC |
| cflags += [ |
| "-Wno-deprecated-declarations", |
| "-Wno-unused-but-set-parameter", |
| "-Wno-unused-function", |
| "-Wno-unused-variable", |
| "-Wno-pessimizing-move", |
| "-Wno-sign-compare", |
| "-Wno-range-loop-construct", |
| ] |
| |
| if (is_clang) { |
| # Clang |
| cflags += [ |
| "-Wno-header-hygiene", |
| "-Wno-unused-private-field", |
| "-Wno-inconsistent-missing-override", |
| "-Wno-unknown-warning-option", |
| ] |
| } else { |
| # GCC |
| cflags += [ |
| "-Wno-redundant-move", |
| "-Wno-uninitialized", |
| "-Wno-init-list-lifetime", |
| |
| # Bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465#c16 triggered by |
| # https://github.com/WebAssembly/binaryen/blob/cdb7aeab40b4c522de20b242019f7e88641445d5/src/wasm/wasm-type.cpp#L530. |
| "-Wno-maybe-uninitialized", |
| ] |
| } |
| } |
| |
| if (is_win) { |
| libs = [ "shell32.lib" ] |
| } |
| } |
| |
| action("generate_needed_files") { |
| script = "generate_needed_files.py" |
| |
| inputs = [ |
| "src/src/passes/wasm-intrinsics.wat", |
| "src/src/passes/WasmIntrinsics.cpp.in", |
| "src/CMakeLists.txt", |
| "src/config.h.in", |
| ] |
| |
| args = [ |
| rebase_path("src/src/passes/wasm-intrinsics.wat", root_build_dir), |
| rebase_path("src/src/passes/WasmIntrinsics.cpp.in", root_build_dir), |
| rebase_path("$target_gen_dir/WasmIntrinsics.cpp", root_build_dir), |
| |
| rebase_path("src/CMakeLists.txt", root_build_dir), |
| rebase_path("src/config.h.in", root_build_dir), |
| rebase_path("$target_gen_dir/config.h", root_build_dir), |
| ] |
| outputs = [ |
| "$target_gen_dir/WasmIntrinsics.cpp", |
| "$target_gen_dir/config.h", |
| ] |
| } |
| |
| source_set("binaryen_sources") { |
| src_dirs = [ |
| "src/src/analysis", |
| "src/src/asmjs", |
| "src/src/cfg", |
| "src/src/emscripten-optimizer", |
| "src/src/ir", |
| "src/src/parser", |
| "src/src/passes", |
| "src/src/support", |
| "src/src/tools/fuzzing", |
| "src/src/wasm", |
| "src/third_party/llvm-project", |
| ] |
| |
| # We avoid listing all sources manually, this means when updating |
| # binaryen in DEPS (or manually editing) one has to ensure to |
| # re-run GN in DEPS to ensure new dependencies are picked up. |
| # (this lowers the maintenance burden of GN build support for binaryen) |
| sources = [] |
| foreach(src_dir, src_dirs) { |
| foreach(src_file, |
| exec_script("list_sources.py", |
| [ rebase_path(src_dir, root_build_dir) ], |
| "list lines", |
| [ "$default_git_folder/logs/HEAD" ])) { |
| sources += [ "$src_dir/$src_file" ] |
| } |
| } |
| |
| include_dirs = [ |
| "src/src", |
| "src/third_party/llvm-project/include", |
| ] |
| |
| # Ensure WasmIntrinsics.cpp/config.h files are generated. |
| deps = [ ":generate_needed_files" ] |
| |
| # Ensure generated WasmIntrinsics.cpp file is included in build. |
| sources += [ "$target_gen_dir/WasmIntrinsics.cpp" ] |
| |
| # Ensure generated config.h file is include path. |
| include_dirs += [ "$target_gen_dir" ] |
| |
| configs += [ |
| "//build/config/compiler:enable_exceptions", |
| ":binaryen_flags", |
| ] |
| } |
| |
| template("wasm_tool") { |
| executable(target_name) { |
| sources = [ string_join("", |
| [ |
| "src/src/tools/", |
| target_name, |
| ".cpp", |
| ]) ] |
| include_dirs = [ "src/src" ] |
| deps = [ ":binaryen_sources" ] |
| forward_variables_from(invoker, "*") |
| |
| configs += [ |
| "//build/config/compiler:enable_exceptions", |
| ":binaryen_flags", |
| ] |
| } |
| } |
| |
| wasm_tool("wasm-opt") { |
| } |
| wasm_tool("wasm-shell") { |
| } |
| wasm_tool("wasm-metadce") { |
| } |
| wasm_tool("wasm-emscripten-finalize") { |
| } |
| wasm_tool("wasm-as") { |
| } |
| wasm_tool("wasm-dis") { |
| } |
| wasm_tool("wasm-ctor-eval") { |
| } |
| wasm_tool("wasm-reduce") { |
| } |
| wasm_tool("wasm-fuzz-types") { |
| } |
| wasm_tool("wasm2js") { |
| } |
| |
| group("binaryen_tools") { |
| deps = [ |
| ":wasm-as", |
| ":wasm-ctor-eval", |
| ":wasm-dis", |
| ":wasm-emscripten-finalize", |
| ":wasm-fuzz-types", |
| ":wasm-metadce", |
| ":wasm-opt", |
| ":wasm-reduce", |
| ":wasm-shell", |
| ":wasm2js", |
| ] |
| } |