Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ template("gcc_toolchain") {
if (defined(invoker.is_clang)) {
is_clang = invoker.is_clang
}

if (defined(invoker.extra_toolchain_args)) {
forward_variables_from(invoker.extra_toolchain_args, "*")
}
}

if (defined(invoker.deps)) {
Expand Down
40 changes: 38 additions & 2 deletions build/toolchain/wasm.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,53 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/toolchain/ccache.gni")
import("//build/toolchain/gcc_toolchain.gni")
import("//build/toolchain/goma.gni")

# Defines the configuration of emscripten for building WASM targets.

declare_args() {
# The location of an activated embedded emsdk.
emsdk_dir = rebase_path("//buildtools/emsdk")
}

wasm_toolchain = "//build/toolchain/wasm"

em_config_path = "$emsdk_dir/.emscripten"

if (use_goma) {
assert(!use_ccache, "Goma and ccache can't be used together.")
compiler_prefix = "$goma_dir/gomacc "
} else if (use_ccache) {
compiler_prefix = "ccache "
} else {
compiler_prefix = ""
}

template("wasm_toolchain") {
gcc_toolchain(target_name) {
# emsdk_dir and em_config are defined in wasm.gni.
ar = "$compiler_prefix$emsdk_dir/upstream/emscripten/emar --em-config $em_config_path"
cc = "$compiler_prefix$emsdk_dir/upstream/emscripten/emcc --em-config $em_config_path"
cxx = "$compiler_prefix$emsdk_dir/upstream/emscripten/em++ --em-config $em_config_path"
ld = cxx
readelf = "readelf"
nm = "nm"

toolchain_cpu = "wasm"
toolchain_os = "wasm"

is_clang = true

link_outputs = [ "{{root_out_dir}}/{{target_output_name}}.wasm" ]

extra_toolchain_args = {
if (defined(invoker.extra_toolchain_args)) {
forward_variables_from(invoker.extra_toolchain_args, "*")
}
}
}
}

# Defines a WASM library target.
# Args:
# export_name: The public name of the module to expose (EXPORT_NAME for
Expand Down
30 changes: 2 additions & 28 deletions build/toolchain/wasm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/toolchain/ccache.gni")
import("//build/toolchain/clang.gni")
import("//build/toolchain/gcc_toolchain.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/wasm.gni")

if (use_goma) {
assert(!use_ccache, "Goma and ccache can't be used together.")
compiler_prefix = "$goma_dir/gomacc "
} else if (use_ccache) {
compiler_prefix = "ccache "
} else {
compiler_prefix = ""
}

gcc_toolchain("wasm") {
# emsdk_dir and em_config are defined in wasm.gni.
ar = "$compiler_prefix$emsdk_dir/upstream/emscripten/emar --em-config $em_config_path"
cc = "$compiler_prefix$emsdk_dir/upstream/emscripten/emcc --em-config $em_config_path"
cxx = "$compiler_prefix$emsdk_dir/upstream/emscripten/em++ --em-config $em_config_path"
ld = cxx
readelf = "readelf"
nm = "nm"

toolchain_cpu = "wasm"
toolchain_os = "wasm"

is_clang = true

link_outputs = [ "{{root_out_dir}}/{{target_output_name}}.wasm" ]
wasm_toolchain("wasm") {
extra_toolchain_args = {}
}