-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.targets
62 lines (54 loc) · 2.91 KB
/
kernel.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<Project>
<ItemGroup>
<KernelCObj Include="@(KernelC->'build/obj/%(Filename).elf')"/>
<KernelAsmObj Include="@(KernelAsm->'build/obj/%(Filename).elf')"/>
<KernelObj Include="@(KernelCObj);@(KernelAsmObj)"/>
<OutputBin Include="build/bin/*.bin"/>
</ItemGroup>
<Target Name="Run" DependsOnTargets="Build">
<Message Text="Starting QEMU..." Importance="high"/>
<PropertyGroup Condition="$(Debug)=='true'">
<DebugArgs>-s -S</DebugArgs>
</PropertyGroup>
<Exec Command="qemu-system-i386 -hda "build/image.bin" $(DebugArgs)"/>
</Target>
<Target Name="Build" DependsOnTargets="CompileMBR;CompileVBR;LinkKernel" Outputs="build/image.bin">
<Message Text="Writing image..." Importance="high"/>
<Copy SourceFiles="image.bin" DestinationFolder="build"/>
<Exec Command="dotnet run --project ImageBurner/ImageBurner.csproj build/image.bin build/bin/mbr.bin build/bin/vbr.bin 10000 build/bin/kernel.bin"/>
</Target>
<Target Name="CompileMBR" Inputs="@(MBRSrc)" Outputs="build/bin/mbr.bin">
<Message Text="Compiling MBR..." Importance="high"/>
<Exec Command="nasm -f bin src/mbr.asm -Isrc/ -o build/bin/mbr.bin"/>
</Target>
<Target Name="CompileVBR" Inputs="@(VBRSrc)" Outputs="build/bin/vbr.bin">
<Message Text="Compiling VBR..." Importance="high"/>
<Exec Command="nasm -f bin src/loader/fat32header.asm -Isrc/ -o build/bin/vbr.bin"/>
</Target>
<Target Name="LinkKernel" DependsOnTargets="CompileKernelC;CompileKernelAsm" Inputs="@(KernelObj)" Outputs="build/bin/kernel.bin">
<Message Text="Linking kernel..." Importance="high"/>
<!-- "init.elf" должен быть первым в списке, поэтому добавляем его в начало, а потом удаляем повторы -->
<RemoveDuplicates Inputs="build/obj/init.elf;@(KernelObj)">
<Output TaskParameter="Filtered" ItemName="FilteredObj"/>
</RemoveDuplicates>
<PropertyGroup>
<LinkCmd>i686-elf-ld @(FilteredObj->'%(Fullpath)', ' ') $(LinkFlags)</LinkCmd>
</PropertyGroup>
<Exec Command="$(LinkCmd) -o build/bin/kernel.bin --oformat binary"/>
<Exec Command="$(LinkCmd) -o build/symbols.elf" Condition="$(Debug)=='true'"/>
</Target>
<Target Name="CompileKernelC" Inputs="@(KernelC)" Outputs="@(KernelCObj)">
<Message Text="Compiling C kenrel files..." Importance="high"/>
<PropertyGroup Condition="$(Debug)=='true'">
<DebugArgs>-g</DebugArgs>
</PropertyGroup>
<Exec Command="i686-elf-gcc $(CFlags) $(DebugArgs) -c %(KernelC.Identity) -o @(KernelC->'build/obj/%(Filename).elf'->'%(Identity)')"/>
</Target>
<Target Name="CompileKernelAsm" Inputs="@(KernelAsm)" Outputs="@(KernelAsmObj)">
<Message Text="Compiling ASM kernel files..." Importance="high"/>
<Exec Command="nasm %(KernelAsm.Identity) -g -f elf32 -Isrc/ -o @(KernelAsm->'build/obj/%(Filename).elf'->'%(Identity)')"/>
</Target>
<Target Name="Clean">
<Delete Files="@(KernelObj);@(OutputBin);build/symbols.elf;build/image.bin"/>
</Target>
</Project>