mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1291944 - Verify makensis binary is 32-bits; r=glandium
This required implementing a utility function to resolve the binary type. I used GetBinaryTypeW via ctypes because this seems the fastest. I arbitrarily limited the function to testing 32-bit and 64-bit Windows executables because hopefully those are the only executables we'll ever encounter. We can expand the binary detection later, if needed. This includes support for running on non-Windows platforms. MozReview-Commit-ID: CYwyDWQrePc --HG-- extra : rebase_source : 8fd7ca7f253d9e9e18d64784652a5ff934ad2272
This commit is contained in:
parent
3dffde2be1
commit
2562138ede
@ -62,6 +62,32 @@ def normsep(path):
|
||||
return mozpath.normsep(path)
|
||||
|
||||
|
||||
@imports('ctypes')
|
||||
@imports(_from='ctypes', _import='wintypes')
|
||||
@imports(_from='mozbuild.configure.constants', _import='WindowsBinaryType')
|
||||
def windows_binary_type(path):
|
||||
"""Obtain the type of a binary on Windows.
|
||||
|
||||
Returns WindowsBinaryType constant.
|
||||
"""
|
||||
GetBinaryTypeW = ctypes.windll.kernel32.GetBinaryTypeW
|
||||
GetBinaryTypeW.argtypes = [wintypes.LPWSTR, wintypes.POINTER(wintypes.DWORD)]
|
||||
GetBinaryTypeW.restype = wintypes.BOOL
|
||||
|
||||
bin_type = wintypes.DWORD()
|
||||
res = GetBinaryTypeW(path, ctypes.byref(bin_type))
|
||||
if not res:
|
||||
die('could not obtain binary type of %s' % path)
|
||||
|
||||
if bin_type.value == 0:
|
||||
return WindowsBinaryType('win32')
|
||||
elif bin_type.value == 6:
|
||||
return WindowsBinaryType('win64')
|
||||
# If we see another binary type, something is likely horribly wrong.
|
||||
else:
|
||||
die('unsupported binary type on %s: %s' % (path, bin_type))
|
||||
|
||||
|
||||
@imports('ctypes')
|
||||
@imports(_from='ctypes', _import='wintypes')
|
||||
def get_GetShortPathNameW():
|
||||
|
@ -295,6 +295,16 @@ def nsis_version(nsis):
|
||||
|
||||
return ver
|
||||
|
||||
# And that makensis is 32-bit.
|
||||
@depends_if(nsis)
|
||||
@checking('for 32-bit NSIS')
|
||||
def nsis_binary_type(nsis):
|
||||
bin_type = windows_binary_type(nsis)
|
||||
if bin_type != 'win32':
|
||||
raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
|
||||
|
||||
return 'yes'
|
||||
|
||||
|
||||
# Fallthrough to autoconf-based configure
|
||||
include('build/moz.configure/old.configure')
|
||||
|
@ -63,6 +63,11 @@ Endianness = EnumString.subclass(
|
||||
'little',
|
||||
)
|
||||
|
||||
WindowsBinaryType = EnumString.subclass(
|
||||
'win32',
|
||||
'win64',
|
||||
)
|
||||
|
||||
# The order of those checks matter
|
||||
CPU_preprocessor_checks = OrderedDict((
|
||||
('x86', '__i386__ || _M_IX86'),
|
||||
|
Loading…
Reference in New Issue
Block a user