From a0dab7d185393d3698c7305cd39429e360ca1a37 Mon Sep 17 00:00:00 2001
From: Julien Lepiller
Date: Sun, 5 Mar 2017 09:01:58 +0100
Subject: [PATCH 1/3] gnu: Add google-gn.
* gnu/packages/google.scm: New file.
* gnu/packages/patches/google-gn-remove-third-party.patch: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES, dist_patch_DATA): Add them.
---
gnu/local.mk | 2 +
gnu/packages/google.scm | 83 ++++++++++++++++++++++
.../patches/google-gn-remove-third-party.patch | 76 ++++++++++++++++++++
3 files changed, 161 insertions(+)
create mode 100644 gnu/packages/google.scm
create mode 100644 gnu/packages/patches/google-gn-remove-third-party.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index c88892df5..3e5e5f804 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -165,6 +165,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/gnu-pw-mgr.scm \
%D%/packages/gobby.scm \
%D%/packages/golang.scm \
+ %D%/packages/google.scm \
%D%/packages/gperf.scm \
%D%/packages/gprolog.scm \
%D%/packages/gps.scm \
@@ -599,6 +600,7 @@ dist_patch_DATA = \
%D%/packages/patches/gobject-introspection-absolute-shlib-path.patch \
%D%/packages/patches/gobject-introspection-cc.patch \
%D%/packages/patches/gobject-introspection-girepository.patch \
+ %D%/packages/patches/google-gn-remove-third-party.patch \
%D%/packages/patches/grep-timing-sensitive-test.patch \
%D%/packages/patches/grub-CVE-2015-8370.patch \
%D%/packages/patches/grub-gets-undeclared.patch \
diff --git a/gnu/packages/google.scm b/gnu/packages/google.scm
new file mode 100644
index 000000000..6bc75d000
--- /dev/null
+++ b/gnu/packages/google.scm
@@ -0,0 +1,83 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Julien Lepiller
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see .
+
+(define-module (gnu packages google)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages gnuzilla)
+ #:use-module (gnu packages icu4c)
+ #:use-module (gnu packages libevent)
+ #:use-module (gnu packages python)
+ #:use-module (gnu packages ninja)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #:use-module (guix git-download)
+ #:use-module (guix utils)
+ #:use-module (guix build-system gnu)
+ #:use-module (srfi srfi-1))
+
+(define-public google-gn
+ (package
+ (name "google-gn")
+ (version "56.0.2924.87")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://commondatastorage.googleapis.com/"
+ "chromium-browser-official/chromium-" version ".tar.xz"))
+ (sha256
+ (base32
+ "1q2kg85pd6lv036w7lsss5mhiiva9rx4f0410sbn9bnazhghib4s"))
+ (patches (search-patches "google-gn-remove-third-party.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ (delete-file-recursively "base/third_party/libevent")))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'build 'fix-include
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((libevent (assoc-ref inputs "libevent"))
+ (event-h (string-append libevent "/include/event.h")))
+ (substitute* "base/message_loop/message_pump_libevent.cc"
+ (("base/third_party/libevent/event.h") event-h)))))
+ (replace 'build
+ (lambda* (#:key outputs #:allow-other-keys)
+ (chdir "tools/gn")
+ (setenv "CC" (which "gcc"))
+ (zero? (system* "python" "bootstrap/bootstrap.py" "-s"))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
+ (mkdir-p bin)
+ (copy-file "../../out/Release/gn" (string-append bin "/gn"))))))))
+ (native-inputs
+ `(("python" ,python-2)
+ ("ninja" ,ninja)))
+ (inputs
+ `(("libevent" ,libevent)
+ ("icu" ,icu4c)
+ ("nspr" ,nspr)))
+ (home-page "https://chromium.googlesource.com/chromium/buildtools.git")
+ (synopsis "Google gn")
+ (description "Google gn.")
+ (license license:bsd-3)))
diff --git a/gnu/packages/patches/google-gn-remove-third-party.patch b/gnu/packages/patches/google-gn-remove-third-party.patch
new file mode 100644
index 000000000..742583861
--- /dev/null
+++ b/gnu/packages/patches/google-gn-remove-third-party.patch
@@ -0,0 +1,76 @@
+From 36f44a39630a329b79432836ec6aecb8ab54a6e5 Mon Sep 17 00:00:00 2001
+From: Julien Lepiller
+Date: Tue, 28 Feb 2017 13:39:58 +0100
+Subject: [PATCH] remove third party
+
+This patch removes references to the bundled libevent from the gn build
+script and allows usage of the system libevent.
+
+---
+ tools/gn/bootstrap/bootstrap.py | 34 +---------------------------------
+ 1 file changed, 1 insertion(+), 33 deletions(-)
+
+diff --git a/tools/gn/bootstrap/bootstrap.py b/tools/gn/bootstrap/bootstrap.py
+index 90adca2..0c790a2 100755
+--- a/tools/gn/bootstrap/bootstrap.py
++++ b/tools/gn/bootstrap/bootstrap.py
+@@ -541,29 +541,9 @@ def write_gn_ninja(path, root_gen_dir, options):
+ 'base/time/time_posix.cc',
+ 'base/trace_event/heap_profiler_allocation_register_posix.cc',
+ ])
+- static_libraries['libevent'] = {
+- 'sources': [
+- 'base/third_party/libevent/buffer.c',
+- 'base/third_party/libevent/evbuffer.c',
+- 'base/third_party/libevent/evdns.c',
+- 'base/third_party/libevent/event.c',
+- 'base/third_party/libevent/event_tagging.c',
+- 'base/third_party/libevent/evrpc.c',
+- 'base/third_party/libevent/evutil.c',
+- 'base/third_party/libevent/http.c',
+- 'base/third_party/libevent/log.c',
+- 'base/third_party/libevent/poll.c',
+- 'base/third_party/libevent/select.c',
+- 'base/third_party/libevent/signal.c',
+- 'base/third_party/libevent/strlcpy.c',
+- ],
+- 'tool': 'cc',
+- 'include_dirs': [],
+- 'cflags': cflags + ['-DHAVE_CONFIG_H'],
+- }
+
+ if is_linux:
+- libs.extend(['-lrt', '-latomic'])
++ libs.extend(['-lrt', '-latomic', '-levent'])
+ ldflags.extend(['-pthread'])
+
+ static_libraries['xdg_user_dirs'] = {
+@@ -587,12 +567,6 @@ def write_gn_ninja(path, root_gen_dir, options):
+ 'base/threading/platform_thread_linux.cc',
+ 'base/trace_event/malloc_dump_provider.cc',
+ ])
+- static_libraries['libevent']['include_dirs'].extend([
+- os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'linux')
+- ])
+- static_libraries['libevent']['sources'].extend([
+- 'base/third_party/libevent/epoll.c',
+- ])
+
+
+ if is_mac:
+@@ -622,12 +596,6 @@ def write_gn_ninja(path, root_gen_dir, options):
+ 'base/threading/platform_thread_mac.mm',
+ 'base/trace_event/malloc_dump_provider.cc',
+ ])
+- static_libraries['libevent']['include_dirs'].extend([
+- os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'mac')
+- ])
+- static_libraries['libevent']['sources'].extend([
+- 'base/third_party/libevent/kqueue.c',
+- ])
+
+ libs.extend([
+ '-framework', 'AppKit',
+--
+2.7.4
+
--
2.12.0