From 99ecbfbd3bc91be43c3939af37001820d44747d6 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:43:57 -0700 Subject: [PATCH 1/5] build: [gn] use consistent node configuration between gyp and build --- build/node/BUILD.gn | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/build/node/BUILD.gn b/build/node/BUILD.gn index a36d3a5654..c6a57fdbfe 100644 --- a/build/node/BUILD.gn +++ b/build/node/BUILD.gn @@ -1,3 +1,9 @@ +if (is_debug) { + node_configuration = "Debug" +} else { + node_configuration = "Release" +} + action("configure_node") { script = "//third_party/electron_node/configure" ssl_libname_suffix = "" @@ -39,7 +45,7 @@ action("gyp_node") { "node_override.gypi", ] outputs = [ - "$target_out_dir/Release/build.ninja", + "$target_out_dir/$node_configuration/build.ninja", ] args = [ @@ -66,23 +72,18 @@ action("build_node") { ":gyp_node", ] script = "//electron/build/run-ninja.py" - if (is_debug) { - configuration = "Debug" - } else { - configuration = "Release" - } args = [ - "-C", rebase_path(target_out_dir, root_build_dir) + "/$configuration", + "-C", rebase_path(target_out_dir, root_build_dir) + "/$node_configuration", "node_lib" ] if (is_mac) { - outputs = [ "$target_out_dir/$configuration/libnode.dylib" ] + outputs = [ "$target_out_dir/$node_configuration/libnode.dylib" ] } if (is_linux) { - outputs = [ "$target_out_dir/$configuration/lib/libnode.so" ] + outputs = [ "$target_out_dir/$node_configuration/lib/libnode.so" ] } if (is_win) { - outputs = [ "$target_out_dir/$configuration/node.dll.lib", "$target_out_dir/$configuration/node.dll" ] + outputs = [ "$target_out_dir/$node_configuration/node.dll.lib", "$target_out_dir/$node_configuration/node.dll" ] } } From d4cf3cee22b51669962eb3831a8ff95c11d80be2 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:48:16 -0700 Subject: [PATCH 2/5] 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 c6a57fdbfe..df7ac48af5 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 fed4cfd786..25aaf2c2b1 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': [ From 1e1adef9b6aeab136ba58b5e8004f04161a2b4d3 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:48:56 -0700 Subject: [PATCH 3/5] build: [gn] use clang and custom stdlib when building node on linux --- build/node/BUILD.gn | 3 +++ build/node/node_override.gypi | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/build/node/BUILD.gn b/build/node/BUILD.gn index df7ac48af5..e231e98c5f 100644 --- a/build/node/BUILD.gn +++ b/build/node/BUILD.gn @@ -72,6 +72,9 @@ action("gyp_node") { # 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, + "-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"), "-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 25aaf2c2b1..d1e68131de 100644 --- a/build/node/node_override.gypi +++ b/build/node/node_override.gypi @@ -6,6 +6,34 @@ 'shlib_suffix': '<(shlib_suffix_gn)', }, + 'conditions': [ + ['OS=="linux"', { + 'make_global_settings': [ + ['CC', '<(llvm_dir)/bin/clang'], + ['CXX', '<(llvm_dir)/bin/clang++'], + ['CC.host', '$(CC)'], + ['CXX.host', '$(CXX)'], + ], + 'target_defaults': { + 'target_conditions': [ + ['_toolset=="target"', { + 'cflags_cc': [ + '-std=gnu++14', + '-nostdinc++', + '-isystem<(libcxx_dir)/trunk/include', + '-isystem<(libcxxabi_dir)/trunk/include', + ], + 'ldflags': [ + '-nostdlib++', + ], + 'libraries': [ + '../../../../../../libc++.so', + ], + }] + ] + } + }] + ], 'target_defaults': { 'target_conditions': [ ['_target_name=="node_lib"', { From 62f62264da8c555b9fb64ea0231460befa79dde0 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:39:22 -0700 Subject: [PATCH 4/5] build: [gn] move crashpad to mac-only --- BUILD.gn | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 382ae69080..b18b36dd26 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -223,7 +223,6 @@ static_library("electron_lib") { "//skia", "//third_party/WebKit/public:blink", "//third_party/boringssl", - "//third_party/crashpad/crashpad/client", "//third_party/leveldatabase", "//third_party/libyuv", "//ui/events:dom_keycode_converter", @@ -244,6 +243,13 @@ static_library("electron_lib") { if (is_mac) { deps += [ "//ui/accelerated_widget_mac", + "//third_party/crashpad/crashpad/client", + ] + include_dirs += [ + # NOTE(nornagon): other chromium files use the full path to include + # crashpad; this is just here for compatibility between GN and GYP, so that + # the #includes can be agnostic about where crashpad is vendored. + "//third_party/crashpad", ] } if (is_linux) { @@ -251,7 +257,6 @@ static_library("electron_lib") { "//build/config/linux/gtk3", "//chrome/browser/ui/libgtkui", "//device/bluetooth", - "//third_party/breakpad:client", "//ui/events/devices/x11", "//ui/events/platform/x11", "//ui/native_theme", @@ -260,11 +265,6 @@ static_library("electron_lib") { ] configs += [ ":gio_unix" ] } - if (is_win) { - deps += [ - "//third_party/breakpad:client", - ] - } defines = [ # Disable warnings for g_settings_list_schemas. "GLIB_DISABLE_DEPRECATION_WARNINGS", @@ -281,12 +281,9 @@ static_library("electron_lib") { # TODO(nornagon): replace usage of SchemeRegistry by an actually exported # API of blink, then delete this include dir. "//third_party/WebKit/Source", - # NOTE(nornagon): other chromium files use the full path to include - # crashpad; this is just here for compatibility between GN and GYP, so that - # the #includes can be agnostic about where crashpad is vendored. - "//third_party/crashpad", ] if (is_linux || is_win) { + deps += [ "//third_party/breakpad:client" ] include_dirs += [ "//third_party/breakpad", ] From 9241645a4b99942294478de29ab84e24d29e54b9 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:43:13 -0700 Subject: [PATCH 5/5] build: [gn] depend on /gtk instead of /gtk3 (We still depend on gtk3, just via one extra layer of abstraction. The /gtk target itself depends on /gtk3.) --- BUILD.gn | 2 +- brightray/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index b18b36dd26..8344df40b4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -254,7 +254,7 @@ static_library("electron_lib") { } if (is_linux) { deps += [ - "//build/config/linux/gtk3", + "//build/config/linux/gtk", "//chrome/browser/ui/libgtkui", "//device/bluetooth", "//ui/events/devices/x11", diff --git a/brightray/BUILD.gn b/brightray/BUILD.gn index c2185726ab..088aba9fa1 100644 --- a/brightray/BUILD.gn +++ b/brightray/BUILD.gn @@ -51,7 +51,7 @@ static_library("brightray") { if (is_linux) { deps += [ - "//build/config/linux/gtk3", + "//build/config/linux/gtk", ":libnotify", ] }