Exemplo n.º 1
0
 protected abstract bool Compile(string fileName, CppCompilerOptions options);
Exemplo n.º 2
0
        protected override bool Compile(string fileName, CppCompilerOptions options)
        {
            var idePath = Path.Combine(compilerDir, "..\\Common7\\IDE");
            var startInfo = new ProcessStartInfo(Path.Combine(compilerDir, "bin\\cl.exe"));
            var dllName = Path.GetFileNameWithoutExtension(fileName);
            startInfo.UseShellExecute = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError = true;
            startInfo.WorkingDirectory = Path.GetDirectoryName(Path.GetFullPath(fileName));
            startInfo.Arguments = @"/GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /fp:precise /D""WIN32"" /D""NDEBUG"" /D""_WINDOWS"" /D""_USRDLL""/D""_WINDLL"" /D""_UNICODE"" /D""UNICODE"" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /EHsc /nologo """ + fileName + @""" ""kernel32.lib"" ""user32.lib"" ""gdi32.lib"" ""winspool.lib"" ""comdlg32.lib"" /link /OUT:""" + dllName + @".dll"" /DEF:""Export.def"" /DLL /nologo";
            var sdk = Environment.GetEnvironmentVariable("WindowsSdkDir");
            startInfo.EnvironmentVariables.Add("INCLUDE", Path.Combine(compilerDir, "include"));
            startInfo.EnvironmentVariables.Add("LIB", Path.Combine(compilerDir, "lib")  + ";" + sdkDir);
            startInfo.EnvironmentVariables.Add("LIBPATH", Path.Combine(compilerDir, "lib") + ";" + sdkDir);
            startInfo.EnvironmentVariables["PATH"] = Environment.GetEnvironmentVariable("PATH") + ";" + idePath;
            var proc = Process.Start(startInfo);
            var output = proc.StandardOutput.ReadToEnd();
            proc.WaitForExit();

            Console.WriteLine(output);
            if (proc.ExitCode != 0)
                return false;
            else
                return true;
        }