Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r?build draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 15 Nov 2017 14:21:15 +0900
changeset 698011 a3fc3b7b0018fe2c7a91e578ab0ff6a45ae6e2ef
parent 698010 4c30b099087df17ac4610ab3a319cc20a09173a1
child 740269 a74d2b0afcf7e746e9c74e562577544af2263531
push id89172
push userbmo:mh+mozilla@glandium.org
push dateWed, 15 Nov 2017 05:25:33 +0000
reviewersbuild
bugs1417309
milestone59.0a1
Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r?build The option allows to iterate on the allocator code without requiring a complete setup to build Firefox.
build/moz.configure/memory.configure
memory/app.mozbuild
memory/build/moz.build
memory/moz.build
memory/moz.configure
moz.build
--- a/build/moz.configure/memory.configure
+++ b/build/moz.configure/memory.configure
@@ -59,15 +59,17 @@ option('--enable-replace-malloc',
 
 @depends('--enable-replace-malloc', jemalloc, milestone, build_project)
 def replace_malloc(value, jemalloc, milestone, build_project):
     # Enable on central for the debugging opportunities it adds.
     if value and not jemalloc:
         die('--enable-replace-malloc requires --enable-jemalloc')
     if value.origin != 'default':
         return bool(value) or None
+    if build_project == 'memory':
+        return True
     if milestone.is_nightly and jemalloc and build_project != 'js':
         return True
 
 
 set_config('MOZ_REPLACE_MALLOC', replace_malloc)
 set_define('MOZ_REPLACE_MALLOC', replace_malloc)
 add_old_configure_assignment('MOZ_REPLACE_MALLOC', replace_malloc)
new file mode 100644
--- /dev/null
+++ b/memory/app.mozbuild
@@ -0,0 +1,15 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Indirectly necessary for chromium's lock.h, included from LogAlloc.cpp
+EXPORTS.mozilla += [
+    '/mozglue/misc/Printf.h',
+    '/xpcom/base/Logging.h',
+]
+
+DIRS += [
+    '/memory',
+]
--- a/memory/build/moz.build
+++ b/memory/build/moz.build
@@ -38,14 +38,15 @@ if CONFIG['OS_TARGET'] == 'Darwin' and (
 
 Library('memory')
 
 if CONFIG['OS_TARGET'] == 'Android' and CONFIG['CC_TYPE'] == 'clang':
     CXXFLAGS += [
         '-Wno-tautological-pointer-compare',
     ]
 
-FINAL_LIBRARY = 'mozglue'
+if CONFIG['MOZ_BUILD_APP'] != 'memory':
+    FINAL_LIBRARY = 'mozglue'
 
 if CONFIG['_MSC_VER']:
     CXXFLAGS += ['-wd4273'] # inconsistent dll linkage (bug 558163)
 
 DisableStlWrapping()
--- a/memory/moz.build
+++ b/memory/moz.build
@@ -4,20 +4,25 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "Memory Allocator")
 
 DIRS += [
     'build',
-    'mozalloc',
     'fallible',
 ]
 
+# For now, don't build mozalloc when building with --enable-project=memory
+if CONFIG['MOZ_BUILD_APP'] != 'memory':
+    DIRS += [
+        'mozalloc',
+    ]
+
 if CONFIG['MOZ_WIDGET_TOOLKIT']:
     DIRS += ['volatile']
 
 # NB: gtest dir is included in toolkit/toolkit.build due to its dependency
 # on libxul.
 
 if CONFIG['MOZ_REPLACE_MALLOC']:
     DIRS += ['replace']
new file mode 100644
--- /dev/null
+++ b/memory/moz.configure
@@ -0,0 +1,7 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+imply_option('--enable-jemalloc', True)
--- a/moz.build
+++ b/moz.build
@@ -78,17 +78,17 @@ if CONFIG['ENABLE_CLANG_PLUGIN']:
 DIRS += [
     'config',
     'python',
     'taskcluster',
     'testing/mozbase',
     'third_party/python',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] or not CONFIG['MOZ_BUILD_APP']:
+if not CONFIG['JS_STANDALONE'] or not CONFIG['MOZ_BUILD_APP']:
     CONFIGURE_DEFINE_FILES += [
         'mozilla-config.h',
     ]
     EXPORTS += [
         '!buildid.h',
         '!mozilla-config.h',
         '!source-repo.h',
     ]