Skip to content

Commit

Permalink
refactor: GN builds on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon committed May 16, 2018
1 parent da0fd10 commit 19a81a4
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 57 deletions.
61 changes: 57 additions & 4 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ if (is_mac) {
import("//v8/gni/v8.gni")
}

if (is_linux) {
import("//build/config/linux/pkg_config.gni")

pkg_config("gio_unix") {
packages = [ "gio-unix-2.0" ]
}
}

declare_args() {
electron_project_name = "electron"
electron_product_name = "Electron"
Expand Down Expand Up @@ -164,13 +172,13 @@ action("atom_js2c") {

asar("js2asar") {
sources = filenames_gypi.js_sources
outputs = [ "$root_out_dir/electron.asar" ]
outputs = [ "$root_out_dir/resources/electron.asar" ]
root = "lib"
}

asar("app2asar") {
sources = filenames_gypi.default_app_sources
outputs = [ "$root_out_dir/default_app.asar" ]
outputs = [ "$root_out_dir/resources/default_app.asar" ]
root = "default_app"
}

Expand Down Expand Up @@ -224,6 +232,20 @@ static_library("electron_lib") {
"//base/allocator:features",
]
}
if (is_linux) {
deps += [
"//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",
"//ui/views/controls/webview",
"//ui/wm",
]
configs += [ ":gio_unix" ]
}
defines = [
# This is defined in skia/skia_common.gypi.
"SK_SUPPORT_LEGACY_GETTOPDEVICE",
Expand All @@ -250,6 +272,11 @@ static_library("electron_lib") {
# the #includes can be agnostic about where crashpad is vendored.
"//third_party/crashpad",
]
if (is_linux) {
include_dirs += [
"//third_party/breakpad",
]
}

extra_source_filters = []
if (!is_linux) {
Expand All @@ -261,6 +288,12 @@ static_library("electron_lib") {
"*_gtk.cc",
]
}
if (!is_win) {
extra_source_filters += [
"*\bwin_*.h",
"*\bwin_*.cc",
]
}
if (is_mac) {
extra_source_filters += [
"*_views.cc",
Expand Down Expand Up @@ -318,6 +351,7 @@ static_library("electron_lib") {
}
if (is_linux) {
sources += filenames_gypi.lib_sources_linux
sources += filenames_gypi.lib_sources_nss
}
}

Expand Down Expand Up @@ -463,8 +497,8 @@ if (is_mac) {
":app2asar",
]
sources = [
"$root_out_dir/electron.asar",
"$root_out_dir/default_app.asar",
"$root_out_dir/resources/electron.asar",
"$root_out_dir/resources/default_app.asar",
]
outputs = [
"{{bundle_resources_dir}}/{{source_file_part}}"
Expand Down Expand Up @@ -513,3 +547,22 @@ if (is_mac) {
]
}
}

if (is_linux) {
executable("electron_app") {
output_name = electron_project_name
sources = filenames_gypi.app_sources
include_dirs = [ "." ]
deps = [
":app2asar",
":electron_lib",
":js2asar",
"//build/config:exe_and_shlib_deps",
"//chrome:packed_resources",
"//content/shell:copy_shell_resources",
"//content/shell:pak",
"//third_party/WebKit/public:image_resources",
"//ui/strings",
]
}
}
23 changes: 23 additions & 0 deletions brightray/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ filenames_gypi = exec_script(
[ "filenames.gypi" ]
)


if (is_linux) {
# TODO: Experiment with using //tools/generate_library_loader for generating
# the libnotify loader.
copy("libnotify_headers") {
sources = [
"/usr/include/libnotify/notify.h",
"/usr/include/libnotify/notification.h",
"/usr/include/libnotify/notify-enum-types.h",
"/usr/include/libnotify/notify-features.h",
]
outputs = [ "$target_gen_dir/libnotify-copy/libnotify/{{source_file_part}}" ]
}
}

static_library("brightray") {
deps = [
"//base",
Expand All @@ -27,6 +42,14 @@ static_library("brightray") {
"DISABLE_NACL=1",
]

if (is_linux) {
include_dirs += [ "$target_gen_dir/libnotify-copy" ]
deps += [
"//build/config/linux/gtk3",
":libnotify_headers",
]
}

extra_source_filters = []
if (is_mac) {
extra_source_filters += [
Expand Down
31 changes: 24 additions & 7 deletions build/node/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ action("gyp_node") {
outputs = [
"$target_out_dir/Release/build.ninja",
]

# TODO(jeremy): should shlib_suffix be set inside node.gypi?
if (is_mac) {
shlib_suffix = "dylib"
} else if (is_linux) {
shlib_suffix = "so"
}
args = [
"-I", rebase_path("toolchain.gypi", root_build_dir),
"-I", rebase_path("node.gypi", root_build_dir),
"-I", rebase_path("//third_party/electron_node/common.gypi", root_build_dir),
# TODO(jeremy): make these paths relative instead of absolute, to help
# caches.
"-D", "chromium_root_out_dir=" + rebase_path(root_out_dir),
"-D", "chromium_src_dir=" + rebase_path("//"),
"-D", "component=shared_library",
"-D", "buildtype=Custom",
"-D", "target_arch=x64",
"-D", "host_arch=x64",
"-D", "shlib_suffix=$shlib_suffix",
"-D", "is_component_build=$is_component_build",
"-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),
Expand All @@ -35,14 +49,19 @@ action("build_node") {
"-C", rebase_path(target_out_dir, root_build_dir) + "/Release",
"node_lib"
]
outputs = [
"$target_out_dir/Release/libnode.dylib"
]
if (is_mac) {
outputs = [ "$target_out_dir/Release/libnode.dylib" ]
}
if (is_linux) {
outputs = [ "$target_out_dir/Release/lib/libnode.so" ]
}
}

node_libs = get_target_outputs(":build_node")

copy("copy_node") {
deps = [ ":build_node" ]
sources = [ "$target_out_dir/Release/libnode.dylib" ]
sources = node_libs
outputs = [ "$root_out_dir/{{source_file_part}}" ]
}

Expand All @@ -52,9 +71,7 @@ config("node_config") {
"//third_party/electron_node/deps/uv/include",
"//third_party/electron_node/deps/cares/include",
]
libs = [
"$target_out_dir/Release/libnode.dylib"
]
libs = node_libs
cflags_cc = [
"-Wno-deprecated-declarations",
]
Expand Down
69 changes: 23 additions & 46 deletions build/node/node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
'debug_nghttp2': 0,

'node_module_version': '0',
'shlib_suffix': 'dylib',
},
# Settings to compile node under Windows.
'target_defaults': {
Expand Down Expand Up @@ -136,10 +135,10 @@
}],
['_target_name=="node_lib"', {
'include_dirs': [
'../../../v8',
'../../../v8/include',
'../../../third_party/icu/source/common',
'../../../third_party/icu/source/i18n',
'<(chromium_src_dir)/v8',
'<(chromium_src_dir)/v8/include',
'<(chromium_src_dir)/third_party/icu/source/common',
'<(chromium_src_dir)/third_party/icu/source/i18n',
],
'defines': [
# Export V8 symbols from node.dll / libnode.so
Expand All @@ -159,10 +158,10 @@
'OTHER_CFLAGS': ['-fno-rtti'],
},
'libraries': [
'../../../../../../libv8.dylib',
'../../../../../../libv8_libbase.dylib',
'../../../../../../libv8_libplatform.dylib',
'../../../../../../libicuuc.dylib',
'<(chromium_root_out_dir)/libv8<(SHARED_LIB_SUFFIX)',
'<(chromium_root_out_dir)/libv8_libbase<(SHARED_LIB_SUFFIX)',
'<(chromium_root_out_dir)/libv8_libplatform<(SHARED_LIB_SUFFIX)',
'<(chromium_root_out_dir)/libicuuc<(SHARED_LIB_SUFFIX)',
],
'conditions': [
#['OS=="mac" and libchromiumcontent_component==0', {
Expand Down Expand Up @@ -242,21 +241,21 @@
}],
['OS=="linux" and _toolset=="target" and _target_name in ["dump_syms", "node_lib"]', {
'conditions': [
#['libchromiumcontent_component==0', {
#'libraries': [
#'<(libchromiumcontent_dir)/libc++.a',
#],
#'ldflags': [
#'-lpthread',
##],
#}, {
#'libraries': [
#'<(libchromiumcontent_dir)/libc++.so',
#],
#'ldflags': [
#'-Wl,-rpath=\$$ORIGIN',
#],
#}],
['is_component_build==0', {
'libraries': [
'<(chromium_root_out_dir)/libc++.a',
],
'ldflags': [
'-lpthread',
],
}, {
'libraries': [
'<(chromium_root_out_dir)/libc++.so',
],
'ldflags': [
'-Wl,-rpath=\$$ORIGIN',
],
}],
],
}]
],
Expand All @@ -280,26 +279,4 @@
4996, # (atlapp.h) 'GetVersionExW': was declared deprecated
],
},
'conditions': [
# The breakdpad on Windows assumes Debug_x64 and Release_x64 configurations.
['OS=="win"', {
'target_defaults': {
'configurations': {
'Debug_x64': {
},
'Release_x64': {
},
},
},
}], # OS=="win"
# The breakdpad on Mac assumes Release_Base configuration.
['OS=="mac"', {
'target_defaults': {
'configurations': {
'Release_Base': {
},
},
},
}], # OS=="mac"
],
}
35 changes: 35 additions & 0 deletions build/node/toolchain.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
'variables': {
'llvm_dir': '<(chromium_src_dir)/third_party/llvm-build/Release+Asserts',
},
'conditions': [
['clang==1', {
'make_global_settings': [
['CC', '<(llvm_dir)/bin/clang'],
['CXX', '<(llvm_dir)/bin/clang++'],
['CC.host', '$(CC)'],
['CXX.host', '$(CXX)'],
],
'target_defaults': {
'target_conditions': [
['OS=="linux" and _toolset=="target"', {
'cflags_cc': [
'-std=gnu++14',
'-nostdinc++',
'-isystem<(chromium_src_dir)/buildtools/third_party/libc++/trunk/include',
'-isystem<(chromium_src_dir)/buildtools/third_party/libc++abi/trunk/include',
],
'ldflags': [
'-nostdlib++',
],
}],
['OS=="linux" and _toolset=="host"', {
'cflags_cc': [
'-std=gnu++14',
],
}],
],
},
}], # clang==1
],
}

0 comments on commit 19a81a4

Please sign in to comment.