-
-
Notifications
You must be signed in to change notification settings - Fork 1
Move build tasks into SDK and add cross-platform resource parser #5
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
nanoFramework.Tools.BuildTasks/GenerateBinaryOutputTask.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Utilities; | ||
| using nanoFramework.Tools.Utilities; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel; | ||
| using System.IO; | ||
| using System.Linq; | ||
|
|
||
| namespace nanoFramework.Tools | ||
| { | ||
| [Description("GenerateBinaryOutputTaskEntry")] | ||
|
|
||
| public class GenerateBinaryOutputTask : Task | ||
| { | ||
| #region public properties for the task | ||
|
|
||
| public string Assembly { get; set; } | ||
|
|
||
| public string AssemblyPE { get; set; } | ||
|
|
||
| public ITaskItem[] AssemblyReferences { get; set; } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// The name(s) of binary file created. | ||
| /// </summary> | ||
| [Output] | ||
| public ITaskItem FileWritten { get; private set; } | ||
|
|
||
| #endregion | ||
|
|
||
| public override bool Execute() | ||
| { | ||
| // report to VS output window what step the build is | ||
| Log.LogMessage(MessageImportance.Normal, "Generating binary output file..."); | ||
|
|
||
| // wait for debugger on var | ||
| DebuggerHelper.WaitForDebuggerIfEnabled(TasksConstants.BuildTaskDebugVar); | ||
|
|
||
| // default with null, indicating that we've generated nothing | ||
| FileWritten = null; | ||
|
|
||
| // get paths for PE files | ||
| List<string> peCollection = AssemblyReferences? | ||
| .Select(a => Path.ChangeExtension(a.GetMetadata("FullPath"), ".pe")) | ||
| .ToList() ?? new List<string>(); | ||
|
|
||
| // add executable PE | ||
| peCollection.Add(AssemblyPE); | ||
|
|
||
| // get executable path and file name | ||
| // rename executable extension .exe with .bin | ||
| var binOutputFile = Assembly.Replace(".exe", ".bin"); | ||
|
|
||
| using (FileStream binFile = new FileStream(binOutputFile, FileMode.Create)) | ||
| { | ||
| // now we will re-deploy all system assemblies | ||
| foreach (string peItem in peCollection) | ||
| { | ||
| // append to the deploy blob the assembly | ||
| using (FileStream fs = File.Open(peItem, FileMode.Open, FileAccess.Read, FileShare.Read)) | ||
| { | ||
| long length = (fs.Length + 3) / 4 * 4; | ||
| byte[] buffer = new byte[length]; | ||
| int fileLength = (int)fs.Length; | ||
| int totalRead = 0; | ||
|
|
||
| while (totalRead < fileLength) | ||
| { | ||
| int bytesRead = fs.Read(buffer, totalRead, fileLength - totalRead); | ||
|
|
||
| if (bytesRead == 0) | ||
| { | ||
| throw new EndOfStreamException($"Unexpected end of file while reading '{peItem}'."); | ||
| } | ||
|
|
||
| totalRead += bytesRead; | ||
| } | ||
|
|
||
| // copy this assembly to the bin file too | ||
| binFile.Write(buffer, 0, (int)length); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| // bin file written | ||
| FileWritten = new TaskItem(binOutputFile); | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
| } | ||
53 changes: 0 additions & 53 deletions
53
nanoFramework.Tools.BuildTasks/GenerateNanoResourceTask.Stub.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.