Skip to content
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

Add UEFI toggle to project properties #2988

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 17 additions & 5 deletions source/Cosmos.Build.Tasks/MakeIso.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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