提交 66bb7dcc authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update gyp

上级 ee3d3be4
......@@ -726,6 +726,8 @@ class XcodeSettings(object):
def _AddObjectiveCARCFlags(self, flags):
if self._Test('CLANG_ENABLE_OBJC_ARC', 'YES', default='NO'):
flags.append('-fobjc-arc')
if self._Test('CLANG_ENABLE_OBJC_WEAK', 'YES', default='NO'):
flags.append('-fobjc-weak')
def _AddObjectiveCMissingPropertySynthesisFlags(self, flags):
if self._Test('CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS',
......@@ -1394,8 +1396,6 @@ def XcodeVersion():
global XCODE_VERSION_CACHE
if XCODE_VERSION_CACHE:
return XCODE_VERSION_CACHE
version = ""
build = ""
try:
version_list = GetStdout(['xcodebuild', '-version']).splitlines()
# In some circumstances xcodebuild exits 0 but doesn't return
......@@ -1405,16 +1405,21 @@ def XcodeVersion():
# checking that version.
if len(version_list) < 2:
raise GypError("xcodebuild returned unexpected results")
version = version_list[0].split()[-1] # Last word on first line
build = version_list[-1].split()[-1] # Last word on last line
except GypError: # Xcode not installed so look for XCode Command Line Tools
version = CLTVersion() # macOS Catalina returns 11.0.0.0.xxx or 11.5
if not version:
except:
version = CLTVersion()
if version:
version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
else:
raise GypError("No Xcode or CLT version detected!")
# Be careful to convert "4.2" to "0420" and "11.0.0" to "1100":
version = version.split(".")[:3] # Just major, minor, micro
version[0] = version[0].zfill(2) # Add a leading zero if major is one digit
version = ("".join(version) + "00")[:4] # Limit to exactly four characters
# The CLT has no build information, so we return an empty string.
version_list = [version, '']
version = version_list[0]
build = version_list[-1]
# Be careful to convert "4.2" to "0420":
version = version.split()[-1].replace('.', '')
version = (version + '0' * (3 - len(version))).zfill(4)
if build:
build = build.split()[-1]
XCODE_VERSION_CACHE = (version, build)
return XCODE_VERSION_CACHE
......@@ -1441,12 +1446,6 @@ def CLTVersion():
except:
continue
regex = re.compile('Command Line Tools for Xcode\s+(?P<version>\S+)')
try:
output = GetStdout(['/usr/sbin/softwareupdate', '--history'])
return re.search(regex, output).groupdict()['version']
except (GypError, OSError):
return None
def GetStdout(cmdlist):
"""Returns the content of standard output returned by invoking |cmdlist|.
......
......@@ -21,6 +21,7 @@ if sys.platform == 'darwin':
test.run_gyp('test.gyp', chdir=CHDIR)
test.build('test.gyp', 'arc_enabled', chdir=CHDIR)
test.build('test.gyp', 'weak_enabled', chdir=CHDIR)
test.build('test.gyp', 'arc_disabled', chdir=CHDIR)
test.pass_test()
#if __has_feature(objc_arc)
#if __has_feature(objc_arc) || __has_feature(objc_arc_weak)
#error "C files shouldn't be ARC'd!"
#endif
void c_fun() {}
#if __has_feature(objc_arc)
#if __has_feature(objc_arc) || __has_feature(objc_arc_weak)
#error "C++ files shouldn't be ARC'd!"
#endif
......
#if __has_feature(objc_arc)
#error "ObjC files without CLANG_ENABLE_OBJC_ARC should not be ARC'd!"
#endif
#if !__has_feature(objc_arc_weak)
#error "With CLANG_ENABLE_OBJC_WEAK, weak references should be enabled."
#endif
void m_fun() {}
......@@ -2,4 +2,8 @@
#error "ObjC files without CLANG_ENABLE_OBJC_ARC should not be ARC'd!"
#endif
#if __has_feature(objc_arc_weak)
#error "Without CLANG_ENABLE_OBJC_WEAK, weak references should be disabled."
#endif
void m_fun() {}
......@@ -2,4 +2,8 @@
#error "ObjC files with CLANG_ENABLE_OBJC_ARC should be ARC'd!"
#endif
#if !__has_feature(objc_arc_weak)
#error "Weak references should always be enabled for ARC."
#endif
void m_fun() {}
#if __has_feature(objc_arc)
#error "ObjC++ files without CLANG_ENABLE_OBJC_ARC should not be ARC'd!"
#endif
#if !__has_feature(objc_arc_weak)
#error "With CLANG_ENABLE_OBJC_WEAK, weak references should be enabled."
#endif
void mm_fun() {}
......@@ -2,4 +2,8 @@
#error "ObjC++ files without CLANG_ENABLE_OBJC_ARC should not be ARC'd!"
#endif
#if __has_feature(objc_arc_weak)
#error "Without CLANG_ENABLE_OBJC_WEAK, weak references should be disabled."
#endif
void mm_fun() {}
......@@ -2,4 +2,8 @@
#error "ObjC++ files with CLANG_ENABLE_OBJC_ARC should be ARC'd!"
#endif
#if !__has_feature(objc_arc_weak)
#error "Weak references should always be enabled for ARC."
#endif
void mm_fun() {}
......@@ -18,13 +18,24 @@
'mm-file.mm',
],
'xcode_settings': {
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'MACOSX_DEPLOYMENT_TARGET': '10.6',
'ARCHS': [ 'x86_64' ], # For the non-fragile objc ABI.
'CLANG_ENABLE_OBJC_ARC': 'YES',
},
},
{
'target_name': 'weak_enabled',
'type': 'static_library',
'sources': [
'c-file.c',
'cc-file.cc',
'm-file-arc-weak.m',
'mm-file-arc-weak.mm',
],
'xcode_settings': {
'CLANG_ENABLE_OBJC_WEAK': 'YES',
},
},
{
'target_name': 'arc_disabled',
'type': 'static_library',
......@@ -35,9 +46,6 @@
'mm-file-no-arc.mm',
],
'xcode_settings': {
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'MACOSX_DEPLOYMENT_TARGET': '10.6',
'ARCHS': [ 'x86_64' ], # For the non-fragile objc ABI.
},
},
],
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论