Skip to content

Commit

Permalink
Merge pull request CosmosOS#2485 from MEMESCOEP/master
Browse files Browse the repository at this point in the history
Add option to set GRUB boot timeout
  • Loading branch information
quajak authored Nov 27, 2022
2 parents fd477ea + 6d179c4 commit 3a239ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
13 changes: 12 additions & 1 deletion source/Cosmos.Build.Tasks/CreateGrubConfig.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.IO;
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

Expand All @@ -16,6 +17,8 @@ public class CreateGrubConfig: Task
public string[] Modules { get; set; }

private string Indentation = " ";

public string Timeout { get; set; }

public override bool Execute()
{
Expand All @@ -30,14 +33,22 @@ public override bool Execute()

using (var xWriter = File.CreateText(Path.Combine(TargetDirectory + "/boot/grub/", "grub.cfg")))
{
xWriter.WriteLine("set timeout=0");
if (!String.IsNullOrWhiteSpace(Timeout) && !String.IsNullOrEmpty(Timeout))
{
xWriter.WriteLine("set timeout=" + Timeout);
}
else
{
xWriter.WriteLine("set timeout=0");
}
if (Modules != null)
{
foreach (var module in Modules)
{
xWriter.WriteLine($"insmod {module}");
}
}

xWriter.WriteLine();
xWriter.WriteLine("menuentry '" + xLabelName + "' {");
WriteIndentedLine(xWriter, "multiboot2 /boot/" + xBinName);
Expand Down
6 changes: 4 additions & 2 deletions source/Cosmos.Build.Tasks/build/Cosmos.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@

<CompileVBEMultiboot Condition="'$(CompileVBEMultiboot)' == ''">False</CompileVBEMultiboot>


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

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

</PropertyGroup>

Expand Down Expand Up @@ -383,10 +383,12 @@
<CreateGrubConfig TargetDirectory="$(IntermediateIsoDirectory)"
BinName="$([System.IO.Path]::GetFileName('$(BinGzFile)'))"
Modules="gzio"
Timeout="$(Timeout)"
Condition="'$(CompressionType)' == 'Gzip'" />

<CreateGrubConfig TargetDirectory="$(IntermediateIsoDirectory)"
BinName="$([System.IO.Path]::GetFileName('$(BinFile)'))"
Timeout="$(Timeout)"
Condition="'$(CompressionType)' == 'None'" />

<MakeIso IsoDirectory="$(IntermediateIsoDirectory)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@
<EnumValue Name="1" DisplayName="O1"/>
<EnumValue Name="2" DisplayName="O2"/>
<EnumValue Name="3" DisplayName="O3 (Unstable)"/>
<EnumValue Name="s" DisplayName="Os (Unstable)"/>
<EnumValue Name="fast" DisplayName="Ofast (Unstable)"/>
<EnumValue Name="s" DisplayName="Os (Unstable)"/>
<EnumValue Name="fast" DisplayName="Ofast (Unstable)"/>
</EnumProperty>

<StringProperty Name="Timeout"
DisplayName="GRUB Menu Timeout"
Description="The time to wait (in seconds) before the kernel is automatically started."
Category="Compile"
Default="0">
</StringProperty>

<StringProperty Name="VBEResolution"
DisplayName="VBE Resolution"
Description="Example format: 800x600x32"
Expand Down

0 comments on commit 3a239ec

Please sign in to comment.