Skip to content

Commit

Permalink
Merge pull request #2988 from MEMESCOEP/BIOS-UEFI-Toggle
Browse files Browse the repository at this point in the history
Add UEFI toggle to project properties
  • Loading branch information
quajak committed Mar 15, 2024
2 parents 24aa0eb + bdaa724 commit 51b1287
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
22 changes: 17 additions & 5 deletions source/Cosmos.Build.Tasks/MakeIso.cs
Expand Up @@ -14,6 +14,9 @@ public class MakeIso : ToolTask
[Required]
public string OutputFile { get; set; }

[Required]
public bool UseUEFI { get; set; }

protected override string ToolName => IsWindows() ? "xorriso.exe" : "xorriso";

protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
Expand Down Expand Up @@ -67,15 +70,24 @@ protected override string GenerateCommandLineCommands()
xBuilder.AppendSwitch("-l");
xBuilder.AppendSwitch("-allow-lowercase");
xBuilder.AppendSwitchIfNotNull("-o ", OutputFile);
xBuilder.AppendSwitch(" -b boot/limine-bios-cd.bin");
xBuilder.AppendSwitch("-b boot/limine-bios-cd.bin");
xBuilder.AppendSwitch("-no-emul-boot");
xBuilder.AppendSwitch("-boot-load-size 4");
xBuilder.AppendSwitch("-boot-info-table");
xBuilder.AppendSwitch("--efi-boot boot/limine-uefi-cd.bin");
xBuilder.AppendSwitch("-efi-boot-part");
xBuilder.AppendSwitch("--efi-boot-image");
xBuilder.AppendFileNameIfNotNull(IsoDirectory.TrimEnd('\\', '/'));

if (UseUEFI)
{
Log.LogMessage(MessageImportance.High, "UEFI enabled.");
xBuilder.AppendSwitch("--efi-boot boot/limine-uefi-cd.bin");
xBuilder.AppendSwitch("-efi-boot-part");
xBuilder.AppendSwitch("--efi-boot-image");
}
else
{
Log.LogMessage(MessageImportance.High, "UEFI switches will not be added.");
}

xBuilder.AppendFileNameIfNotNull(IsoDirectory.TrimEnd('\\', '/'));
Log.LogMessage(MessageImportance.High, xBuilder.ToString());

return xBuilder.ToString();
Expand Down
17 changes: 10 additions & 7 deletions source/Cosmos.Build.Tasks/build/Cosmos.Build.targets
Expand Up @@ -84,6 +84,8 @@
<AllowComments Condition="'$(AllowComments)' == ''">False</AllowComments>

<OptimizationLevel Condition="'$(OptimizationLevel)' == ''">1</OptimizationLevel>

<UseUEFI Condition="'$(UseUEFI)' == ''">True</UseUEFI>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -227,7 +229,7 @@
OutputFormat="$(BinFormat)"
ToolPath="$(NasmToolPath)"
ToolExe="$(NasmToolExe)"
OptimizationLevel="$(OptimizationLevel)"/>
OptimizationLevel="$(OptimizationLevel)"/>

</Target>

Expand Down Expand Up @@ -350,7 +352,7 @@
</ItemGroup>

<ItemGroup>
<_IsoFile Include="$(LiminePath)boot\limine-uefi-cd.bin" />
<_IsoFile Include="$(LiminePath)boot\limine-uefi-cd.bin" Condition="'$(UseUEFI)' == 'True'" />
<_IsoFile Include="$(LiminePath)boot\limine-bios-cd.bin" />
<_IsoFile Include="$(LiminePath)boot\limine-bios.sys" />
<_IsoFile Include="$(LiminePath)boot\liminewp.bmp" />
Expand All @@ -368,10 +370,10 @@
<Copy SourceFiles="@(_IsoFile)"
DestinationFolder="$(IntermediateIsoDirectory)\boot\" />

<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTAA64.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTIA32.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTRISCV64.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTX64.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTAA64.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" Condition="'$(UseUEFI)' == 'True'" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTIA32.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" Condition="'$(UseUEFI)' == 'True'" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTRISCV64.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" Condition="'$(UseUEFI)' == 'True'" />
<Copy SourceFiles="$(LiminePath)EFI\boot\BOOTX64.EFI" DestinationFolder="$(IntermediateIsoDirectory)\EFI\boot\" Condition="'$(UseUEFI)' == 'True'" />

<Copy SourceFiles="@(_IsoCustomFiles)"
DestinationFolder="$(IntermediateIsoDirectory)%(RecursiveDir)"
Expand All @@ -393,7 +395,8 @@
<MakeIso IsoDirectory="$(IntermediateIsoDirectory)"
OutputFile="$(IsoFile)"
ToolPath="$(XorrisoToolPath)"
ToolExe="$(XorrisoToolExe)" />
ToolExe="$(XorrisoToolExe)"
UseUEFI="$(UseUEFI)" />
</Target>

<!--
Expand Down
Expand Up @@ -74,9 +74,15 @@
Category="Compile">
</BoolProperty>

<BoolProperty Name="UseUEFI"
DisplayName="Compile with UEFI"
Description="Your OS will be compiled with UEFI support, which allows for booting on non-legacy systems. Enabling this may break legacy booting, and will cause tools such as Rufus and balenaEtcher to see your ISO as unbootable or missing a filesystem."
Category="Compile">
</BoolProperty>

<EnumProperty Name="OptimizationLevel"
DisplayName="Optimization Level"
Description="Choose the optimization level that you want to use."
Description="Choose the optimization level that you want to use."
Category="Compile">
<EnumValue Name="0" DisplayName="O0"/>
<EnumValue Name="1" DisplayName="O1"/>
Expand All @@ -88,7 +94,7 @@
DisplayName="Bootloader Timeout"
Description="The time to wait (in seconds) before the bootloader automatically starts the kernel."
Category="Compile"
Default="0">
Default="0">
</StringProperty>

<StringProperty Name="VBEResolution"
Expand Down

0 comments on commit 51b1287

Please sign in to comment.