-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.bat
115 lines (85 loc) · 2.58 KB
/
build.bat
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
@echo off
rem Build batch file for Piscos OS
rem Author: Tishion (tishion#163.com)
rem 2016-03-26 11:58:38
set RUN=%~1%
echo %RUN%
rem change work directory to build folder
set PROJ_ROOT=%~dp0
set FASM_PATH=%PROJ_ROOT%tools\Flat Assembler\FASM.EXE
set SRC_ROOT=%PROJ_ROOT%src\
set SRC_APPS=%SRC_ROOT%apps\
set OUT_ROOT=%PROJ_ROOT%out\
set IMG_ROOT=%PROJ_ROOT%image\
set IMG_PATH=%IMG_ROOT%piscisos.img
set BOCHS_SCRIPT=%IMG_ROOT%bochsrc.bxrc
set OUT_APPS=%OUT_ROOT%bin\
set MTOOL_ROOT=%PROJ_ROOT%tools\mtools\
cd /d %PROJ_ROOT%
rem create output folders
if not exist "%OUT_ROOT%" mkdir "%OUT_ROOT%"
if not exist "%OUT_APPS%" mkdir "%OUT_APPS%"
if not exist "%IMG_ROOT%" mkdir "%IMG_ROOT%"
rem build bootsector file
echo ====== Building bootsector... ======
call "%FASM_PATH%" "%SRC_ROOT%bootsector\bootsect.asm" -s "%OUT_ROOT%bootsector.sym" "%OUT_ROOT%bootsector"
if not %errorlevel% == 0 (
goto _l_end
)
echo.
rem build kernel file
echo ====== Building pkernel... ======
call "%FASM_PATH%" "%SRC_ROOT%kernel\pkernel.asm" -s "%OUT_ROOT%pkernel.sym" "%OUT_ROOT%pkernel.bin"
if not %errorlevel% == 0 (
goto _l_end
)
echo.
rem build shell file
echo ====== Building shell... ======
call "%FASM_PATH%" "%SRC_ROOT%shell\shell.asm" -s "%OUT_ROOT%shell.sym" "%OUT_ROOT%shell"
if not %errorlevel% == 0 (
goto _l_end
)
echo.
rem build apps
echo ====== Building applications... ======
for /R "%SRC_APPS%" %%i in (*.asm) do (
echo +Building %%i
call "%FASM_PATH%" "%%i" -s "%OUT_APPS%%%~ni.sym" "%OUT_APPS%%%~ni"
)
echo.
echo ====== Burning OS image... ======
echo +Creating image file with bootsector...
"%MTOOL_ROOT%mformat.exe" -f 1440 -v PiscisOSVOL -B "%OUT_ROOT%bootsector" -C -i "%IMG_PATH%" ::
if not %errorlevel% == 0 (
goto _l_end
)
echo +Copying perkenel.bin to image file system...
"%MTOOL_ROOT%mcopy.exe" -i "%IMG_PATH%" "%OUT_ROOT%pkernel.bin" ::
if not %errorlevel% == 0 (
goto _l_end
)
echo +Copying shell to image file system...
"%MTOOL_ROOT%mcopy.exe" -i "%IMG_PATH%" "%OUT_ROOT%shell" ::
if not %errorlevel% == 0 (
goto _l_end
)
echo +Creating bin folder in image file system...
"%MTOOL_ROOT%mmd.exe" -i "%IMG_PATH%" ::bin
if not %errorlevel% == 0 (
goto _l_end
)
echo +Copying all applications to image file system...
"%MTOOL_ROOT%mcopy.exe" -i "%IMG_PATH%" "%OUT_ROOT%bin\*" ::bin
if not %errorlevel% == 0 (
goto _l_end
)
echo Build and burn done successfully!
echo Output floppy image file: %IMG_PATH%
echo +Creating bochs script...
echo floppya: type=1_44, 1_44="%IMG_PATH%", status=inserted, write_protected=1 > %BOCHS_SCRIPT%
echo Done!
if "%RUN%" == "-run" (
%BOCHS_SCRIPT%
)
:_l_end