Bug 938289 - part 1 - add automation support for adding DMD environment variables; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Wed, 13 Nov 2013 14:47:41 -0500
changeset 171551 24ad61f6e52404af6184c4f5ee24a9a2204b23ae
parent 171550 852de77cd9f723d156ef77f09596aa2328a167b2
child 171552 0ebda6d823340bfc948dc0b6a90282c6f93bc5aa
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs938289
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 938289 - part 1 - add automation support for adding DMD environment variables; r=jmaher
build/automation.py.in
build/automationutils.py
build/mobile/remoteautomation.py
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -466,34 +466,45 @@ class Automation(object):
       if ext == ".client":
         self.Process([pk12util, "-i", os.path.join(certPath, item), "-w",
                     pwfilePath, "-d", profileDir], 
                     env = env).wait()
 
     os.unlink(pwfilePath)
     return 0
 
-  def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False):
+  def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, dmdPath=None):
     if xrePath == None:
       xrePath = self.DIST_BIN
     if env == None:
       env = dict(os.environ)
 
     ldLibraryPath = os.path.abspath(os.path.join(SCRIPT_DIR, xrePath))
+    dmdLibrary = None
+    preloadEnvVar = None
     if self.UNIXISH or self.IS_MAC:
       envVar = "LD_LIBRARY_PATH"
+      preloadEnvVar = "LD_PRELOAD"
       if self.IS_MAC:
         envVar = "DYLD_LIBRARY_PATH"
+        dmdLibrary = "libdmd.dylib"
       else: # unixish
         env['MOZILLA_FIVE_HOME'] = xrePath
+        dmdLibrary = "libdmd.so"
       if envVar in env:
         ldLibraryPath = ldLibraryPath + ":" + env[envVar]
       env[envVar] = ldLibraryPath
     elif self.IS_WIN32:
       env["PATH"] = env["PATH"] + ";" + str(ldLibraryPath)
+      dmdLibrary = "dmd.dll"
+      preloadEnvVar = "MOZ_REPLACE_MALLOC_LIB"
+
+    if dmdPath and dmdLibrary and preloadEnvVar:
+      env['DMD'] = '1'
+      env[preloadEnvVar] = os.path.join(dmdPath, dmdLibrary)
 
     if crashreporter and not debugger:
       env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
       env['MOZ_CRASHREPORTER'] = '1'
     else:
       env['MOZ_CRASHREPORTER_DISABLE'] = '1'
 
     env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -395,39 +395,51 @@ def parseKeyValue(strings, separator='='
 
 def systemMemory():
   """
   Returns total system memory in kilobytes.
   Works only on unix-like platforms where `free` is in the path.
   """
   return int(os.popen("free").readlines()[1].split()[1])
 
-def environment(xrePath, env=None, crashreporter=True, debugger=False):
+def environment(xrePath, env=None, crashreporter=True, debugger=False, dmdPath=None):
   """populate OS environment variables for mochitest"""
 
   env = os.environ.copy() if env is None else env
 
   assert os.path.isabs(xrePath)
 
   ldLibraryPath = xrePath
 
   envVar = None
+  dmdLibrary = None
+  preloadEnvVar = None
   if mozinfo.isUnix:
     envVar = "LD_LIBRARY_PATH"
     env['MOZILLA_FIVE_HOME'] = xrePath
+    dmdLibrary = "libdmd.so"
+    preloadEnvVar = "LD_PRELOAD"
   elif mozinfo.isMac:
     envVar = "DYLD_LIBRARY_PATH"
+    dmdLibrary = "libdmd.dylib"
+    preloadEnvVar = "DYLD_INSERT_LIBRARIES"
   elif mozinfo.isWin:
     envVar = "PATH"
+    dmdLibrary = "dmd.dll"
+    preloadEnvVar = "MOZ_REPLACE_MALLOC_LIB"
   if envVar:
     envValue = ((env.get(envVar), str(ldLibraryPath))
                 if mozinfo.isWin
-                else (ldLibraryPath, env.get(envVar)))
+                else (ldLibraryPath, dmdPath, env.get(envVar)))
     env[envVar] = os.path.pathsep.join([path for path in envValue if path])
 
+  if dmdPath and dmdLibrary and preloadEnvVar:
+    env['DMD'] = '1'
+    env[preloadEnvVar] = os.path.join(dmdPath, dmdLibrary)
+
   # crashreporter
   env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
   env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1'
   env['NS_TRACE_MALLOC_DISABLE_STACKS'] = '1'
 
   if crashreporter and not debugger:
     env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
     env['MOZ_CRASHREPORTER'] = '1'
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -43,22 +43,26 @@ class RemoteAutomation(Automation):
 
     def setProduct(self, product):
         self._product = product
 
     def setRemoteLog(self, logfile):
         self._remoteLog = logfile
 
     # Set up what we need for the remote environment
-    def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False):
+    def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, dmdPath=None):
         # Because we are running remote, we don't want to mimic the local env
         # so no copying of os.environ
         if env is None:
             env = {}
 
+        if dmdPath:
+            env['DMD'] = '1'
+            env['MOZ_REPLACE_MALLOC_LIB'] = os.path.join(dmdPath, 'libdmd.so')
+
         # Except for the mochitest results table hiding option, which isn't
         # passed to runtestsremote.py as an actual option, but through the
         # MOZ_HIDE_RESULTS_TABLE environment variable.
         if 'MOZ_HIDE_RESULTS_TABLE' in os.environ:
             env['MOZ_HIDE_RESULTS_TABLE'] = os.environ['MOZ_HIDE_RESULTS_TABLE']
 
         if crashreporter and not debugger:
             env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'