# Copyright (C) 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("../wasm_vars.gni")

# Used by //gn/standalone/toolchain/BUILD.gn .
em_config = rebase_path(".emscripten", "")
if (is_mac_host) {
  emsdk_dir = rebase_path("//buildtools/mac/emsdk", "")
} else {
  emsdk_dir = rebase_path("//buildtools/linux64/emsdk", "")
}

# Defines a WASM library target.
# Args:
#  generate_js: when true generates a .wasm file and a .js file that wraps it
#      and provides the boilerplate to initialize the module.
#  generate_html: when true generates also an example .html file which contains
#      a minimal console to interact with the module (useful for testing).
template("wasm_lib") {
  assert(defined(invoker.name))

  # If the name is foo the target_name must be foo_wasm.
  assert(invoker.name + "_wasm" == target_name)
  _lib_name = invoker.name
  if (is_wasm) {
    _exports = "['ccall', 'callMain', 'addFunction', 'FS']"
    _target_ldflags = [
      "-s",
      "WASM=1",
      "-s",
      "DISABLE_EXCEPTION_CATCHING=1",
      "-s",
      "NO_DYNAMIC_EXECUTION=1",
      "-s",
      "INITIAL_MEMORY=33554432",
      "-s",
      "ALLOW_MEMORY_GROWTH=1",
      "-s",
      "ALLOW_TABLE_GROWTH=1",
      "-s",
      "WASM_ASYNC_COMPILATION=0",
      "-s",
      "EXTRA_EXPORTED_RUNTIME_METHODS=" + _exports,

      # This forces the MEMFS filesystem library to always use typed arrays
      # instead of building strings/arrays when appending to a file. This allows
      # to deal with pseudo-files larger than 128 MB when calling traceconv.
      "-s",
      "MEMFS_APPEND_TO_TYPED_ARRAYS=1",

      # Reduces global namespace pollution.
      "-s",
      "MODULARIZE=1",

      # This is to prevent that two different wasm modules end up generating
      # JS that overrides the same global variable (var Module = ...)
      "-s",
      "EXPORT_NAME=${target_name}",

      "-lworkerfs.js",  # For FS.filesystems.WORKERFS
    ]
    if (is_debug) {
      _target_ldflags += [
        "-s",
        "ASSERTIONS=2",
        "-s",
        "SAFE_HEAP=1",
        "-s",
        "STACK_OVERFLOW_CHECK=1",
        "-g4",
        "-O0",
      ]
    } else {
      _target_ldflags += [
        "-s",
        "ASSERTIONS=1",
        "-g2",  # Required for getting C++ symbol names.
        "-O3",
      ]
    }

    if (defined(invoker.js_library)) {
      _target_ldflags += [
        "--js-library",
        invoker.js_library,
      ]
    }

    _vars_to_forward = [
      "cflags",
      "defines",
      "deps",
      "includes",
      "sources",
      "include_dirs",
      "public_configs",
      "testonly",
      "visibility",
    ]

    executable("${_lib_name}.js") {
      forward_variables_from(invoker, _vars_to_forward)
      ldflags = _target_ldflags
      output_extension = ""
    }

    # This is just a workaround to deal with the fact that GN doesn't allow
    # spcifying extra outputs for an executable() target. In reality the .wasm
    # file here is generated by the executable() target above, together with the
    # .js file. This dummy target is here to tell GN "there is a target that
    # outputs also the .wasm file", so we can depend on that in copy() targets.
    action("${_lib_name}.wasm") {
      inputs = []
      deps = [ ":${_lib_name}.js" ]
      outputs = [ "$root_out_dir/$_lib_name.wasm" ]
      if (is_debug) {
        outputs += [ "$root_out_dir/$_lib_name.wasm.map" ]
      }
      args = [ "--noop" ]
      script = "//gn/standalone/build_tool_wrapper.py"
    }

    copy("${_lib_name}.d.ts") {
      sources = [ "//gn/standalone/wasm_typescript_declaration.d.ts" ]
      outputs = [ "$root_out_dir/$_lib_name.d.ts" ]
    }
  } else {  # is_wasm
    not_needed(invoker, "*")
  }

  group(target_name) {
    deps = [
      ":${_lib_name}.d.ts($wasm_toolchain)",
      ":${_lib_name}.js($wasm_toolchain)",
      ":${_lib_name}.wasm($wasm_toolchain)",
    ]
  }
}  # template
