WinNotUnicodePatch( Bam.Core.Settings settings) { if (settings is C.ICommonCompilerSettingsWin winCompiler) { winCompiler.CharacterSet = C.ECharacterSet.NotSet; } }
NotPyDEBUGPatch( Bam.Core.Settings settings) { // need asserts to dissolve to nothing, since they contain expressions which // depende on Py_DEBUG being set var preprocessor = settings as C.ICommonPreprocessorSettings; preprocessor.PreprocessorDefines.Add("NDEBUG"); }
void ISitePolicy.DefineLocalSettings( Settings settings, Module module) { var cxxCompiler = settings as C.ICxxOnlyCompilerSettings; if (null != cxxCompiler) { cxxCompiler.LanguageStandard = C.Cxx.ELanguageStandard.Cxx11; cxxCompiler.StandardLibrary = C.Cxx.EStandardLibrary.libcxx; } var cxxLinker = settings as C.ICxxOnlyLinkerSettings; if (null != cxxLinker) { cxxLinker.StandardLibrary = C.Cxx.EStandardLibrary.libcxx; } }
SuppressC4091( Bam.Core.Settings settings) { // warning suppression only required for VS2015 and above // this is a less common example of a static private patch, so it has no access // to the variables generally available to patches inlined in Init() // so settings.Module is just a Bam.Core.Module, so utility functions from the C package // are provided to get access to properties on the compilable module if (settings is VisualCCommon.ICommonCompilerSettings) { var compilerUsed = C.PatchUtilities.GetCompiler <C.ObjectFile>(settings.Module); if (compilerUsed.IsAtLeast(19)) { var compiler = settings as C.ICommonCompilerSettings; compiler.DisableWarnings.AddUnique("4091"); // C:\Program Files (x86)\Windows Kits\8.1\Include\um\DbgHelp.h(1544): warning C4091: 'typedef ': ignored on left of '' when no variable is declared } } }
CoreBuildPatch( Bam.Core.Settings settings) { var preprocessor = settings as C.ICommonPreprocessorSettings; preprocessor.PreprocessorDefines.Add("Py_BUILD_CORE"); preprocessor.PreprocessorDefines.Add("Py_ENABLE_SHARED"); var cCompiler = settings as C.ICOnlyCompilerSettings; cCompiler.LanguageStandard = C.ELanguageStandard.C99; // some C99 features are now used from 3.6 (https://www.python.org/dev/peps/pep-0007/#c-dialect) if (settings is C.ICommonCompilerSettingsWin winCompiler) { winCompiler.CharacterSet = C.ECharacterSet.NotSet; } if (settings is VisualCCommon.ICommonCompilerSettings visualcCompiler) { visualcCompiler.WarningLevel = VisualCCommon.EWarningLevel.Level4; // VisualC 2015 onwards does not issue C4127 for idiomatic cases such as 1 or true var compilerUsed = (settings.Module is Bam.Core.IModuleGroup) ? (settings.Module as C.CCompilableModuleCollection <C.ObjectFile>).Compiler : (settings.Module as C.ObjectFile).Compiler; if (compilerUsed.Version.AtMost(VisualCCommon.ToolchainVersion.VC2017_15_0)) { var compiler = settings as C.ICommonCompilerSettings; compiler.DisableWarnings.AddUnique("4127"); // Python-3.5.1\Parser\myreadline.c(39) : warning C4127: conditional expression is constant } } if (settings is GccCommon.ICommonCompilerSettings gccCompiler) { gccCompiler.AllWarnings = true; gccCompiler.ExtraWarnings = true; gccCompiler.Pedantic = true; } if (settings is ClangCommon.ICommonCompilerSettings clangCompiler) { clangCompiler.AllWarnings = true; clangCompiler.ExtraWarnings = true; clangCompiler.Pedantic = true; } }
ISitePolicy.DefineLocalSettings( Bam.Core.Settings settings, Bam.Core.Module module) { var vcCompiler = settings as VisualCCommon.ICommonCompilerSettings; if (null != vcCompiler) { vcCompiler.WarningLevel = VisualCCommon.EWarningLevel.Level4; } var mingwCompiler = settings as MingwCommon.ICommonCompilerSettings; if (null != mingwCompiler) { mingwCompiler.AllWarnings = true; mingwCompiler.ExtraWarnings = true; mingwCompiler.Pedantic = true; } var gccCompiler = settings as GccCommon.ICommonCompilerSettings; if (null != gccCompiler) { gccCompiler.AllWarnings = true; gccCompiler.ExtraWarnings = true; gccCompiler.Pedantic = true; } var clangCompiler = settings as ClangCommon.ICommonCompilerSettings; if (null != clangCompiler) { clangCompiler.AllWarnings = true; clangCompiler.ExtraWarnings = true; clangCompiler.Pedantic = true; } }