aboutsummaryrefslogtreecommitdiff
path: root/build_msvc/msbuild/tasks/hexdump.targets
diff options
context:
space:
mode:
authorAaron Clauson <aaron@sipsorcery.com>2018-08-10 09:19:00 +0200
committerAaron Clauson <aaron@sipsorcery.com>2018-08-10 09:19:00 +0200
commitef7beaea6abcaab389ccb486a8f25bc4512b99ed (patch)
tree86223ae2f6c0eb342bc03bf1b5e77cbeb5ecb0be /build_msvc/msbuild/tasks/hexdump.targets
parentf66e1c793eda7a6143fd03400c98512a9b6f00c7 (diff)
Visual Studio build configuration for Bitcoin Core
Diffstat (limited to 'build_msvc/msbuild/tasks/hexdump.targets')
-rw-r--r--build_msvc/msbuild/tasks/hexdump.targets53
1 files changed, 53 insertions, 0 deletions
diff --git a/build_msvc/msbuild/tasks/hexdump.targets b/build_msvc/msbuild/tasks/hexdump.targets
new file mode 100644
index 0000000000..12868a9874
--- /dev/null
+++ b/build_msvc/msbuild/tasks/hexdump.targets
@@ -0,0 +1,53 @@
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <UsingTask
+ TaskName="HeaderFromHexdump"
+ TaskFactory="CodeTaskFactory"
+ AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
+ <ParameterGroup>
+ <RawFilePath Required="true" />
+ <HeaderFilePath Required="true" />
+ <SourceHeader Required="true" />
+ <SourceFooter Required="true" />
+ </ParameterGroup>
+ <Task>
+ <Using Namespace="System"/>
+ <Using Namespace="System.IO"/>
+ <Code Type="Fragment" Language="cs">
+<![CDATA[
+Log.LogMessage("msbuild inline hexdump task for " + RawFilePath + ".");
+if(File.Exists(RawFilePath) == false) {
+ Log.LogError("hexdump task could not locate " + RawFilePath + ".");
+}
+else {
+ FileInfo inFileInfo = new FileInfo(RawFilePath);
+ FileInfo outFileInfo = new FileInfo(HeaderFilePath);
+
+ if (outFileInfo.Exists == false || inFileInfo.LastWriteTime > outFileInfo.LastWriteTime)
+ {
+ using (Stream inStm = File.OpenRead(RawFilePath))
+ {
+ using (StreamWriter sw = new StreamWriter(HeaderFilePath))
+ {
+ sw.WriteLine(SourceHeader);
+ int count = 0;
+ int rawChar = inStm.ReadByte();
+ while(rawChar != -1)
+ {
+ sw.Write("0x{0:x2}, ", rawChar);
+ count++;
+ if(count % 8 == 0)
+ {
+ sw.WriteLine();
+ }
+ rawChar = inStm.ReadByte();
+ }
+ sw.WriteLine(SourceFooter);
+ }
+ }
+ }
+}
+]]>
+ </Code>
+ </Task>
+ </UsingTask>
+</Project> \ No newline at end of file