Bug 893976 - Avoid importing buildconfig globally from mozpack.executables. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 30 Jul 2013 08:57:28 +0900
changeset 152759 03f984a3bd2a4d07ce5751c78fceabaf9008e58c
parent 152758 fb60c9b4b74f8b689bfedec319f46ec93c5c8a89
child 152760 9251bba8a9b2d99137551659c214ac17b5dee1cc
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs893976
milestone25.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 893976 - Avoid importing buildconfig globally from mozpack.executables. r=gps
python/mozbuild/mozpack/executables.py
--- a/python/mozbuild/mozpack/executables.py
+++ b/python/mozbuild/mozpack/executables.py
@@ -1,18 +1,14 @@
 # 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/.
 
 import os
 import struct
-from buildconfig import (
-    substs,
-    topobjdir,
-)
 import subprocess
 from mozpack.errors import errors
 
 MACHO_SIGNATURES = [
     0xfeedface,  # mach-o 32-bits big endian
     0xcefaedfe,  # mach-o 32-bits little endian
     0xfeedfacf,  # mach-o 64-bits big endian
     0xcffaedfe,  # mach-o 64-bits little endian
@@ -66,55 +62,60 @@ def is_executable(path):
         - the file signature on OS/X and ELF systems (GNU/Linux, Android, BSD,
           Solaris)
 
     As this function is intended for use to choose between the ExecutableFile
     and File classes in FileFinder, and choosing ExecutableFile only matters
     on OS/2, OS/X, ELF and WINNT (in GCC build) systems, we don't bother
     detecting other kind of executables.
     '''
+    from buildconfig import substs
     if not os.path.exists(path):
         return False
 
     if substs['OS_ARCH'] == 'OS2' or substs['OS_ARCH'] == 'WINNT':
         return path.lower().endswith((substs['DLL_SUFFIX'],
                                       substs['BIN_SUFFIX']))
 
     return get_type(path) != UNKNOWN
 
 
 def may_strip(path):
     '''
     Return whether strip() should be called
     '''
+    from buildconfig import substs
     return not substs['PKG_SKIP_STRIP']
 
 
 def strip(path):
     '''
     Execute the STRIP command with STRIP_FLAGS on the given path.
     '''
+    from buildconfig import substs
     strip = substs['STRIP']
     flags = substs['STRIP_FLAGS'].split() if 'STRIP_FLAGS' in substs else []
     cmd = [strip] + flags + [path]
     if subprocess.call(cmd) != 0:
         errors.fatal('Error executing ' + ' '.join(cmd))
 
 
 def may_elfhack(path):
     '''
     Return whether elfhack() should be called
     '''
     # elfhack only supports libraries. We should check the ELF header for
     # the right flag, but checking the file extension works too.
+    from buildconfig import substs
     return 'USE_ELF_HACK' in substs and substs['USE_ELF_HACK'] and \
            path.endswith(substs['DLL_SUFFIX'])
 
 
 def elfhack(path):
     '''
     Execute the elfhack command on the given path.
     '''
+    from buildconfig import topobjdir
     cmd = [os.path.join(topobjdir, 'build/unix/elfhack/elfhack'), path]
     if 'ELF_HACK_FLAGS' in os.environ:
         cmd[1:0] = os.environ['ELF_HACK_FLAGS'].split()
     if subprocess.call(cmd) != 0:
         errors.fatal('Error executing ' + ' '.join(cmd))