private void ValidateArchitecture(Architecture architecture) { if (!SupportedArchitectures.Any(s => s.Equals(architecture.ToString(), StringComparison.OrdinalIgnoreCase))) { throw new PlatformNotSupportedException($"Architecture {architecture.ToString()} is not supported for language {Language}"); } }
public LLVMDisassembler(IDisassemblable cpu) { if (!SupportedArchitectures.ContainsKey(cpu.Architecture)) { throw new ArgumentOutOfRangeException("cpu"); } this.cpu = cpu; cache = new Dictionary <string, IDisassembler>(); }
public LLVMDisassembler(IDisassemblable cpu) { if (!SupportedArchitectures.ContainsKey(cpu.Architecture)) { throw new ArgumentOutOfRangeException("cpu"); } this.cpu = cpu; cache = new Dictionary <string, LLVMDisasWrapper>(); Disassemble = cpu.Architecture == "arm-m" ? CortexMAddressTranslator.Wrap(LLVMDisassemble) : LLVMDisassemble; }
protected void SetSupportedArchitectures(params Architecture[] architectures) { SupportedArchitectures = architectures; SupportedArchitectureStrings = SupportedArchitectures.Select(arch => ObjectNames.NicifyVariableName(Enum.GetName(typeof(Architecture), arch))).ToArray(); SupportedArchitectureInts = SupportedArchitectures.Select(arch => (int)arch).ToArray(); }
public static bool IsAvailableFor(string arch) { return(SupportedArchitectures.ContainsKey(arch)); }
public void OverrideNulls(ResourceNode defaultValues) { Init(); if (defaultValues == null) { CheckConsistency(); return; } //ResourceName { get; set; } // private set //public string ProviderName; if (!SupportedArchitectures.Any() && defaultValues.SupportedArchitectures.Any()) { SupportedArchitectures = defaultValues.SupportedArchitectures; // it's ok, because field is read-only } if (Services == null) { Services = new NodeServices(defaultValues.Services); } if (DataFolders == null) { DataFolders = new NodeDataFolders(defaultValues.DataFolders); } Credentials = new NodeCredentials ( userName: (Credentials.Username ?? defaultValues.Credentials.Username), password: (Credentials.Password ?? defaultValues.Credentials.Password), certFile: (Credentials.CertFile ?? defaultValues.Credentials.CertFile) ); if (CoresCount == 0 && defaultValues.CoresCount > 0) { CoresCount = defaultValues.CoresCount; } //if (CoresAvailable == 0 && defaultValues.CoresAvailable > 0) // todo : unnecessary? //CoresAvailable = defaultValues.CoresAvailable; if (TasksSubmissionLimit <= 1 && defaultValues.TasksSubmissionLimit > 1) // do not override if defaultValue == (0 or 1) or non-default value for node is set { TasksSubmissionLimit = defaultValues.TasksSubmissionLimit; } //if (SubmissionsAvailable == 0 && defaultValues.SubmissionsAvailable > 0) // todo : unnecessary? //SubmissionsAvailable = defaultValues.SubmissionsAvailable; if (defaultValues.StaticHardwareParams != null) { foreach (var key in defaultValues.StaticHardwareParams.Keys) { if (!StaticHardwareParams.ContainsKey(key)) { StaticHardwareParams[key] = defaultValues.StaticHardwareParams[key]; } } } if (!_packages.Any()) { foreach (var pack in defaultValues._packages) { _packages.Add(new PackageOnNode(pack)); } } if (!_otherSoftware.Any()) { foreach (var soft in defaultValues._otherSoftware) { _otherSoftware.Add(soft); } } CheckConsistency(); }
public override bool Run(BuildConfiguration config, Architecture arch) { // Clear errors before trying. Errors.Clear(); if (!SupportedArchitectures.HasFlag(arch)) { Errors.Add(new Exception("Unsupported architecture specified for build task.")); return(false); } if (!ConfigureDirectories()) { Errors.Add(new Exception("Failed to configure arch specific directories for openSSL build.")); return(false); } // We need to get the environment for a the MSVC compiler and // associated build tools. var installedMsvcVersions = MSVCCompilerTask.InstalledToolVersions; if (installedMsvcVersions.Count == 0) { Errors.Add(new Exception("Could not detect a compatible installation of MSVC.")); return(false); } // Get a reversed list of tool versions and iterate over them, until we find // an installed version. This way we're always working with the latest // version available. var allVersions = Enum.GetValues(typeof(ToolVersions)).Cast <ToolVersions>().Reverse(); ToolVersions versionToUse = ToolVersions.v11; foreach (var msvcVersion in allVersions) { if (installedMsvcVersions.ContainsKey(msvcVersion)) { versionToUse = msvcVersion; WriteLineToConsole(string.Format("Discovered and using MSVC {0} for compilation.", versionToUse.ToString())); break; } } // Build out the base path to the openSSL source directory. StringBuilder opensslBasePath = new StringBuilder(WorkingDirectory); opensslBasePath.Append(Path.DirectorySeparatorChar); opensslBasePath.Append("deps"); opensslBasePath.Append(Path.DirectorySeparatorChar); opensslBasePath.Append("openssl"); int numCompilationAttempts = 0; int numSuccessfulCompilations = 0; // We're only going to iterate over arches. We're not going to build a debug // version of openSSL, just release versions for each arch. foreach (Architecture a in Enum.GetValues(typeof(Architecture))) { if (arch.HasFlag(a)) { ++numCompilationAttempts; var finalBuildEnvironment = MSVCCompilerTask.GetEnvironmentForVersion(versionToUse, a); // Add perl path if it doesn't already exist. if (finalBuildEnvironment["PATH"].IndexOf(m_perlDir) == -1) { finalBuildEnvironment["PATH"] += (Path.PathSeparator + m_perlDir); } var configArgs = new List <string>(); configArgs.Add("no-idea"); configArgs.Add("no-mdc2"); configArgs.Add("no-rc5"); configArgs.Add("no-comp"); // XXX TODO - Remove this option when upgrading to openSSL 1.1.0 configArgs.Add("no-ssl2"); configArgs.Add("no-ssl3"); configArgs.Add("no-weak-ssl-ciphers"); configArgs.Add("threads"); // The working dir. This will either be the x86 or x64 openSSL source dir. string workingDirectory = string.Empty; // We need to include nasm regardless of rater arch because // the openSSL configuration system will whine and quit if // we don't. We should be guaranteed to have a PATH variable // here unless something went horribly wrong. finalBuildEnvironment["PATH"] += (Path.PathSeparator + m_nasmDir); // XXX TODO - This needs to go away when we bump to OpenSSL 1.1.0 string whichAsmCall = string.Empty; string openSslInstallDir = string.Empty; switch (a) { case Architecture.x86: { // Build inside the x86 dir workingDirectory = m_openSslx86Dir; // Set x86 release build. configArgs.Insert(0, "VC-WIN32"); whichAsmCall = "ms" + Path.DirectorySeparatorChar + "do_nasm.bat"; openSslInstallDir = opensslBasePath.ToString().ConvertToHostOsPath() + Path.DirectorySeparatorChar + "msvc" + Path.DirectorySeparatorChar + "Releasex86"; } break; case Architecture.x64: { // Build inside the x64 dir workingDirectory = m_openSslx64Dir; whichAsmCall = "ms" + Path.DirectorySeparatorChar + "do_win64a.bat"; // Set x64 release build. configArgs.Insert(0, "VC-WIN64A"); openSslInstallDir = opensslBasePath.ToString().ConvertToHostOsPath() + Path.DirectorySeparatorChar + "msvc" + Path.DirectorySeparatorChar + "Releasex64"; } break; default: { WriteLineToConsole(string.Format("Dont have arch: {0}", a.ToString())); continue; } } // Setup prefix (output) path to deps/openssl/msvc/ReleaseX64 configArgs.Add( string.Format( "--prefix={0}", openSslInstallDir) ); // Setup config path to deps/openssl/msvc/ReleaseX86 configArgs.Add( string.Format( "--openssldir={0}", openSslInstallDir) ); WriteLineToConsole(string.Format("Configuring for arch: {0}", a.ToString())); WriteLineToConsole(workingDirectory); WriteLineToConsole(string.Format("Config Path: {0}", workingDirectory + Path.DirectorySeparatorChar + "Configure")); // Push configure script to front of args. configArgs.Insert(0, "Configure"); WriteLineToConsole(string.Join(" ", configArgs)); // Run the configuration process. var perlExitCode = RunProcess(workingDirectory, m_perlDir + Path.DirectorySeparatorChar + "perl.exe", configArgs, Timeout.Infinite, finalBuildEnvironment); // Now run the actual build process. // Example of the call string expanded/populated: // call "ms\do_nasm.bat" && nmake -f ms\ntdll.mak && nmake -f ms\ntdll.mak install string callArgs = string.Format("/C \"{0}\" && {1} && {2}", whichAsmCall, "nmake -f ms" + Path.DirectorySeparatorChar + "ntdll.mak", "nmake -f ms" + Path.DirectorySeparatorChar + "ntdll.mak install"); // XXX TODO - This is way to do it when we jump up to OpenSSL 1.1.0 //string callArgs = string.Format("/C {0} && {1}", "nmake", "nmake install"); // Running cmd.exe with these batch commands will build openSSL. var buildExitCode = RunProcess(workingDirectory, "cmd.exe", new List <string> { callArgs }, Timeout.Infinite, finalBuildEnvironment); if (perlExitCode == 0 && buildExitCode == 0) { // Was a success. Move the output folder now. var destBaseDir = opensslBasePath.ToString().ConvertToHostOsPath() + Path.DirectorySeparatorChar + "msvc" + Path.DirectorySeparatorChar; var destReleaseDir = destBaseDir + string.Format("{0} {1}", BuildConfiguration.Release.ToString(), a.ToString()); var destDebugDir = destBaseDir + string.Format("{0} {1}", BuildConfiguration.Debug.ToString(), a.ToString()); // If we don't delete old stuff, Directory.Move will fail. if (Directory.Exists(destReleaseDir)) { Directory.Delete(destReleaseDir, true); } // Move aka rename the directory to have a space. try { Directory.Move(openSslInstallDir, destReleaseDir); } catch { // Sometimes getting access denied. Perhaps parts of the build // process are still hanging. Try and give them a few seconds // to wrap up, then try again. Thread.Sleep(3000); Directory.Move(openSslInstallDir, destReleaseDir); } // Simply copy the release folder for arch to a debug folder. CopyDirectory(destReleaseDir, destDebugDir, true); ++numSuccessfulCompilations; } } } var wasSuccess = numCompilationAttempts > 0 && numCompilationAttempts == numSuccessfulCompilations; return(wasSuccess); }