-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
126 lines (107 loc) · 4.59 KB
/
Copy pathbuild.bat
File metadata and controls
126 lines (107 loc) · 4.59 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
@echo off
setlocal enabledelayedexpansion
:: ============================================================
:: SELEÇÃO DE IDIOMA / LANGUAGE SELECTION
:: ============================================================
echo Select the build language / Selecione o idioma do build:
echo [1] Portugues (BR)
echo [2] English (US)
echo.
choice /c 12 /n /m "Choose/Escolha (1 or 2): "
if errorlevel 2 (set LANG=EN) else (set LANG=PT)
cls
echo ============================================================
echo LuusOS Build System — Windows PC
echo ============================================================
echo.
:: Caminhos dos executáveis
set "BIN_DIR=%~dp0bin"
set "CC=%BIN_DIR%\i686-elf-gcc.exe"
set "AS=%BIN_DIR%\i686-elf-as.exe"
set "LD=%BIN_DIR%\i686-elf-ld.exe"
:: ============================================================
:: VERIFICAÇÃO DE TOOLCHAIN (DOWNLOAD ÚNICO)
:: ============================================================
if not exist "%BIN_DIR%" mkdir "%BIN_DIR%"
:: Verifica se o compilador já existe. Se existir, pula todo o bloco de download.
if not exist "%CC%" (
if "!LANG!"=="PT" (echo [INFO] Compilador nao encontrado. Iniciando download unico...) else (echo [INFO] Compiler not found. Starting one-time download...)
if not exist toolchain_tmp mkdir toolchain_tmp
:: Download
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://github.com/lordmilko/i686-elf-tools/releases/download/7.1.0/i686-elf-tools-windows.zip' -OutFile 'toolchain_tmp\toolchain.zip'"
if exist toolchain_tmp\toolchain.zip (
:: Extrai e organiza na pasta bin
powershell -Command "Expand-Archive -Path 'toolchain_tmp\toolchain.zip' -DestinationPath 'toolchain_tmp\extracted' -Force"
xcopy /s /y "toolchain_tmp\extracted\*" "%BIN_DIR%\" >nul
rmdir /s /q toolchain_tmp
echo [OK] Ferramentas instaladas com sucesso.
) else (
echo [ERRO] Falha no download. Verifique a conexao.
pause & exit /b 1
)
) else (
echo [INFO] Toolchain ja instalada. Pulando download.
)
:: ============================================================
:: MENU E COMPILAÇÃO (Restante do script mantido)
:: ============================================================
:setup_menu
if "!LANG!"=="PT" (
echo Escolha o tipo de compilacao:
echo [1] Apenas Kernel (luusos.bin)
echo [2] Kernel + Imagem ISO
echo.
choice /c 12 /n /m "Opcao (1 ou 2): "
) else (
echo Choose build target:
echo [1] Kernel Only (luusos.bin)
echo [2] Kernel + ISO Image
echo.
choice /c 12 /n /m "Choice (1 or 2): "
)
set TARGET=bin
if errorlevel 2 set TARGET=iso
echo.
echo ============================================================
echo [INFO] Alvo selecionado: !TARGET!
echo ============================================================
echo.
call :compile src/boot.s boot.o -c
call :compile src/gdt_flush.s gdt_flush.o -c
call :compile src/isr.s isr.o -c
call :compile src/gdt.c gdt.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/idt.c idt.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/kernel.c kernel.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/keyboard.c keyboard.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/string.c string.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/shell.c shell.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/sound.c sound.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
call :compile src/timer.c timer.o "-c -ffreestanding -O2 -Wall -Wextra -std=gnu99"
"%LD%" -m elf_i386 -T linker.ld -o luusos.bin boot.o gdt_flush.o isr.o gdt.o idt.o kernel.o keyboard.o string.o shell.o sound.o timer.o
if errorlevel 1 goto :error
if /i "%TARGET%"=="iso" goto :make_iso
goto :done
:compile
if "%~2"=="boot.o" (set "CMD=%AS% --32") else if "%~2"=="gdt_flush.o" (set "CMD=%AS% --32") else if "%~2"=="isr.o" (set "CMD=%AS% --32") else (set "CMD=%CC% -m32")
echo Compilando %~1...
%CMD% %~3 %~1 -o %~2
if errorlevel 1 goto :error
exit /b
:make_iso
where grub-mkrescue >nul 2>&1
if errorlevel 1 (echo [AVISO] grub-mkrescue nao encontrado. & goto :done)
if exist isodir rmdir /s /q isodir
mkdir isodir\boot\grub
copy /y luusos.bin isodir\boot\luusos.bin >nul
copy /y grub.cfg isodir\boot\grub\grub.cfg >nul
grub-mkrescue -o luusos.iso isodir >nul 2>&1
echo [OK] luusos.iso gerada.
if exist isodir rmdir /s /q isodir
goto :done
:done
del *.o >nul 2>&1
echo Build concluído com sucesso!
pause & exit /b 0
:error
echo [ERRO] Falha no processo.
pause & exit /b 1