build: auto-gen libnotify_loader.cc (#15648)
This commit is contained in:
		
					parent
					
						
							
								9fd98bb27b
							
						
					
				
			
			
				commit
				
					
						1cf28e8b75
					
				
			
		
					 5 changed files with 34 additions and 182 deletions
				
			
		
							
								
								
									
										33
									
								
								BUILD.gn
									
										
									
									
									
								
							
							
						
						
									
										33
									
								
								BUILD.gn
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -9,6 +9,7 @@ import("//build/config/win/manifest.gni")
 | 
			
		|||
import("//pdf/features.gni")
 | 
			
		||||
import("//services/service_manager/public/service_manifest.gni")
 | 
			
		||||
import("//third_party/ffmpeg/ffmpeg_options.gni")
 | 
			
		||||
import("//tools/generate_library_loader/generate_library_loader.gni")
 | 
			
		||||
import("//tools/grit/grit_rule.gni")
 | 
			
		||||
import("//tools/grit/repack.gni")
 | 
			
		||||
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +27,13 @@ if (is_linux) {
 | 
			
		|||
  pkg_config("gio_unix") {
 | 
			
		||||
    packages = [ "gio-unix-2.0" ]
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  pkg_config("libnotify_config") {
 | 
			
		||||
    packages = [
 | 
			
		||||
      "glib-2.0",
 | 
			
		||||
      "gdk-pixbuf-2.0",
 | 
			
		||||
    ]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
branding = read_file("atom/app/BRANDING.json", "json")
 | 
			
		||||
| 
						 | 
				
			
			@ -194,6 +202,30 @@ grit("resources") {
 | 
			
		|||
  output_dir = "$target_gen_dir"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (is_linux) {
 | 
			
		||||
  generate_library_loader("libnotify_loader") {
 | 
			
		||||
    name = "LibNotifyLoader"
 | 
			
		||||
    output_h = "libnotify_loader.h"
 | 
			
		||||
    output_cc = "libnotify_loader.cc"
 | 
			
		||||
    header = "<libnotify/notify.h>"
 | 
			
		||||
    config = ":libnotify_config"
 | 
			
		||||
 | 
			
		||||
    functions = [
 | 
			
		||||
      "notify_is_initted",
 | 
			
		||||
      "notify_init",
 | 
			
		||||
      "notify_get_server_caps",
 | 
			
		||||
      "notify_get_server_info",
 | 
			
		||||
      "notify_notification_new",
 | 
			
		||||
      "notify_notification_add_action",
 | 
			
		||||
      "notify_notification_set_image_from_pixbuf",
 | 
			
		||||
      "notify_notification_set_timeout",
 | 
			
		||||
      "notify_notification_set_hint_string",
 | 
			
		||||
      "notify_notification_show",
 | 
			
		||||
      "notify_notification_close",
 | 
			
		||||
    ]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static_library("electron_lib") {
 | 
			
		||||
  configs += [ "//v8:external_startup_data" ]
 | 
			
		||||
  configs += [ "//third_party/electron_node:node_internals" ]
 | 
			
		||||
| 
						 | 
				
			
			@ -345,6 +377,7 @@ static_library("electron_lib") {
 | 
			
		|||
  }
 | 
			
		||||
  if (is_linux) {
 | 
			
		||||
    deps += [
 | 
			
		||||
      ":libnotify_loader",
 | 
			
		||||
      "//build/config/linux/gtk",
 | 
			
		||||
      "//chrome/browser/ui/libgtkui",
 | 
			
		||||
      "//device/bluetooth",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,130 +0,0 @@
 | 
			
		|||
// Copyright (c) 2015 GitHub, Inc.
 | 
			
		||||
// Use of this source code is governed by the MIT license that can be
 | 
			
		||||
// found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
#include "atom/browser/notifications/linux/libnotify_loader.h"
 | 
			
		||||
 | 
			
		||||
#include <dlfcn.h>
 | 
			
		||||
 | 
			
		||||
LibNotifyLoader::LibNotifyLoader() : loaded_(false) {}
 | 
			
		||||
 | 
			
		||||
LibNotifyLoader::~LibNotifyLoader() {
 | 
			
		||||
  CleanUp(loaded_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool LibNotifyLoader::Load(const std::string& library_name) {
 | 
			
		||||
  if (loaded_)
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  library_ = dlopen(library_name.c_str(), RTLD_LAZY);
 | 
			
		||||
  if (!library_)
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  notify_is_initted = reinterpret_cast<decltype(this->notify_is_initted)>(
 | 
			
		||||
      dlsym(library_, "notify_is_initted"));
 | 
			
		||||
  if (!notify_is_initted) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_init = reinterpret_cast<decltype(this->notify_init)>(
 | 
			
		||||
      dlsym(library_, "notify_init"));
 | 
			
		||||
  if (!notify_init) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_get_server_info =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_get_server_info)>(
 | 
			
		||||
          dlsym(library_, "notify_get_server_info"));
 | 
			
		||||
  if (!notify_get_server_info) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_get_server_caps =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_get_server_caps)>(
 | 
			
		||||
          dlsym(library_, "notify_get_server_caps"));
 | 
			
		||||
  if (!notify_get_server_caps) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_new =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_notification_new)>(
 | 
			
		||||
          dlsym(library_, "notify_notification_new"));
 | 
			
		||||
  if (!notify_notification_new) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_add_action =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_notification_add_action)>(
 | 
			
		||||
          dlsym(library_, "notify_notification_add_action"));
 | 
			
		||||
  if (!notify_notification_add_action) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_set_image_from_pixbuf = reinterpret_cast<decltype(
 | 
			
		||||
      this->notify_notification_set_image_from_pixbuf)>(
 | 
			
		||||
      dlsym(library_, "notify_notification_set_image_from_pixbuf"));
 | 
			
		||||
  if (!notify_notification_set_image_from_pixbuf) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_set_timeout =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_notification_set_timeout)>(
 | 
			
		||||
          dlsym(library_, "notify_notification_set_timeout"));
 | 
			
		||||
  if (!notify_notification_set_timeout) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_set_hint_string =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_notification_set_hint_string)>(
 | 
			
		||||
          dlsym(library_, "notify_notification_set_hint_string"));
 | 
			
		||||
  if (!notify_notification_set_hint_string) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_show =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_notification_show)>(
 | 
			
		||||
          dlsym(library_, "notify_notification_show"));
 | 
			
		||||
  if (!notify_notification_show) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  notify_notification_close =
 | 
			
		||||
      reinterpret_cast<decltype(this->notify_notification_close)>(
 | 
			
		||||
          dlsym(library_, "notify_notification_close"));
 | 
			
		||||
  if (!notify_notification_close) {
 | 
			
		||||
    CleanUp(true);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  loaded_ = true;
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LibNotifyLoader::CleanUp(bool unload) {
 | 
			
		||||
  if (unload) {
 | 
			
		||||
    dlclose(library_);
 | 
			
		||||
    library_ = NULL;
 | 
			
		||||
  }
 | 
			
		||||
  loaded_ = false;
 | 
			
		||||
  notify_is_initted = NULL;
 | 
			
		||||
  notify_init = NULL;
 | 
			
		||||
  notify_get_server_info = NULL;
 | 
			
		||||
  notify_get_server_caps = NULL;
 | 
			
		||||
  notify_notification_new = NULL;
 | 
			
		||||
  notify_notification_add_action = NULL;
 | 
			
		||||
  notify_notification_set_image_from_pixbuf = NULL;
 | 
			
		||||
  notify_notification_set_timeout = NULL;
 | 
			
		||||
  notify_notification_set_hint_string = NULL;
 | 
			
		||||
  notify_notification_show = NULL;
 | 
			
		||||
  notify_notification_close = NULL;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,49 +0,0 @@
 | 
			
		|||
// Copyright (c) 2015 GitHub, Inc.
 | 
			
		||||
// Use of this source code is governed by the MIT license that can be
 | 
			
		||||
// found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_LOADER_H_
 | 
			
		||||
#define ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_LOADER_H_
 | 
			
		||||
 | 
			
		||||
// FIXME Generate during build using
 | 
			
		||||
// //tools/generate_library_loader/generate_library_loader.gni
 | 
			
		||||
 | 
			
		||||
#include <libnotify/notify.h>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
class LibNotifyLoader {
 | 
			
		||||
 public:
 | 
			
		||||
  LibNotifyLoader();
 | 
			
		||||
  ~LibNotifyLoader();
 | 
			
		||||
 | 
			
		||||
  bool Load(const std::string& library_name)
 | 
			
		||||
      __attribute__((warn_unused_result));
 | 
			
		||||
 | 
			
		||||
  bool loaded() const { return loaded_; }
 | 
			
		||||
 | 
			
		||||
  decltype(&::notify_is_initted) notify_is_initted;
 | 
			
		||||
  decltype(&::notify_init) notify_init;
 | 
			
		||||
  decltype(&::notify_get_server_caps) notify_get_server_caps;
 | 
			
		||||
  decltype(&::notify_get_server_info) notify_get_server_info;
 | 
			
		||||
  decltype(&::notify_notification_new) notify_notification_new;
 | 
			
		||||
  decltype(&::notify_notification_add_action) notify_notification_add_action;
 | 
			
		||||
  decltype(&::notify_notification_set_image_from_pixbuf)
 | 
			
		||||
      notify_notification_set_image_from_pixbuf;
 | 
			
		||||
  decltype(&::notify_notification_set_timeout) notify_notification_set_timeout;
 | 
			
		||||
  decltype(&::notify_notification_set_hint_string)
 | 
			
		||||
      notify_notification_set_hint_string;
 | 
			
		||||
  decltype(&::notify_notification_show) notify_notification_show;
 | 
			
		||||
  decltype(&::notify_notification_close) notify_notification_close;
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  void CleanUp(bool unload);
 | 
			
		||||
 | 
			
		||||
  void* library_;
 | 
			
		||||
  bool loaded_;
 | 
			
		||||
 | 
			
		||||
  // Disallow copy constructor and assignment operator.
 | 
			
		||||
  LibNotifyLoader(const LibNotifyLoader&);
 | 
			
		||||
  void operator=(const LibNotifyLoader&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif  // ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_LOADER_H_
 | 
			
		||||
| 
						 | 
				
			
			@ -8,8 +8,8 @@
 | 
			
		|||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "atom/browser/notifications/linux/libnotify_loader.h"
 | 
			
		||||
#include "atom/browser/notifications/notification.h"
 | 
			
		||||
#include "library_loaders/libnotify_loader.h"
 | 
			
		||||
#include "ui/base/glib/glib_signal.h"
 | 
			
		||||
 | 
			
		||||
namespace atom {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -334,8 +334,6 @@ filenames = {
 | 
			
		|||
    "atom/browser/net/url_request_fetch_job.h",
 | 
			
		||||
    "atom/browser/net/url_request_stream_job.cc",
 | 
			
		||||
    "atom/browser/net/url_request_stream_job.h",
 | 
			
		||||
    "atom/browser/notifications/linux/libnotify_loader.cc",
 | 
			
		||||
    "atom/browser/notifications/linux/libnotify_loader.h",
 | 
			
		||||
    "atom/browser/notifications/linux/libnotify_notification.cc",
 | 
			
		||||
    "atom/browser/notifications/linux/libnotify_notification.h",
 | 
			
		||||
    "atom/browser/notifications/linux/notification_presenter_linux.cc",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue