Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Created May 14, 2015 18:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpunkass/02bdfb61f53a4325b2de to your computer and use it in GitHub Desktop.
Save danielpunkass/02bdfb61f53a4325b2de to your computer and use it in GitHub Desktop.
Build Setting Policy
#!/usr/bin/python
# Hard-code the build settings that we feel strongly should
# only be defined in a centralized location (.xcconfig files).
# These can also serve then to (at some point) confirm that the
# values are indeed being defined by the .xcconfig files
def forbiddenBuildSettingKeys():
return ["CLANG_CXX_LANGUAGE_STANDARD",
"CLANG_CXX_LIBRARY",
"CLANG_ENABLE_MODULES",
"CLANG_MODULES_AUTOLINK",
"CLANG_WARN_BOOL_CONVERSION",
"CLANG_WARN_CONSTANT_CONVERSION",
"CLANG_WARN_DIRECT_OBJC_ISA_USAGE",
"CLANG_WARN_EMPTY_BODY",
"CLANG_WARN_ENUM_CONVERSION",
"CLANG_WARN_INT_CONVERSION",
"CLANG_WARN_OBJC_ROOT_CLASS",
"CLANG_WARN_UNREACHABLE_CODE",
"CLANG_WARN__DUPLICATE_METHOD_MATCH",
"COMBINE_HIDPI_IMAGES",
"COPY_PHASE_STRIP",
"COPY_PHASE_STRIP",
"GCC_VERSION",
"GCC_C_LANGUAGE_STANDARD",
"GCC_DYNAMIC_NO_PIC",
"GCC_ENABLE_OBJC_EXCEPTIONS",
"GCC_GENERATE_DEBUGGING_SYMBOLS",
"GCC_GENERATE_DEBUGGING_SYMBOLS",
"GCC_MODEL_TUNING",
"GCC_OPTIMIZATION_LEVEL",
"GCC_PRECOMPILE_PREFIX_HEADER",
"GCC_WARN_64_TO_32_BIT_CONVERSION",
"GCC_WARN_ABOUT_RETURN_TYPE",
"GCC_WARN_UNINITIALIZED_AUTOS",
"GCC_WARN_TYPECHECK_CALLS_TO_PRINTF",
"GCC_WARN_UNKNOWN_PRAGMAS",
"GCC_WARN_UNUSED_LABEL",
"GCC_WARN_CHECK_SWITCH_STATEMENTS",
"GCC_WARN_UNUSED_PARAMETER",
"GCC_WARN_SIGN_COMPARE",
"GCC_WARN_UNUSED_VALUE",
"GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS",
"GCC_WARN_UNDECLARED_SELECTOR",
"GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS", # not sure this is even used any more by clang
"GCC_WARN_ABOUT_GLOBAL_CONSTRUCTORS", # same
"GCC_USE_GCC3_PFE_SUPPORT", # same
"GCC_TREAT_WARNINGS_AS_ERRORS",
"GCC_WARN_MISSING_PARENTHESES",
"GCC_WARN_SHADOW",
"GCC_WARN_SIGN_COMPARE"
"GCC_WARN_UNUSED_PARAMETER",
"GCC_WARN_ABOUT_MISSING_NEWLINE",
"MACOSX_DEPLOYMENT_TARGET",
"ENABLE_STRICT_OBJC_MSGSEND",
"GCC_WARN_UNUSED_VARIABLE",
"ZERO_LINK",
"CODE_SIGN_IDENTITY",
"CODE_SIGN_IDENTITY[sdk=iphoneos*]",
"CODE_SIGN_IDENTITY[sdk=macosx*]",
"MTL_ENABLE_DEBUG_INFO", # Should be enabled only if we ever have Metal-specific targets
"SDKROOT",
"SKIP_INSTALL",
"ARCHS",
"CLANG_ENABLE_OBJC_ARC",
"ALWAYS_SEARCH_USER_PATHS",
"DEFINES_MODULE", # Should be imposed by the framework-flavored build config
"GCC_WARN_UNUSED_FUNCTION",
"GCC_INCREASE_PRECOMPILED_HEADER_SHARING",
"GCC_ALTIVEC_EXTENSIONS", # No longer pertinent to i386/x86_64
"DEBUG_INFORMATION_FORMAT",
"GCC_WARN_ABOUT_MISSING_PROTOTYPES",
"GCC_FAST_OBJC_DISPATCH", # Only pertinent to PPC builds
"ENABLE_NS_ASSERTIONS",
"SUPPORTED_PLATFORMS", # Should impose this through xcconfig as/if needed
"IPHONEOS_DEPLOYMENT_TARGET",
"VERSIONING_SYSTEM", # We don't use apple-generic, so zap targets that specify it
"VERSION_INFO_PREFIX",
"VALIDATE_PRODUCT",
"GCC_SYMBOLS_PRIVATE_EXTERN", # Should be managed at xcconfig level unless we get on a kick of ratcheting down exported symbols
"KEEP_PRIVATE_EXTERNS",
"DYLIB_INSTALL_NAME_BASE", # Our only uses of this were redundant with INSTALL_PATH default
"ONLY_ACTIVE_ARCH",
"DEPLOYMENT_POSTPROCESSING",
"IBC_ERRORS",
"WARNING_CFLAGS",
"OTHER_REZFLAGS",
"OTHER_LDFLAGS[arch=ppc]", # We shouldn't any longer have ppc-specific settings
"GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS",
"PREBINDING",
"PRINCIPAL_CLASS",
"GCC_ENABLE_FIX_AND_CONTINUE",
"STRIP_STYLE", # Seems irrelevant when using separate symbols file
"PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR",
"GCC_THUMB_SUPPORT",
"USER_HEADER_SEARCH_PATHS", # Don't think we have legitimate reasons for this style of import (plain quotes style for foreign, non-library style headers)
"INFOPLIST_EXPAND_BUILD_SETTINGS", # On by default anyway
"GCC_WARN_FOUR_CHARACTER_CONSTANTS",
"GCC_ENABLE_TRIGRAPHS",
"LIBRARY_STYLE", # Think this is ignored in favor of MACH_O_TYPE
"DEBUGGING_SYMBOLS", # Also obsolete
"RS_TARGET_OTHER_CFLAGS", # SHOULD ONLY BE DEFINED IN xcconfig!
]
# Whitelisted build settings make eminent sense at the project or target level. However,
# we should review this from time to time and/or consider changing our approach such that
# even app-specific settings are all specified in .xcconfig files that in turn import
# from the standard ones
def whitelistedBuildSettingKeys():
return ["APPLICATION_VERSION",
"FRAMEWORK_SEARCH_PATHS",
"GCC_PREFIX_HEADER",
"INFOPLIST_FILE",
"PRODUCT_NAME",
"WRAPPER_EXTENSION", # Until and unless we decide common bundles deserve own xcconfig
"CODE_SIGN_ENTITLEMENTS",
"PROVISIONING_PROFILE",
"PROVISIONING_PROFILE[sdk=iphoneos*]",
"DYLIB_COMPATIBILITY_VERSION",
"DYLIB_CURRENT_VERSION",
"TARGETED_DEVICE_FAMILY",
"CURRENT_PROJECT_VERSION", # We don't actively use these version values but they are indeed target-specific and could be adopted at some point
"FRAMEWORK_VERSION",
"GCC_PFE_FILE_C_DIALECTS", # Allowed, though ideally should be removed if it defines our default from .xcconfig, which is just objective-c
"GCC_PREPROCESSOR_DEFINITIONS", # Currently mostly used to -DDEBUG=1 ... should .xcconfig all that
"ASSETCATALOG_COMPILER_APPICON_NAME",
"TEST_HOST", # legitimate for injected test targets
"BUNDLE_LOADER", # same
]
# Semantically different from whitelist because they are possibly worthy of review and
# effort to eliminate, but shouldn't be nagged about or automatically removed.
# WOULD BE NICE to also support a mechanism for confirming that certain keys only have
# values that meet certain criteria, are not redundant with default, etc.
#
# Recommended to stub this out when first examining a project for linting, to
# evaluate afresh which of these are actually being used.
def greylistedBuildSettingKeys():
return ["FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1",
"INSTALL_PATH", # Allowed for e.g. specific bundle types - move to xcconfig? Should generally be @rpath!
"OTHER_LDFLAGS", # Often just specifies e.g. -framework Foundation -framework Cocoa, should ideally detect and delete bogus lines that are redundant with built-in framework linkage rules - ACTUALLY is this even still consulted by clang?
"OTHER_CFLAGS", # Very questionable but not quite ready to wholesale zap it yet. Should at least zap cases where a target is redundantly specifying -DDEBUG when it would be inherited from debug xcconfig. But for example I think Mac App Store variants rely upon this to set -DRS_TARGET_MAC_APP_STORE=1 and sandboxed apps similarly. So some overriding, for now, is appropriate
"LD_RUNPATH_SEARCH_PATHS", # There are only a few typical options here but e.g. RSScriptRunner uses a weird self-relative version currently ... look into whether this is bogus and can be replaced with @rpath standardized stuff
"LIBRARY_SEARCH_PATHS", # Typically these shouldn't need to be expanded upon
"APPLICATION_EXTENSION_API_ONLY", # Generally should be on by default but e.g. RSTestingKit needs to turn it off to link with XCTest without warning
"HEADER_SEARCH_PATHS", # Used e.g. by RSWebClientCore to access libxml2 headers at build time
"SECTORDER_FLAGS", # Don't think any of our targets have a good reason to use these
"OTHER_LIBTOOL_FLAGS",
"EXECUTABLE_EXTENSION", # Still used by some .o static library targets but why do we even still have those?
"MACH_O_TYPE", # Also still declared on some static library targets
"PUBLIC_HEADERS_FOLDER_PATH", # Shouldn't be used often, but e.g. the dependent CrashReporter framework underlying RSCrashReporter still does use it
"OTHER_LDFLAGS[arch=i386]", # We shouldn't any longer have i386-specific settings, see if they are really necessary?
"OTHER_CODE_SIGN_FLAGS", # Used to e.g. add custom designated requirement text
"SWIFT_INSTALL_OBJC_HEADER", # Swift build settings should be formalized as part of standard .xcconfig files but for now we are not really using swift except a tiny bit in Moto.app
"SWIFT_OPTIMIZATION_LEVEL",
"SWIFT_OBJC_BRIDGING_HEADER",
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment