-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add managed build client #884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.BuildTasks | ||
| { | ||
| [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
| internal struct STARTUPINFO | ||
| { | ||
| internal Int32 cb; | ||
| internal string lpReserved; | ||
| internal string lpDesktop; | ||
| internal string lpTitle; | ||
| internal Int32 dwX; | ||
| internal Int32 dwY; | ||
| internal Int32 dwXSize; | ||
| internal Int32 dwYSize; | ||
| internal Int32 dwXCountChars; | ||
| internal Int32 dwYCountChars; | ||
| internal Int32 dwFillAttribute; | ||
| internal Int32 dwFlags; | ||
| internal Int16 wShowWindow; | ||
| internal Int16 cbReserved2; | ||
| internal IntPtr lpReserved2; | ||
| internal IntPtr hStdInput; | ||
| internal IntPtr hStdOutput; | ||
| internal IntPtr hStdError; | ||
| } | ||
|
|
||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal struct PROCESS_INFORMATION | ||
| { | ||
| public IntPtr hProcess; | ||
| public IntPtr hThread; | ||
| public int dwProcessId; | ||
| public int dwThreadId; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Interop methods. | ||
| /// </summary> | ||
| internal static class NativeMethods | ||
| { | ||
| #region Constants | ||
|
|
||
| internal static readonly IntPtr NullPtr = IntPtr.Zero; | ||
| internal static readonly IntPtr InvalidIntPtr = new IntPtr((int)-1); | ||
|
|
||
| internal const uint NORMAL_PRIORITY_CLASS = 0x0020; | ||
| internal const uint CREATE_NO_WINDOW = 0x08000000; | ||
| internal const Int32 STARTF_USESTDHANDLES = 0x00000100; | ||
| internal const int ERROR_SUCCESS = 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big issue, but it looks a bit odd having |
||
|
|
||
| #endregion | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| // CloseHandle | ||
| //------------------------------------------------------------------------------ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment seems pointless. |
||
| [DllImport("kernel32.dll", SetLastError = true)] | ||
| [return: MarshalAs(UnmanagedType.Bool)] | ||
| internal static extern bool CloseHandle(IntPtr hObject); | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| // CreateProcess | ||
| //------------------------------------------------------------------------------ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment seems pointless. |
||
| [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | ||
| [return: MarshalAs(UnmanagedType.Bool)] | ||
| internal static extern bool CreateProcess | ||
| ( | ||
| string lpApplicationName, | ||
| string lpCommandLine, | ||
| IntPtr lpProcessAttributes, | ||
| IntPtr lpThreadAttributes, | ||
| [In, MarshalAs(UnmanagedType.Bool)] | ||
| bool bInheritHandles, | ||
| uint dwCreationFlags, | ||
| IntPtr lpEnvironment, | ||
| string lpCurrentDirectory, | ||
| [In] ref STARTUPINFO lpStartupInfo, | ||
| out PROCESS_INFORMATION lpProcessInformation | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Tasks.Hosting; | ||
| using Microsoft.Build.Utilities; | ||
| using Microsoft.CodeAnalysis.CompilerServer; | ||
| using Microsoft.CodeAnalysis.CSharp; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.BuildTasks | ||
| { | ||
|
|
@@ -152,6 +154,24 @@ public string WarningsNotAsErrors | |
|
|
||
| #region Tool Members | ||
|
|
||
| internal override BuildProtocolConstants.RequestLanguage Language | ||
| => BuildProtocolConstants.RequestLanguage.CSharpCompile; | ||
|
|
||
| private static string[] s_separators = { "\r\n" }; | ||
|
|
||
| internal override void LogMessages(string output, MessageImportance messageImportance) | ||
| { | ||
| var lines = output.Split(s_separators, StringSplitOptions.RemoveEmptyEntries); | ||
| foreach (string line in lines) | ||
| { | ||
| string trimmedMessage = line.Trim(); | ||
| if (trimmedMessage != "") | ||
| { | ||
| Log.LogMessageFromText(trimmedMessage, messageImportance); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Return the name of the tool to execute. | ||
| /// </summary> | ||
|
|
@@ -274,8 +294,6 @@ override protected internal void AddResponseFileCommands(CommandLineBuilderExten | |
| /// list of aliases, and if any of the aliases specified is the string "global", | ||
| /// then we add that reference to the command-line without an alias. | ||
| /// </summary> | ||
| /// <param name="commandLine"></param> | ||
| /// <owner>RGoel</owner> | ||
| private void AddReferencesToCommandLine | ||
| ( | ||
| CommandLineBuilderExtension commandLine | ||
|
|
@@ -393,7 +411,7 @@ internal string GetDefineConstantsSwitch(string originalDefineConstants) | |
| // add them to the outgoing string. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the doc comment for this method GetDefineConstantsSwitch (GitHub does not allow me to place a comment there). It says "Note that CSharp does support assigning a value to the constants", but probably means "Note that CSharp does NOT support assigning a value to the constants". |
||
| foreach (string singleIdentifier in allIdentifiers) | ||
| { | ||
| if (CSharp.SyntaxFacts.IsValidIdentifier(singleIdentifier)) | ||
| if (SyntaxFacts.IsValidIdentifier(singleIdentifier)) | ||
| { | ||
| // Separate them with a semicolon if there's something already in | ||
| // the outgoing string. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting int to int seems pointless.