From 6e16d7065e36d314e7a8efba48ffa2b21e4663c7 Mon Sep 17 00:00:00 2001
From: "brettw@chromium.org"
 <brettw@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c>
Date: Fri, 16 May 2014 19:33:08 +0000
Subject: [PATCH] Hook up base unit tests and allocator to GN build.

Adds a meta-target "//base/allocator" that forwards to tcmallor or nothing depending on the build configuration.

Write tcmalloc target definition.

Write base unit tests prefs, and some support targets from base.gypi.

Fix a bunch of added files in the base target that were exposed by linking the unit tests.

Removes toolkit_uses_gtk which was removed from the GYP build.

BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/288203003

git-svn-id: http://src.chromium.org/svn/trunk/src/build@271079 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
---
 config/BUILD.gn      |  4 ++++
 config/allocator.gni | 14 ++++++++++++++
 config/ui.gni        |  3 ---
 3 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 config/allocator.gni

diff --git a/config/BUILD.gn b/config/BUILD.gn
index d83a221aa..48a33eda6 100644
--- a/config/BUILD.gn
+++ b/config/BUILD.gn
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/allocator.gni")
 import("//build/config/crypto.gni")
 import("//build/config/features.gni")
 import("//build/config/ui.gni")
@@ -120,6 +121,9 @@ config("feature_flags") {
       defines += [ "USE_XI2_MT=$use_xi2_mt" ]
     }
   }
+  if (use_allocator != "tcmalloc") {
+    defines += [ "NO_TCMALLOC" ]
+  }
 }
 
 # Debug/release ----------------------------------------------------------------
diff --git a/config/allocator.gni b/config/allocator.gni
new file mode 100644
index 000000000..ef10c3dc3
--- /dev/null
+++ b/config/allocator.gni
@@ -0,0 +1,14 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if (is_android || cpu_arch == "mipsel") {
+  _default_allocator = "none"
+} else {
+  _default_allocator = "tcmalloc"
+}
+
+declare_args() {
+  # Memory allocator to use. Set to "none" to use default allocator.
+  use_allocator = _default_allocator
+}
diff --git a/config/ui.gni b/config/ui.gni
index 6577331ef..360e860ef 100644
--- a/config/ui.gni
+++ b/config/ui.gni
@@ -44,9 +44,6 @@ if (is_linux) {
   use_pango = false
 }
 
-# Indicates if the UI toolkit depends on GTK.
-toolkit_uses_gtk = is_linux && !is_chromeos && !use_aura && !use_ozone
-
 # Use GPU accelerated cross process image transport by default on linux builds
 # with the Aura window manager.
 ui_compositor_image_transport = use_aura && is_linux