protected abstract bool CompileCore( CompilerOutputType outputType, SupportedArchitecture architecture, IEnumerable <string> libraries, IEnumerable <string> sourceFilePaths, string targetFilePath, CompilerOption options, IDictionary <string, string> defineConstants);
public CompilerSettings( string compilerName, SupportedCompiler compilerType, string compilerPath, SupportedArchitecture debuggeeArchitecture, IDictionary <string, string> compilerProperties) { this.CompilerName = compilerName; this.CompilerType = compilerType; this.CompilerPath = compilerPath; this.DebuggeeArchitecture = debuggeeArchitecture; this.Properties = compilerProperties ?? new Dictionary <string, string>(StringComparer.Ordinal); }
internal TestSettings( SupportedArchitecture debuggeeArchitecture, string compilerName, SupportedCompiler compilerType, string compilerPath, IDictionary <string, string> compilerProperties, string debuggerName, SupportedDebugger debuggerType, string debuggerPath, string debuggerAdapterPath, string miMode, IDictionary <string, string> debuggerProperties) { this.CompilerSettings = new CompilerSettings(compilerName, compilerType, compilerPath, debuggeeArchitecture, compilerProperties); this.DebuggerSettings = new DebuggerSettings(debuggerName, debuggerType, debuggerPath, debuggerAdapterPath, miMode, debuggeeArchitecture, debuggerProperties); }
public static string ToArchitectureString(this SupportedArchitecture architecture) { switch (architecture) { case SupportedArchitecture.x86: return("x86"); case SupportedArchitecture.x64: return("x64"); case SupportedArchitecture.arm: return("arm"); default: throw new ArgumentOutOfRangeException(nameof(architecture)); } }
public DebuggerSettings( string debuggerName, SupportedDebugger debuggerType, string debuggerPath, string debuggerAdapterPath, string miMode, SupportedArchitecture debuggeeArchitecture, IDictionary <string, string> debuggerProperties) { this.DebuggeeArchitecture = debuggeeArchitecture; this.DebuggerName = debuggerName; this.DebuggerType = debuggerType; this.DebuggerPath = debuggerPath; this.DebuggerAdapterPath = debuggerAdapterPath; if (!string.IsNullOrWhiteSpace(miMode)) { this.MIMode = miMode; } this.Properties = debuggerProperties ?? new Dictionary <string, string>(StringComparer.Ordinal); }
protected override bool CompileCore( CompilerOutputType outputType, SupportedArchitecture architecture, IEnumerable <string> libraries, IEnumerable <string> sourceFilePaths, string targetFilePath, CompilerOption options, IDictionary <string, string> defineConstants) { ArgumentBuilder builder = new ArgumentBuilder("-", String.Empty); if (options.HasFlag(CompilerOption.GenerateSymbols)) { builder.AppendNamedArgument("g", null); } if (options.HasFlag(CompilerOption.OptimizeLevel1)) { builder.AppendNamedArgument("O1", null); } else if (options.HasFlag(CompilerOption.OptimizeLevel2)) { builder.AppendNamedArgument("O2", null); } else if (options.HasFlag(CompilerOption.OptimizeLevel3)) { builder.AppendNamedArgument("O3", null); } else { builder.AppendNamedArgument("O0", null); } // Enable pthreads if (options.HasFlag(CompilerOption.SupportThreading)) { builder.AppendNamedArgument("pthread", null); } // Just use C++ 11 builder.AppendNamedArgument("std", "c++11", "="); switch (outputType) { case CompilerOutputType.SharedLibrary: builder.AppendNamedArgument("shared", null); builder.AppendNamedArgument("fpic", null); break; case CompilerOutputType.ObjectFile: builder.AppendNamedArgument("c", null); builder.AppendNamedArgument("fpic", null); break; case CompilerOutputType.Unspecified: // Treat Unspecified as Executable, since executable is the default case CompilerOutputType.Executable: // Compiling an executable does not have a command line option, it's the default break; default: throw new ArgumentOutOfRangeException(nameof(outputType), "Unhandled output type: " + outputType); } switch (architecture) { case SupportedArchitecture.x64: builder.AppendNamedArgument("m", "64"); DefineConstant(builder, "DEBUGGEE_ARCH", "64"); break; case SupportedArchitecture.x86: builder.AppendNamedArgument("m", "32"); DefineConstant(builder, "DEBUGGEE_ARCH", "32"); break; case SupportedArchitecture.arm: builder.AppendNamedArgument("m", "arm"); DefineConstant(builder, "DEBUGGEE_ARCH", "ARM"); break; default: throw new ArgumentOutOfRangeException(nameof(architecture), "Unhandled target architecture: " + architecture); } // Define a constant for the platform name. DefineConstant(builder, "DEBUGGEE_PLATFORM", GetPlatformName()); this.SetAdditionalArguments(builder); builder.AppendNamedArgument("o", targetFilePath); foreach (string sourceFilePath in sourceFilePaths) { builder.AppendArgument(sourceFilePath); } foreach (string library in libraries) { builder.AppendNamedArgument("l", library); } foreach (var defineConstant in defineConstants) { DefineConstant(builder, defineConstant.Key, defineConstant.Value); } return(0 == this.RunCompiler(builder.ToString(), targetFilePath)); }
public SupportedPlatformAttribute(SupportedPlatform platform, SupportedArchitecture architecture) { this.Architecture = architecture; this.Platform = platform; }
public SupportedDebuggerAttribute(SupportedDebugger debugger, SupportedArchitecture architecture) : base(debugger, architecture) { }
public SupportedCompilerAttribute(SupportedCompiler compiler, SupportedArchitecture debuggeeArchitecture) { this.Compiler = compiler; this.Architecture = debuggeeArchitecture; }
private static IEnumerable <ITestSettings> FilterSettings(string methodName, SupportedPlatform platform, SupportedArchitecture platformArchitecture) { MethodInfo methodInfo = AttributionTests.GetTestMethodInfo(methodName); return(AttributionTests.AllSettings.FilterSettings(methodInfo, platform, platformArchitecture)); }
private static TestSettings CreateGppGdbSettings(SupportedArchitecture debuggeeArchitecture, string compilerName, string debuggerName, SupportedDebugger debuggerType) { return(new TestSettings(debuggeeArchitecture, compilerName, SupportedCompiler.GPlusPlus, "g++", null, debuggerName, debuggerType, "gdb", null, null, null)); }
private static TestSettings CreateClangLldbSettings(SupportedArchitecture debuggeeArchitecture, string compilerName, string debuggerName) { return(new TestSettings(debuggeeArchitecture, compilerName, SupportedCompiler.ClangPlusPlus, "clang++", null, debuggerName, SupportedDebugger.Lldb, "lldb-mi", null, "lldb", null)); }
public DebuggerAttribute(SupportedDebugger debugger, SupportedArchitecture architecture) { this.Debugger = debugger; this.Architecture = architecture; }
internal static IEnumerable <ITestSettings> GetSettings(MethodInfo testMethod, SupportedPlatform platform, SupportedArchitecture platformArchitecture) { Parameter.AssertIfNull(testMethod, nameof(testMethod)); // Find the attribute in the context of the test method. // Currently, only look at the assembly of the test method. TestSettingsProviderAttribute providerAttribute = testMethod.DeclaringType?.GetTypeInfo().Assembly?.GetCustomAttribute <TestSettingsProviderAttribute>(); UDebug.AssertNotNull(providerAttribute, "Unable to locate TestSettingsProviderAttribute."); if (null == providerAttribute) { return(Enumerable.Empty <ITestSettings>()); } UDebug.AssertNotNull(providerAttribute.ProviderType, "TestSettingsProviderAttribute.ProviderType is null"); if (null == providerAttribute.ProviderType) { return(Enumerable.Empty <ITestSettings>()); } ITestSettingsProvider provider = null; lock (s_providerMapping) { // Get the provider from the attribute if the provider was not already created if (!s_providerMapping.TryGetValue(providerAttribute.ProviderType, out provider)) { // If not cached, create the provide from the attribute and cache it provider = (ITestSettingsProvider)Activator.CreateInstance(providerAttribute.ProviderType); s_providerMapping.Add(providerAttribute.ProviderType, provider); } } // Get the list of settings from the provider IEnumerable <ITestSettings> settings = provider.GetSettings(testMethod); UDebug.AssertNotNull(settings, "Settings were not provided by the test settings provider."); if (null == settings) { return(Enumerable.Empty <ITestSettings>()); } // Filter the settings according to the attribution on the test method return(settings.FilterSettings(testMethod, platform, platformArchitecture)); }
internal static IEnumerable <ITestSettings> FilterSettings(this IEnumerable <ITestSettings> settings, MethodInfo methodInfo, SupportedPlatform platform, SupportedArchitecture platformArchitecture) { // Makre sure that the test runs for the platform and platform architecture SupportedPlatformAttribute platformAttribute = methodInfo.GetCustomAttribute <SupportedPlatformAttribute>(); // If platform attribute is not specified, implicitly assume that all platforms are supported if (null != platformAttribute) { if (!platformAttribute.Platform.HasFlag(platform)) { return(Enumerable.Empty <ITestSettings>()); } if (!platformAttribute.Architecture.HasFlag(platformArchitecture)) { return(Enumerable.Empty <ITestSettings>()); } } IReadOnlyCollection <SupportedCompilerAttribute> supportedCompilers = methodInfo.GetCustomAttributes <SupportedCompilerAttribute>().ToArray(); IReadOnlyCollection <SupportedDebuggerAttribute> supportedDebuggers = methodInfo.GetCustomAttributes <SupportedDebuggerAttribute>().ToArray(); IReadOnlyCollection <UnsupportedDebuggerAttribute> unsupportedDebuggers = methodInfo.GetCustomAttributes <UnsupportedDebuggerAttribute>().ToArray(); // Get the subset of test settings that match the requirements of the test. // The test will be run for each test setting in the set. If an empty set is returned, // the test is not run. return(settings.Where(s => (supportedCompilers.Count == 0 || supportedCompilers.Matches(s.CompilerSettings)) && (supportedDebuggers.Count == 0 || supportedDebuggers.Matches(s.DebuggerSettings)) && !unsupportedDebuggers.Matches(s.DebuggerSettings)) .Select(x => TestSettings.CloneWithName(x, methodInfo.Name)) .ToArray()); }
protected override bool CompileCore( CompilerOutputType outputType, SupportedArchitecture architecture, IEnumerable <string> libraries, IEnumerable <string> sourceFilePaths, string targetFilePath, CompilerOption options, IDictionary <string, string> defineConstants) { ArgumentBuilder clBuilder = new ArgumentBuilder("/", ":"); ArgumentBuilder linkBuilder = new ArgumentBuilder("/", ":"); foreach (var defineConstant in defineConstants) { DefineConstant(clBuilder, defineConstant.Key, defineConstant.Value); } DefineConstant(clBuilder, "_WIN32"); // Suppresses error C4996 for 'getenv' (in debuggees/kitchensink/src/environment.cpp) DefineConstant(clBuilder, "_CRT_SECURE_NO_WARNINGS"); if (options.HasFlag(CompilerOption.GenerateSymbols)) { clBuilder.AppendNamedArgument("ZI", null); clBuilder.AppendNamedArgument("Debug", null); } if (!options.HasFlag(CompilerOption.OptimizeLevel1) && !options.HasFlag(CompilerOption.OptimizeLevel2) && !options.HasFlag(CompilerOption.OptimizeLevel3)) { // Disable optimization clBuilder.AppendNamedArgument("Od", null); } // Add options that are set by default in VS AddDefaultOptions(clBuilder); if (this.Settings.Properties != null) { // Get the include folders from the compiler properties string rawIncludes; if (!this.Settings.Properties.TryGetValue("Include", out rawIncludes)) { rawIncludes = String.Empty; } IEnumerable <string> includes = rawIncludes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); foreach (string include in includes) { clBuilder.AppendNamedArgumentQuoted("I", include, string.Empty); } // Get the lib folders from the compiler properties string rawLibs; if (!this.Settings.Properties.TryGetValue("Lib", out rawLibs)) { rawLibs = String.Empty; } IEnumerable <string> libs = rawLibs.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); foreach (string lib in libs) { linkBuilder.AppendNamedArgumentQuoted("LIBPATH", lib); } } switch (outputType) { case CompilerOutputType.SharedLibrary: // Create.DLL clBuilder.AppendNamedArgument("LD", null); clBuilder.AppendNamedArgument("Fo", Path.GetDirectoryName(targetFilePath) + Path.DirectorySeparatorChar); clBuilder.AppendNamedArgument("Fe", targetFilePath); break; case CompilerOutputType.ObjectFile: // Name obj clBuilder.AppendNamedArgument("Fo", targetFilePath); break; case CompilerOutputType.Unspecified: // Treat Unspecified as Executable, since executable is the default case CompilerOutputType.Executable: // Compiling an executable does not have a command line option, it's the default // Name exe clBuilder.AppendNamedArgument("Fo", Path.GetDirectoryName(targetFilePath) + Path.DirectorySeparatorChar); clBuilder.AppendNamedArgument("Fe", targetFilePath); break; default: throw new ArgumentOutOfRangeException(nameof(outputType), "Unhandled output type: " + outputType); } // Specify the PDB name clBuilder.AppendNamedArgument("Fd", Path.ChangeExtension(targetFilePath, "pdb")); // Define a constant for the platform name. DefineConstant(clBuilder, "DEBUGGEE_PLATFORM", GetPlatformName()); DefineConstant(clBuilder, "DEBUGGEE_COMPILER", "Visual C++"); foreach (string sourceFilePath in sourceFilePaths) { clBuilder.AppendArgument(sourceFilePath); } foreach (string library in libraries) { clBuilder.AppendArgument(library); } switch (architecture) { case SupportedArchitecture.x64: DefineConstant(clBuilder, "DEBUGGEE_ARCH", "64"); linkBuilder.AppendNamedArgument("MACHINE", "X64"); break; case SupportedArchitecture.x86: DefineConstant(clBuilder, "DEBUGGEE_ARCH", "32"); linkBuilder.AppendNamedArgument("MACHINE", "X86"); break; default: throw new ArgumentOutOfRangeException(nameof(architecture), "Unhandled target architecture: " + architecture); } // Pass the linker arguments (Note, the link parameter doesn't use the ":" suffix) clBuilder.AppendNamedArgument("link", linkBuilder.ToString(), overrideSuffix: " "); return(0 == this.RunCompiler(clBuilder.ToString(), targetFilePath)); }