This commit is contained in:
Heejin Ahn 2018-01-24 08:01:18 -08:00 коммит произвёл Alon Zakai
Родитель d79dd89331
Коммит 1513d7297d
6 изменённых файлов: 42 добавлений и 40 удалений

Просмотреть файл

@ -182,7 +182,8 @@ class EmccOptions(object):
self.separate_asm = False
self.cfi = False
# Specifies the line ending format to use for all generated text files.
# Defaults to using the native EOL on each platform (\r\n on Windows, \n on Linux&OSX)
# Defaults to using the native EOL on each platform (\r\n on Windows, \n on
# Linux & MacOS)
self.output_eol = os.linesep

Просмотреть файл

@ -63,18 +63,18 @@ ADB = ''
# Host OS detection to autolocate browsers and other OS-specific support needs.
WINDOWS = False
LINUX = False
OSX = False
MACOS = False
if os.name == 'nt':
WINDOWS = True
elif platform.system() == 'Linux':
LINUX = True
elif platform.mac_ver()[0] != '':
OSX = True
MACOS = True
import plistlib
# If you are running on an OS that is not any of these, must add explicit support for it.
if not WINDOWS and not LINUX and not OSX:
if not WINDOWS and not LINUX and not MACOS:
raise Exception("Unknown OS!")
import_win32api_modules_warned_once = False
@ -99,7 +99,8 @@ def import_win32api_modules():
# Returns wallclock time in seconds.
def tick():
# Would like to return time.clock() since it's apparently better for precision, but it is broken on OSX 10.10 and Python 2.7.8.
# Would like to return time.clock() since it's apparently better for
# precision, but it is broken on macOS 10.10 and Python 2.7.8.
return time.time()
# Absolute wallclock time in seconds specifying when the previous HTTP stdout message from
@ -627,7 +628,7 @@ def get_cpu_info():
physical_cores = int(check_output(['wmic', 'cpu', 'get', 'NumberOfCores']).split('\n')[1].strip())
logical_cores = int(check_output(['wmic', 'cpu', 'get', 'NumberOfLogicalProcessors']).split('\n')[1].strip())
frequency = int(check_output(['wmic', 'cpu', 'get', 'MaxClockSpeed']).split('\n')[1].strip())
elif OSX:
elif MACOS:
cpu_name = check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).strip()
physical_cores = int(check_output(['sysctl', '-n', 'machdep.cpu.core_count']).strip())
logical_cores = int(check_output(['sysctl', '-n', 'machdep.cpu.thread_count']).strip())
@ -759,7 +760,7 @@ def linux_get_gpu_info():
if not model: model = 'Unknown'
return [{'model': model, 'ram': ram}]
def osx_get_gpu_info():
def macos_get_gpu_info():
gpus = []
try:
info = check_output(['system_profiler', 'SPDisplaysDataType'])
@ -776,7 +777,7 @@ def osx_get_gpu_info():
def get_gpu_info():
if WINDOWS: return win_get_gpu_info()
elif LINUX: return linux_get_gpu_info()
elif OSX: return osx_get_gpu_info()
elif MACOS: return macos_get_gpu_info()
else: return []
def get_executable_version(filename):
@ -787,7 +788,7 @@ def get_executable_version(filename):
ls = info['FileVersionLS']
version = win32api.HIWORD(ms), win32api.LOWORD(ms), win32api.HIWORD(ls), win32api.LOWORD(ls)
return '.'.join(map(str, version))
elif OSX:
elif MACOS:
plistfile = filename[0:filename.find('MacOS')] + 'Info.plist'
info = plistlib.readPlist(plistfile)
# Data in Info.plists is a bit odd, this check combo gives best information on each browser.
@ -810,7 +811,7 @@ def get_executable_version(filename):
def get_browser_build_date(filename):
try:
if OSX:
if MACOS:
plistfile = filename[0:filename.find('MacOS')] + 'Info.plist'
info = plistlib.readPlist(plistfile)
# Data in Info.plists is a bit odd, this check combo gives best information on each browser.
@ -877,7 +878,7 @@ def win_get_file_properties(fname):
def get_computer_model():
try:
if OSX:
if MACOS:
try:
with open(os.path.join(os.getenv("HOME"), '.emrun.hwmodel.cached'), 'r') as f:
model = f.read()
@ -934,7 +935,7 @@ def get_os_version():
except:
pass
return productName[0] + version + bitness
elif OSX:
elif MACOS:
return 'Mac OS ' + platform.mac_ver()[0] + bitness
elif LINUX:
kernel_version = check_output(['uname', '-r']).strip()
@ -959,7 +960,7 @@ def get_system_memory():
return int(sline[1]) * 1024
elif WINDOWS:
return win32api.GlobalMemoryStatusEx()['TotalPhys']
elif OSX:
elif MACOS:
return int(check_output(['sysctl', '-n', 'hw.memsize']).strip())
except:
return -1
@ -1011,7 +1012,7 @@ def win_get_default_browser():
def find_browser(name):
if WINDOWS and name == 'start':
return win_get_default_browser()
if OSX and name == 'open':
if MACOS and name == 'open':
return [name]
if os.path.isfile(os.path.abspath(name)):
@ -1028,7 +1029,7 @@ def find_browser(name):
return [path_lookup]
browser_locations = []
if OSX:
if MACOS:
# Note: by default Firefox beta installs as 'Firefox.app', you must manually rename it to
# FirefoxBeta.app after installation.
browser_locations = [ ('firefox', '/Applications/Firefox.app/Contents/MacOS/firefox'),
@ -1360,7 +1361,7 @@ def run():
options.browser = which('xdg-open')
if not options.browser:
options.browser = 'firefox'
elif OSX:
elif MACOS:
options.browser = 'safari'
if options.list_browsers:
@ -1460,7 +1461,7 @@ def run():
# Safari has a bug that a command line 'Safari http://page.com' does not launch that page,
# but instead launches 'file:///http://page.com'. To remedy this, must use the open -a command
# to run Safari, but unfortunately this will end up spawning Safari process detached from emrun.
if OSX:
if MACOS:
browser = ['open', '-a', 'Safari'] + (browser[1:] if len(browser) > 1 else [])
processname_killed_atexit = 'Safari'

Просмотреть файл

@ -44,9 +44,9 @@ def no_linux(note=''):
return skip_if(f, 'is_linux', note)
return decorated
def no_osx(note=''):
def no_macos(note=''):
def decorated(f):
return skip_if(f, 'is_osx', note)
return skip_if(f, 'is_macos', note)
return decorated
def no_windows(note=''):
@ -81,8 +81,8 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
return 'BINARYEN' in str(self.emcc_args) or self.is_wasm_backend()
def is_linux(self):
return LINUX
def is_osx(self):
return OSX
def is_macos(self):
return MACOS
def is_windows(self):
return WINDOWS
@ -5545,7 +5545,7 @@ return malloc(size);
os.path.join('objs', '.libs', 'libfreetype.a'))
def test_freetype(self):
if self.is_windows(): return self.skip('test_freetype uses a ./configure script to build and therefore currently only runs on Linux and OS X.')
if self.is_windows(): return self.skip('test_freetype uses a ./configure script to build and therefore currently only runs on Linux and macOS.')
assert 'asm2g' in test_modes
if self.run_name == 'asm2g':
Settings.ALIASING_FUNCTION_POINTERS = 1 - Settings.ALIASING_FUNCTION_POINTERS # flip for some more coverage here
@ -5687,7 +5687,7 @@ def process(filename):
@sync
def test_poppler(self):
if self.is_windows(): return self.skip('test_poppler depends on freetype, which uses a ./configure script to build and therefore currently only runs on Linux and OS X.')
if self.is_windows(): return self.skip('test_poppler depends on freetype, which uses a ./configure script to build and therefore currently only runs on Linux and macOS.')
def test():
Building.COMPILER_TEST_OPTS += [

Просмотреть файл

@ -2198,7 +2198,7 @@ int f() {
def test_llvm_nativizer(self):
if WINDOWS: return self.skip('test_llvm_nativizer does not work on Windows: https://github.com/kripken/emscripten/issues/702')
if OSX: return self.skip('test_llvm_nativizer does not work on OS X: https://github.com/kripken/emscripten/issues/709')
if MACOS: return self.skip('test_llvm_nativizer does not work on macOS: https://github.com/kripken/emscripten/issues/709')
try:
Popen(['as', '--version'], stdout=PIPE, stderr=PIPE).communicate()
except:
@ -2367,7 +2367,7 @@ seeked= file.
# run again, should not recrunch!
time.sleep(0.1)
Popen([PYTHON, FILE_PACKAGER, 'test.data', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
if 'linux' in sys.platform: # OS time reporting in other OSes (OS X) seems flaky here
if 'linux' in sys.platform: # OS time reporting in other OSes (macOS) seems flaky here
assert crunch_time == os.stat('ship.crn').st_mtime, 'Crunch is unchanged ' + str([crunch_time, os.stat('ship.crn').st_mtime])
# update dds, so should recrunch
time.sleep(0.1)

Просмотреть файл

@ -15,7 +15,7 @@ def convert_line_endings_in_file(filename, from_eol, to_eol):
# This function checks and prints out the detected line endings in the given file.
# If the file only contains either Windows \r\n line endings or Unix \n line endings, it returns 0.
# Otherwise, in the presence of old OSX or mixed/malformed line endings, a non-zero error code is returned.
# Otherwise, in the presence of old macOS or mixed/malformed line endings, a non-zero error code is returned.
def check_line_endings(filename, expect_only_specific_line_endings=None, print_errors=True, print_info=False):
try:
data = open(filename, 'rb').read()
@ -51,11 +51,11 @@ def check_line_endings(filename, expect_only_specific_line_endings=None, print_e
unix_line_ending_count = data.count(b'\n')
has_unix_line_endings = True
if b'\r' in data:
old_osx_line_ending_example = data[max(0, data.find(b'\r') - 50):min(len(data), data.find(b'\r')+50)].replace(b'\r', b'\\r').replace(b'\n', b'\\n')
old_macos_line_ending_example = data[max(0, data.find(b'\r') - 50):min(len(data), data.find(b'\r')+50)].replace(b'\r', b'\\r').replace(b'\n', b'\\n')
if print_errors:
print('File \'' + filename + '\' contains OLD OSX line endings "\\r"', file=sys.stderr)
print("Content around an OLD OSX line ending location: '" + old_osx_line_ending_example + "'", file=sys.stderr)
return 1 # Return a non-zero process exit code since we don't want to use the old OSX (9.x) line endings anywhere.
print('File \'' + filename + '\' contains OLD macOS line endings "\\r"', file=sys.stderr)
print("Content around an OLD macOS line ending location: '" + old_macos_line_ending_example + "'", file=sys.stderr)
return 1 # Return a non-zero process exit code since we don't want to use the old macOS (9.x) line endings anywhere.
if has_dos_line_endings and has_unix_line_endings:
if print_errors:
print('File \'' + filename + '\' contains both DOS "\\r\\n" and UNIX "\\n" line endings! (' + str(dos_line_ending_count) + ' DOS line endings, ' + str(unix_line_ending_count) + ' UNIX line endings)', file=sys.stderr)

Просмотреть файл

@ -81,7 +81,7 @@ def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
WINDOWS = sys.platform.startswith('win')
OSX = sys.platform == 'darwin'
MACOS = sys.platform == 'darwin'
LINUX = sys.platform.startswith('linux')
# This is a workaround for https://bugs.python.org/issue9400
@ -598,16 +598,16 @@ def build_clang_tool_path(tool):
else:
return os.path.join(LLVM_ROOT, tool)
# Whenever building a native executable for OSX, we must provide the OSX SDK version we want to target.
def osx_find_native_sdk_path():
# Whenever building a native executable for macOS, we must provide the macOS SDK version we want to target.
def macos_find_native_sdk_path():
try:
sdk_root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs'
sdks = os.walk(sdk_root).next()[1]
sdk_path = os.path.join(sdk_root, sdks[0]) # Just pick first one found, we don't care which one we found.
logging.debug('Targeting OSX SDK found at ' + sdk_path)
logging.debug('Targeting macOS SDK found at ' + sdk_path)
return sdk_path
except:
logging.warning('Could not find native OSX SDK path to target!')
logging.warning('Could not find native macOS SDK path to target!')
return None
# These extra args need to be passed to Clang when targeting a native host system executable
@ -616,10 +616,10 @@ def get_clang_native_args():
global CACHED_CLANG_NATIVE_ARGS
if CACHED_CLANG_NATIVE_ARGS is not None: return CACHED_CLANG_NATIVE_ARGS
CACHED_CLANG_NATIVE_ARGS = []
if OSX:
sdk_path = osx_find_native_sdk_path()
if MACOS:
sdk_path = macos_find_native_sdk_path()
if sdk_path:
CACHED_CLANG_NATIVE_ARGS = ['-isysroot', osx_find_native_sdk_path()]
CACHED_CLANG_NATIVE_ARGS = ['-isysroot', macos_find_native_sdk_path()]
elif os.name == 'nt':
CACHED_CLANG_NATIVE_ARGS = ['-DWIN32']
# TODO: If Windows.h et al. are needed, will need to add something like '-isystemC:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Include'.
@ -1939,7 +1939,7 @@ class Building(object):
elif status == 'C':
commons.append(symbol)
elif (not include_internal and status == status.upper()) or \
( include_internal and status in ['W', 't', 'T', 'd', 'D']): # FIXME: using WTD in the previous line fails due to llvm-nm behavior on OS X,
( include_internal and status in ['W', 't', 'T', 'd', 'D']): # FIXME: using WTD in the previous line fails due to llvm-nm behavior on macOS,
# so for now we assume all uppercase are normally defined external symbols
defs.append(symbol)
return ObjectFileInfo(0, None, set(defs), set(undefs), set(commons))
@ -2314,7 +2314,7 @@ class Building(object):
# look for ar signature
elif Building.is_ar(filename):
return True
# on OS X, there is a 20-byte prefix
# on macOS, there is a 20-byte prefix
elif b[0] == 222 and b[1] == 192 and b[2] == 23 and b[3] == 11:
b = bytearray(open(filename, 'rb').read(24))
return b[20] == ord('B') and b[21] == ord('C')