mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 04:18:43 +00:00
Added build targets for publish.
This commit is contained in:
parent
29ca16f47d
commit
35cdcc64a0
21 changed files with 145 additions and 15 deletions
63
source/Cosmos.Build.Tasks/CreateMbr.cs
Normal file
63
source/Cosmos.Build.Tasks/CreateMbr.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Cosmos.Build.Tasks
|
||||
{
|
||||
public class CreateMbr : ToolTask
|
||||
{
|
||||
[Required]
|
||||
public string TargetDrive { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool FormatDrive { get; set; }
|
||||
|
||||
protected override string ToolName => "syslinux.exe";
|
||||
|
||||
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||
|
||||
protected override bool ValidateParameters()
|
||||
{
|
||||
if (!DriveInfo.GetDrives().Any(
|
||||
d => String.Equals(
|
||||
Path.GetFullPath(d.Name),
|
||||
Path.GetFullPath(TargetDrive),
|
||||
StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
Log.LogError($"Invalid target drive '{TargetDrive}'!");
|
||||
}
|
||||
|
||||
return !Log.HasLoggedErrors;
|
||||
}
|
||||
|
||||
protected override string GenerateFullPathToTool()
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(ToolExe))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(ToolPath))
|
||||
{
|
||||
return Path.Combine(Directory.GetCurrentDirectory(), ToolExe);
|
||||
}
|
||||
|
||||
return Path.Combine(Path.GetFullPath(ToolPath), ToolExe);
|
||||
}
|
||||
|
||||
protected override string GenerateCommandLineCommands()
|
||||
{
|
||||
var builder = new CommandLineBuilder();
|
||||
|
||||
var driveLetter = TargetDrive.TrimEnd(':', Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
|
||||
builder.AppendSwitch("-fma");
|
||||
builder.AppendSwitch($"{driveLetter}:");
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
|
|
@ -8,7 +7,7 @@ namespace Cosmos.Build.Tasks
|
|||
public class CreateSyslinuxConfig : Task
|
||||
{
|
||||
[Required]
|
||||
public string IsoDirectory { get; set; }
|
||||
public string TargetDirectory { get; set; }
|
||||
|
||||
[Required]
|
||||
public string BinName { get; set; }
|
||||
|
|
@ -17,16 +16,16 @@ namespace Cosmos.Build.Tasks
|
|||
|
||||
public override bool Execute()
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(IsoDirectory) || !Directory.Exists(IsoDirectory))
|
||||
if (!Directory.Exists(TargetDirectory))
|
||||
{
|
||||
Log.LogError($"Invalid ISO directory! ISO directory: '{IsoDirectory}'");
|
||||
Log.LogError($"Invalid target directory! Target directory: '{TargetDirectory}'");
|
||||
return false;
|
||||
}
|
||||
|
||||
var xBinName = BinName;
|
||||
var xLabelName = Path.GetFileNameWithoutExtension(xBinName);
|
||||
|
||||
using (var xWriter = File.CreateText(Path.Combine(IsoDirectory, "syslinux.cfg")))
|
||||
using (var xWriter = File.CreateText(Path.Combine(TargetDirectory, "syslinux.cfg")))
|
||||
{
|
||||
xWriter.WriteLine("default " + xLabelName);
|
||||
xWriter.WriteLine("label " + xLabelName);
|
||||
|
|
|
|||
|
|
@ -13,23 +13,26 @@
|
|||
<PropertyGroup>
|
||||
<CosmosToolsPath Condition="'$(CosmosToolsPath)' == ''">$(MSBuildThisFileDirectory)..\tools\</CosmosToolsPath>
|
||||
|
||||
<NasmToolPath Condition = "'$(NasmToolPath)' == ''">$(CosmosToolsPath)nasm\</NasmToolPath>
|
||||
<NasmToolPath Condition = "'$(NasmToolPath)' == ''">$(CosmosToolsPath)nasm\win\</NasmToolPath>
|
||||
<NasmToolExe Condition = "'$(NasmToolExe)' == ''">nasm.exe</NasmToolExe>
|
||||
|
||||
<LdToolPath Condition = "'$(LdToolPath)' == ''">$(CosmosToolsPath)cygwin\</LdToolPath>
|
||||
<LdToolPath Condition = "'$(LdToolPath)' == ''">$(CosmosToolsPath)cygwin\win\</LdToolPath>
|
||||
<LdToolExe Condition = "'$(LdToolExe)' == ''">ld.exe</LdToolExe>
|
||||
|
||||
<ObjdumpToolPath Condition = "'$(ObjdumpToolPath)' == ''">$(CosmosToolsPath)cygwin\</ObjdumpToolPath>
|
||||
<ObjdumpToolPath Condition = "'$(ObjdumpToolPath)' == ''">$(CosmosToolsPath)cygwin\win\</ObjdumpToolPath>
|
||||
<ObjdumpToolExe Condition = "'$(ObjdumpToolExe)' == ''">objdump.exe</ObjdumpToolExe>
|
||||
|
||||
<MkisofsToolPath Condition = "'$(MkisofsToolPath)' == ''">$(CosmosToolsPath)mkisofs\</MkisofsToolPath>
|
||||
<MkisofsToolPath Condition = "'$(MkisofsToolPath)' == ''">$(CosmosToolsPath)mkisofs\win\</MkisofsToolPath>
|
||||
<MkisofsToolExe Condition = "'$(MkisofsToolExe)' == ''">mkisofs.exe</MkisofsToolExe>
|
||||
|
||||
<SyslinuxToolPath Condition = "'$(SyslinuxToolPath)' == ''">$(CosmosToolsPath)syslinux\win\</SyslinuxToolPath>
|
||||
<SyslinuxToolExe Condition = "'$(SyslinuxToolExe)' == ''">syslinux.exe</SyslinuxToolExe>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DebugEnabled Condition="'$(DebugEnabled)' == '' AND '$(Configuration)' == 'Debug'">True</DebugEnabled>
|
||||
<DebugEnabled Condition="'$(DebugEnabled)' == ''">False</DebugEnabled>
|
||||
|
||||
|
||||
<BinFormat Condition="'$(BinFormat)' == ''">ELF</BinFormat>
|
||||
<DebugMode Condition="'$(DebugMode)' == ''">Source</DebugMode>
|
||||
<TraceMode Condition="'$(TraceMode)' == ''">User</TraceMode>
|
||||
|
|
@ -48,7 +51,7 @@
|
|||
<CosmosDebugSymbolsFile Condition="'$(CosmosDebugSymbolsFile)' == ''">$(OutputPath)$(AssemblyName).cdb</CosmosDebugSymbolsFile>
|
||||
|
||||
<IntermediateIsoDirectory Condition="'$(IntermediateIsoDirectory)' == ''">$(OutputPath)ISO\</IntermediateIsoDirectory>
|
||||
<ISOLINUX Condition="'$(ISOLINUX)' == ''">$(CosmosToolsPath)isolinux\</ISOLINUX>
|
||||
<SyslinuxPath Condition="'$(SyslinuxPath)' == ''">$(CosmosToolsPath)syslinux\bios\</SyslinuxPath>
|
||||
|
||||
<Deployment Condition="'$(Deployment)' == ''">ISO</Deployment>
|
||||
</PropertyGroup>
|
||||
|
|
@ -73,6 +76,7 @@
|
|||
<PlugsReference Include="$(KernelAssembliesDir)Cosmos.Plugs.TapRoot.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<UsingTask TaskName="Cosmos.Build.Tasks.CreateMbr" AssemblyFile="$(CosmosBuildTasksAssembly)" />
|
||||
<UsingTask TaskName="Cosmos.Build.Tasks.CreateSyslinuxConfig" AssemblyFile="$(CosmosBuildTasksAssembly)" />
|
||||
<UsingTask TaskName="Cosmos.Build.Tasks.ExtractMapFromElfFile" AssemblyFile="$(CosmosBuildTasksAssembly)" />
|
||||
<UsingTask TaskName="Cosmos.Build.Tasks.IL2CPU" AssemblyFile="$(CosmosBuildTasksAssembly)" />
|
||||
|
|
@ -260,15 +264,20 @@
|
|||
Condition="'$(Deployment)' == 'ISO'">
|
||||
|
||||
<ItemGroup>
|
||||
<_ISOLINUX Include="$(ISOLINUX)**" />
|
||||
<_IsoFile Include="$(SyslinuxPath)core\isolinux.bin" />
|
||||
<_IsoFile Include="$(SyslinuxPath)com32\elflink\ldlinux\ldlinux.c32" />
|
||||
<_IsoFile Include="$(SyslinuxPath)com32\lib\libcom32.c32" />
|
||||
<_IsoFile Include="$(SyslinuxPath)com32\mboot\mboot.c32" />
|
||||
<_IsoFile Include="$(BinFile)" />
|
||||
</ItemGroup>
|
||||
|
||||
<RemoveDir Directories="$(IntermediateIsoDirectory)" />
|
||||
<MakeDir Directories="$(IntermediateIsoDirectory)" />
|
||||
|
||||
<Copy SourceFiles="@(_ISOLINUX);$(BinFile)"
|
||||
<Copy SourceFiles="@(_IsoFile)"
|
||||
DestinationFolder="$(IntermediateIsoDirectory)" />
|
||||
|
||||
<CreateSyslinuxConfig IsoDirectory="$(IntermediateIsoDirectory)"
|
||||
<CreateSyslinuxConfig TargetDirectory="$(IntermediateIsoDirectory)"
|
||||
BinName="$([System.IO.Path]::GetFileName('$(BinFile)'))" />
|
||||
|
||||
<MakeIso IsoDirectory="$(IntermediateIsoDirectory)"
|
||||
|
|
@ -278,6 +287,65 @@
|
|||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
TODO: When this is an SDK, rename to Publish and remove BeforeTargets and the PropertyGroup.
|
||||
-->
|
||||
<Target Name="BootablePublish"
|
||||
BeforeTargets="Publish"
|
||||
DependsOnTargets="Build">
|
||||
|
||||
<PropertyGroup>
|
||||
<IsPublishable>False</IsPublishable>
|
||||
</PropertyGroup>
|
||||
|
||||
<Error Condition="'$(PublishType)' == ''" Text="No publish type specified!" />
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="IsoPublish"
|
||||
AfterTargets="Publish"
|
||||
Condition="'$(PublishType)' == 'ISO'">
|
||||
|
||||
<Error Condition="'$(IsoPublishOutputPath)' == ''" Text="No ISO publish output path specified!" />
|
||||
<Error Condition="'$(Deployment)' != 'ISO'" Text="Deployment type should be ISO!" />
|
||||
|
||||
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(IsoPublishOutputPath)'))" />
|
||||
<Copy SourceFiles="$(IsoFile)" DestinationFiles="$(IsoPublishOutputPath)" />
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="UsbPublish"
|
||||
AfterTargets="Publish"
|
||||
Condition="'$(PublishType)' == 'USB'">
|
||||
|
||||
<Error Condition="'$(UsbPublishDrive)' == ''" Text="No USB drive specified!" />
|
||||
<Error Condition="'$(Deployment)' != 'ISO'" Text="Deployment type should be ISO!" />
|
||||
<Error Condition="'$(OS)' != 'Windows_NT'" Text="USB publish only works on Windows!" />
|
||||
|
||||
<PropertyGroup>
|
||||
<UsbPublishFormatDrive Condition="'$(UsbPublishFormatDrive)' == ''">False</UsbPublishFormatDrive>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_UsbFile Include="$(SyslinuxPath)com32\elflink\ldlinux\ldlinux.c32" />
|
||||
<_UsbFile Include="$(SyslinuxPath)com32\lib\libcom32.c32" />
|
||||
<_UsbFile Include="$(SyslinuxPath)com32\mboot\mboot.c32" />
|
||||
<_UsbFile Include="$(BinFile)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="@(_UsbFile)"
|
||||
DestinationFolder="$(UsbPublishDrive)" />
|
||||
|
||||
<CreateSyslinuxConfig TargetDirectory="$(UsbPublishDrive)"
|
||||
BinName="$([System.IO.Path]::GetFileName('$(BinFile)'))" />
|
||||
|
||||
<CreateMbr TargetDrive="$(UsbPublishDrive)"
|
||||
FormatDrive="$(UsbPublishFormatDrive)"
|
||||
ToolPath="$(SyslinuxToolPath)"
|
||||
ToolExe="$(SyslinuxToolExe)" />
|
||||
|
||||
</Target>
|
||||
|
||||
<PropertyGroup>
|
||||
<CosmosDesignTimeTargetsPath Condition="'$(CosmosDesignTimeTargetsPath)'==''">$(MSBuildExtensionsPath)\Cosmos\Cosmos.DesignTime.targets</CosmosDesignTimeTargetsPath>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
BIN
source/Cosmos.Build.Tasks/tools/syslinux/bios/core/pxelinux.0
Normal file
BIN
source/Cosmos.Build.Tasks/tools/syslinux/bios/core/pxelinux.0
Normal file
Binary file not shown.
BIN
source/Cosmos.Build.Tasks/tools/syslinux/bios/core/pxelinux.bin
Normal file
BIN
source/Cosmos.Build.Tasks/tools/syslinux/bios/core/pxelinux.bin
Normal file
Binary file not shown.
BIN
source/Cosmos.Build.Tasks/tools/syslinux/win/syslinux.exe
Normal file
BIN
source/Cosmos.Build.Tasks/tools/syslinux/win/syslinux.exe
Normal file
Binary file not shown.
Loading…
Reference in a new issue