Skip to content

Commit

Permalink
Add support for Swift warning policies
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumealgis committed Nov 1, 2016
1 parent a3ba5a6 commit 1120a6a
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions warnings2xcconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@

# Those are settings where 'YES' is not the most aggressive value
AGGRESSIVE_DEFAULTS_EXCEPTIONS = {
'GCC_WARN_INHIBIT_ALL_WARNINGS': 'NO'
'GCC_WARN_INHIBIT_ALL_WARNINGS': 'NO',
'SWIFT_SUPPRESS_WARNINGS': 'NO',
}


Expand Down Expand Up @@ -279,6 +280,9 @@ def parse_script_args():
' - strict: hand picked values to make your code safer without '
'being too much of a hassle to fix\n'
' - aggressive: everything \'on\' (you probably don\'t want this)')
parser.add_argument(
'--no-swift', dest='swift', action='store_false',
help='don\'t include Swift-related flags in the output')
parser.add_argument(
'--doc', action='store_true',
help='include documentation about the options in the generated '
Expand All @@ -296,21 +300,29 @@ def parse_script_args():
return args


def clang_llvm_xcspec_path(xcode_path):
XCODE_REL_CLANG_LLVM_XCSPEC_PATH = 'Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/Clang LLVM 1.0.xcspec'
clang_llvm_xcspec_path = path.join(xcode_path,
XCODE_REL_CLANG_LLVM_XCSPEC_PATH)
return clang_llvm_xcspec_path
def xcspec_path(xcode_path, xcplugin, xcspec=None):
if not xcspec:
xcspec = xcplugin

path_template = 'Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/{}.xcplugin/Contents/Resources/{}.xcspec'
rel_path = path_template.format(xcplugin, xcspec)
full_path = path.join(xcode_path, rel_path)

return full_path


def main():
args = parse_script_args()

xcspec_path = clang_llvm_xcspec_path(args.xcode_path)
clang_llvm_xcspec_path = xcspec_path(args.xcode_path, 'Clang LLVM 1.0')
clang_llvm_parser = XSpecParser(clang_llvm_xcspec_path)
options_groups = clang_llvm_parser.parse_options('com.apple.compilers.llvm.clang.1_0.compiler', category_filter=r'^Warning')
options_groups += clang_llvm_parser.parse_options('com.apple.compilers.llvm.clang.1_0.analyzer')

parser = XSpecParser(xcspec_path)
options_groups = parser.parse_options('com.apple.compilers.llvm.clang.1_0.compiler', category_filter=r'^Warning')
options_groups += parser.parse_options('com.apple.compilers.llvm.clang.1_0.analyzer')
if args.swift:
swift_xcspec_path = xcspec_path(args.xcode_path, 'XCLanguageSupport', 'Swift')
swift_parser = XSpecParser(swift_xcspec_path)
options_groups += swift_parser.parse_options('com.apple.xcode.tools.swift.compiler', category_filter=r'^Warning')

import_xcode_defaults_into_options(args.xcode_path, options_groups)

Expand Down

0 comments on commit 1120a6a

Please sign in to comment.