2018-06-29 20:43:57 +00:00
|
|
|
if (is_debug) {
|
|
|
|
node_configuration = "Debug"
|
|
|
|
} else {
|
|
|
|
node_configuration = "Release"
|
|
|
|
}
|
|
|
|
|
2018-05-15 16:31:13 +00:00
|
|
|
action("configure_node") {
|
|
|
|
script = "//third_party/electron_node/configure"
|
2018-06-26 20:58:20 +00:00
|
|
|
ssl_libname_suffix = ""
|
|
|
|
if (is_win) {
|
|
|
|
ssl_libname_suffix = ".dll"
|
|
|
|
}
|
2018-05-15 16:31:13 +00:00
|
|
|
args = [
|
|
|
|
"--enable-static",
|
|
|
|
"--release-urlbase=https://atom.io/download/electron",
|
2018-06-19 15:39:43 +00:00
|
|
|
"--shared-openssl",
|
|
|
|
"--shared-openssl-includes=" + rebase_path("//third_party/boringssl/src/include"),
|
2018-06-26 20:58:20 +00:00
|
|
|
"--shared-openssl-libname=boringssl" + ssl_libname_suffix,
|
2018-06-19 15:39:43 +00:00
|
|
|
"--shared-openssl-libpath=" + rebase_path(root_out_dir),
|
2018-05-15 16:31:13 +00:00
|
|
|
"--without-npm",
|
|
|
|
"--without-bundled-v8",
|
|
|
|
"--without-dtrace",
|
|
|
|
"--without-etw",
|
|
|
|
"--without-perfctr",
|
|
|
|
"--without-v8-platform",
|
|
|
|
"--without-intl",
|
|
|
|
"--prefix=",
|
|
|
|
"--config-out-dir=" + rebase_path(target_gen_dir),
|
|
|
|
"--no-run-gyp",
|
|
|
|
]
|
2018-07-11 17:43:52 +00:00
|
|
|
if (is_component_build) {
|
|
|
|
args += [ "--shared" ]
|
|
|
|
}
|
2018-05-15 16:31:13 +00:00
|
|
|
outputs = [
|
|
|
|
"$target_gen_dir/config.gypi",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-05-03 22:44:29 +00:00
|
|
|
action("gyp_node") {
|
|
|
|
script = "//tools/gyp/gyp_main.py"
|
2018-05-15 16:31:13 +00:00
|
|
|
deps = [ ":configure_node" ]
|
2018-05-03 22:44:29 +00:00
|
|
|
inputs = [
|
|
|
|
"//third_party/electron_node/common.gypi",
|
|
|
|
"//third_party/electron_node/node.gyp",
|
|
|
|
"//third_party/electron_node/node.gypi",
|
2018-05-15 16:31:13 +00:00
|
|
|
"$target_gen_dir/config.gypi",
|
|
|
|
"node_override.gypi",
|
2018-05-03 22:44:29 +00:00
|
|
|
]
|
|
|
|
outputs = [
|
2018-06-29 20:43:57 +00:00
|
|
|
"$target_out_dir/$node_configuration/build.ninja",
|
2018-05-03 22:44:29 +00:00
|
|
|
]
|
2018-05-16 19:51:11 +00:00
|
|
|
|
2018-06-29 20:48:16 +00:00
|
|
|
# By default, node will build a dylib called something like
|
|
|
|
# libnode.$node_module_version.dylib, which is inconvenient for our
|
|
|
|
# purposes (since it makes the library's name unpredictable). This forces
|
|
|
|
# it to drop the module_version from the filename and just produce
|
|
|
|
# `libnode.dylib`.
|
|
|
|
if (is_mac) {
|
|
|
|
shlib_suffix = "dylib"
|
|
|
|
} else if (is_win) {
|
|
|
|
shlib_suffix = "dll"
|
|
|
|
} else if (is_linux) {
|
|
|
|
shlib_suffix = "so"
|
|
|
|
}
|
|
|
|
|
2018-05-03 22:44:29 +00:00
|
|
|
args = [
|
2018-05-15 16:31:13 +00:00
|
|
|
"-I", rebase_path("$target_gen_dir/config.gypi", root_build_dir),
|
|
|
|
"-I", rebase_path("node_override.gypi", root_build_dir),
|
2018-05-15 16:53:20 +00:00
|
|
|
"-I", rebase_path("//third_party/electron_node/common.gypi", root_build_dir),
|
2018-05-03 22:44:29 +00:00
|
|
|
"-D", "component=shared_library",
|
2018-05-15 16:31:13 +00:00
|
|
|
"-D", "target_arch=$target_cpu",
|
|
|
|
"-D", "host_arch=$host_cpu",
|
|
|
|
"-D", "config_gypi=" + rebase_path("$target_gen_dir/config.gypi"),
|
2018-06-29 20:48:16 +00:00
|
|
|
# This has _gn suffixed otherwise it gets overridden by a shlib_suffix
|
|
|
|
# that's set in node's gyp files. Don't ask me 🤷
|
|
|
|
"-D", "shlib_suffix_gn=" + shlib_suffix,
|
2018-06-29 20:48:56 +00:00
|
|
|
"-D", "llvm_dir=" + rebase_path("//third_party/llvm-build/Release+Asserts"),
|
|
|
|
"-D", "libcxx_dir=" + rebase_path("//buildtools/third_party/libc++"),
|
|
|
|
"-D", "libcxxabi_dir=" + rebase_path("//buildtools/third_party/libc++abi"),
|
2018-07-11 17:43:52 +00:00
|
|
|
"-D", "is_component_build=$is_component_build",
|
2018-05-03 22:44:29 +00:00
|
|
|
"-Goutput_dir=./$target_out_dir", # bizarrely, gyp generates from the build root instead of from cwd
|
|
|
|
"-fninja",
|
|
|
|
rebase_path("//third_party/electron_node/node.gyp", root_build_dir),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
action("build_node") {
|
|
|
|
deps = [
|
2018-06-19 15:39:43 +00:00
|
|
|
"//third_party/boringssl",
|
2018-05-03 22:44:29 +00:00
|
|
|
"//third_party/icu",
|
|
|
|
"//v8",
|
|
|
|
"//v8:v8_libbase",
|
|
|
|
"//v8:v8_libplatform",
|
|
|
|
":gyp_node",
|
|
|
|
]
|
|
|
|
script = "//electron/build/run-ninja.py"
|
|
|
|
args = [
|
2018-06-29 20:43:57 +00:00
|
|
|
"-C", rebase_path(target_out_dir, root_build_dir) + "/$node_configuration",
|
2018-07-11 17:43:52 +00:00
|
|
|
"node_lib",
|
|
|
|
"libuv", "nghttp2", "cares", "http_parser", "zlib"
|
2018-05-03 22:44:29 +00:00
|
|
|
]
|
2018-05-16 19:51:11 +00:00
|
|
|
if (is_mac) {
|
2018-07-11 17:43:52 +00:00
|
|
|
if (is_component_build) {
|
|
|
|
outputs = [ "$target_out_dir/$node_configuration/libnode.dylib" ]
|
|
|
|
} else {
|
|
|
|
outputs = [
|
|
|
|
"$target_out_dir/$node_configuration/libnode.a",
|
|
|
|
"$target_out_dir/$node_configuration/libcares.a",
|
|
|
|
"$target_out_dir/$node_configuration/libhttp_parser.a",
|
|
|
|
"$target_out_dir/$node_configuration/libnghttp2.a",
|
|
|
|
"$target_out_dir/$node_configuration/libuv.a",
|
|
|
|
"$target_out_dir/$node_configuration/libzlib.a",
|
|
|
|
]
|
|
|
|
}
|
2018-05-16 19:51:11 +00:00
|
|
|
}
|
|
|
|
if (is_linux) {
|
2018-07-11 17:43:52 +00:00
|
|
|
if (is_component_build) {
|
|
|
|
outputs = [ "$target_out_dir/$node_configuration/lib/libnode.so" ]
|
|
|
|
} else {
|
|
|
|
outputs = [
|
2018-07-12 01:11:48 +00:00
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/libnode.a",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/uv/libuv.a",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/nghttp2/libnghttp2.a",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/cares/libcares.a",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/http_parser/libhttp_parser.a",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/zlib/libzlib.a",
|
2018-07-11 17:43:52 +00:00
|
|
|
]
|
|
|
|
}
|
2018-05-16 19:51:11 +00:00
|
|
|
}
|
2018-06-26 20:58:20 +00:00
|
|
|
if (is_win) {
|
2018-07-11 17:43:52 +00:00
|
|
|
if (is_component_build) {
|
|
|
|
outputs = [
|
|
|
|
"$target_out_dir/$node_configuration/node.dll.lib",
|
|
|
|
"$target_out_dir/$node_configuration/node.dll",
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
outputs = [
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/node.lib",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/uv/libuv.lib",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/nghttp2/nghttp2.lib",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/cares/cares.lib",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/http_parser/http_parser.lib",
|
|
|
|
"$target_out_dir/$node_configuration/obj/third_party/electron_node/deps/zlib/zlib.lib",
|
|
|
|
]
|
|
|
|
}
|
2018-06-26 20:58:20 +00:00
|
|
|
}
|
2018-05-03 22:44:29 +00:00
|
|
|
}
|
|
|
|
|
2018-05-16 19:51:11 +00:00
|
|
|
node_libs = get_target_outputs(":build_node")
|
|
|
|
|
2018-05-03 22:44:29 +00:00
|
|
|
copy("copy_node") {
|
|
|
|
deps = [ ":build_node" ]
|
2018-05-16 19:51:11 +00:00
|
|
|
sources = node_libs
|
2018-05-03 22:44:29 +00:00
|
|
|
outputs = [ "$root_out_dir/{{source_file_part}}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
config("node_config") {
|
|
|
|
include_dirs = [
|
|
|
|
"//third_party/electron_node/src",
|
|
|
|
"//third_party/electron_node/deps/uv/include",
|
|
|
|
"//third_party/electron_node/deps/cares/include",
|
|
|
|
]
|
2018-07-11 17:43:52 +00:00
|
|
|
if (is_win && is_component_build) {
|
|
|
|
# Windows builds need both the .dll and the .dll.lib copied, but only the
|
|
|
|
# .dll.lib goes in the `libs` list.
|
|
|
|
libs = [ node_libs[0] ]
|
|
|
|
} else {
|
|
|
|
libs = node_libs
|
|
|
|
}
|
2018-05-03 22:44:29 +00:00
|
|
|
cflags_cc = [
|
|
|
|
"-Wno-deprecated-declarations",
|
|
|
|
]
|
|
|
|
defines = [
|
|
|
|
# We need to access internal implementations of Node.
|
|
|
|
"NODE_WANT_INTERNALS=1",
|
|
|
|
"HAVE_OPENSSL=1",
|
|
|
|
"HAVE_INSPECTOR=1",
|
|
|
|
]
|
2018-07-11 17:43:52 +00:00
|
|
|
if (is_component_build) {
|
|
|
|
defines += [ "NODE_SHARED_MODE" ]
|
|
|
|
}
|
2018-05-03 22:44:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
group("node") {
|
|
|
|
public_configs = [ ":node_config" ]
|
|
|
|
public_deps = [ ":copy_node" ]
|
|
|
|
}
|