From d4cf3cee22b51669962eb3831a8ff95c11d80be2 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:48:16 -0700 Subject: [PATCH] build: [gn] use platform-appropriate shlib_suffix when building node --- build/node/BUILD.gn | 16 ++++++++++++++++ build/node/node_override.gypi | 7 +------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/build/node/BUILD.gn b/build/node/BUILD.gn index c6a57fdbfef1..df7ac48af51a 100644 --- a/build/node/BUILD.gn +++ b/build/node/BUILD.gn @@ -48,6 +48,19 @@ action("gyp_node") { "$target_out_dir/$node_configuration/build.ninja", ] + # 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" + } + args = [ "-I", rebase_path("$target_gen_dir/config.gypi", root_build_dir), "-I", rebase_path("node_override.gypi", root_build_dir), @@ -56,6 +69,9 @@ action("gyp_node") { "-D", "target_arch=$target_cpu", "-D", "host_arch=$host_cpu", "-D", "config_gypi=" + rebase_path("$target_gen_dir/config.gypi"), + # 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, "-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), diff --git a/build/node/node_override.gypi b/build/node/node_override.gypi index fed4cfd78633..25aaf2c2b179 100644 --- a/build/node/node_override.gypi +++ b/build/node/node_override.gypi @@ -4,12 +4,7 @@ # that we're building v8 with icu, so force it on. 'v8_enable_inspector': 1, - # 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`. - 'shlib_suffix': 'dylib', + 'shlib_suffix': '<(shlib_suffix_gn)', }, 'target_defaults': { 'target_conditions': [