blob: e57c3be7faf9163ead503f86a319502aaf3484cc [file] [log] [blame]
import("//build/config/c++/c++.gni")
import("//node/node.gni")
if (is_mac) {
import("//build/config/mac/mac_sdk.gni")
}
group("node_tests") {
testonly = true
deps = [
# The tests files are copied for consumption in node_integration_ng.py.
# TODO(zcbenz): Remove this after refactoring node_integration_ng.py.
":copy_test_common",
":copy_test_testpy",
":node_test_addons",
":node_test_js_native_api",
":node_test_node_api",
]
}
action("node_headers") {
deps = [
"$node_v8_path:v8_headers",
"$node_path:generate_config_gypi"
]
stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ stamp ]
script = "//tools/run_with_env.py"
args = [
rebase_path("$node_path/tools/install.py", root_build_dir),
"install",
"--silent",
"--headers-only",
"--prefix",
"/",
"--dest-dir",
rebase_path("$root_gen_dir/node_headers"),
"--config-gypi-path",
rebase_path("$root_gen_dir/node/config.gypi"),
"--v8-dir",
rebase_path(node_v8_path),
"--root-dir",
rebase_path(node_path),
"--stamp",
rebase_path(stamp),
]
}
template("copy_dir") {
action(target_name) {
testonly = true
forward_variables_from(invoker, [ "deps" ])
script = "//tools/run_with_env.py"
stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ stamp ]
args = [
rebase_path("//tools/cp_dir.py", root_build_dir),
rebase_path(invoker.src, root_build_dir),
rebase_path(invoker.dest, root_build_dir),
"--stamp",
rebase_path(stamp, root_build_dir),
]
}
}
template("build_addons") {
testonly = true
group(target_name) {
deps = [
":$target_name" + "_build",
":$target_name" + "_copy",
]
}
action(target_name + "_build") {
deps = [
":node_headers",
"$node_path:node",
]
script = "//tools/run_with_env.py"
# TODO(zcbenz): Make search_files.py support more extensions.
inputs = exec_script("$node_path/tools/search_files.py",
[
rebase_path(".", root_build_dir),
rebase_path("$node_path/test/" + invoker.target,
root_build_dir),
"cc",
],
"list lines")
stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ stamp ]
args = [
rebase_path("$node_path/tools/build_addons.py"),
rebase_path("$node_path/test/" + invoker.target),
"--loglevel",
"verbose",
"--out-dir",
rebase_path(root_build_dir),
"--headers-dir",
rebase_path("$root_gen_dir/node_headers"),
"--stamp",
rebase_path(stamp),
]
if (defined(invoker.skip_tests)) {
args += [
"--skip-tests",
string_join(",", invoker.skip_tests),
]
}
clang_path =
rebase_path("//third_party/llvm-build/Release+Asserts/bin/clang++")
clang_args = ""
if (use_custom_libcxx) {
# TODO(zcbenz): Following code makes native addons build with the custom
# libcxx headers, but does not actually link with libcxx, and some addons
# tests will fail with linking error.
# We should eventually find a way to link the addons with custom libcxx,
# and enable this code path, because the node addons should use the same
# libcxx with the node binary otherwise addons would crash when using V8
# APIs that use STL containers.
config_site_path = rebase_path("//buildtools/third_party/libc++")
libcpp_path = rebase_path("//third_party/libc++")
libcppabi_path = rebase_path("//third_party/libc++abi")
clang_args =
"-isystem $libcpp_path/src/include " +
"-isystem $libcppabi_path/src/include " + "-I $config_site_path " +
"-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE " +
"-nostdinc++ " + "-nostdlib++ "
if (is_mac) {
mac_sdk_path_abs = rebase_path(mac_sdk_path)
clang_args += "-isysroot $mac_sdk_path_abs "
}
}
args += [
"--env",
"CXX",
"$clang_path $clang_args",
]
}
# The tests files are copied for consumption in node_integration_ng.py.
# TODO(zcbenz): Remove this after refactoring node_integration_ng.py.
copy_dir(target_name + "_copy") {
build_step = invoker.target_name + "_build"
deps = [
":$build_step",
":node_headers",
"$node_path:node",
]
src = "$node_path/test/" + invoker.target
dest = "$root_gen_dir/node/test/" + invoker.target
}
}
build_addons("node_test_addons") {
target = "addons"
if (target_os == "mac") {
# TODO(zcbenz): Following addons fail to link.
skip_tests = [
"openssl-client-cert-engine",
"openssl-key-engine",
"openssl-test-engine",
]
}
}
build_addons("node_test_node_api") {
target = "node-api"
skip_tests = [
"test_instance_data",
]
}
build_addons("node_test_js_native_api") {
target = "js-native-api"
}
copy_dir("copy_test_common") {
src = "$node_path/test/common"
dest = "$root_gen_dir/node/test/common"
}
copy_dir("copy_test_testpy") {
src = "$node_path/test/testpy"
dest = "$root_gen_dir/node/test/testpy"
}