Обновление конфигурации сборки

This commit is contained in:
Aren Elchinyan 2023-09-30 22:19:09 +03:00
parent 3d9bcb19bc
commit 7a232105b8
5 changed files with 28 additions and 110 deletions

21
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: CI BUILD
on:
push:
branches-ignore: [ "pages" ]
pull_request:
branches-ignore: [ "pages" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install Python3
run: sudo apt install python3
- name: build
run: python3 build.py
- name: check
run: ls -la

7
.gitignore vendored
View File

@ -1,5 +1,8 @@
kernel.elf
mseos.hdd
*.elf
*.hdd
*.iso
*.0
bin/
limine/
ovmf/

View File

@ -118,4 +118,4 @@ if __name__ == "__main__":
compile_all()
create_hdd("mseos")
os.system("qemu-system-x86_64 -M q35 -m 8G -smp 8 -bios ovmf/OVMF.fd -hda mseos.hdd")
print("qemu-system-x86_64 -M q35 -m 8G -smp 8 -bios ovmf/OVMF.fd -hda mseos.hdd")

106
build.sh
View File

@ -1,106 +0,0 @@
#!/bin/bash
CC="g++"
ARCH_FLAGS="-m64 -march=x86-64 -mabi=sysv -mno-80387 -mno-red-zone -mcmodel=kernel -MMD -MP"
WARN_FLAGS="-Wall -Wextra"
STANDART_FLAGS="-std=gnu11"
PROTECT_FLAGS="-O0 -pipe -ffreestanding -fno-stack-protector -fno-lto -fno-stack-check -fno-PIC -fno-PIE"
CHARSET_FLAGS="-finput-charset=UTF-8 -fexec-charset=cp1251"
LIBS_FLAGS="-Ilimine"
find_files() {
file_list=()
directory=$1
extensions=$2
while IFS= read -r -d '' file; do
file_list+=("$file")
done < <(find "$directory" -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.s" \) -print0)
printf '%s\n' "${file_list[@]}"
}
compile() {
file=$1
output_file="${file/\//-}"
obj_file="bin/${output_file}.o"
cmd="$CC $WARN_FLAGS $PROTECT_FLAGS $ARCH_FLAGS $CHARSET_FLAGS $LIBS_FLAGS -c $file -o $obj_file"
echo "$cmd"
eval "$cmd"
echo "$obj_file"
}
compile_all() {
file_list=$(find_files "kernel/" ".c .cpp .s")
IFS=$'\n' read -rd '' -a file_array <<<"$file_list"
for file in "${file_array[@]}"; do
compile "$file"
done
while [[ $(grep -o "bin/.*\.o" <<<"${results[*]}") ]]; do
sleep 1
done
cmd="ld -nostdlib -static -m elf_x86_64 -z max-page-size=0x1000 -T configs/linker.ld -o kernel.elf ${results[*]}"
echo "$cmd"
eval "$cmd"
}
check_limine() {
if [ ! -d "limine" ]; then
git clone "https://github.com/limine-bootloader/limine.git" --branch=v5.x-branch-binary --depth=1
else
pushd "limine"
git pull
popd
fi
pushd "limine"
make
popd
}
check_tools() {
required_tools=("g++" "xorriso" "make" "mtools")
missing_tools=()
for tool in "${required_tools[@]}"; do
if ! command -v "$tool" >/dev/null 2>&1; then
missing_tools+=("$tool")
fi
done
if (( ${#missing_tools[@]} > 0 )); then
sudo apt install "${missing_tools[@]}"
fi
}
create_iso() {
IMAGE_NAME=$1
rm -rf "iso_root"
mkdir -p "iso_root"
cp -v "boot/CYRILL2.F16" "iso_root/"
cp -v "kernel.elf" "configs/limine.cfg" "limine/limine-bios.sys" "limine/limine-bios-cd.bin" "limine/limine-uefi-cd.bin" "iso_root/"
mkdir -p "iso_root/EFI/BOOT"
cp -v "limine/BOOTX64.EFI" "iso_root/EFI/BOOT/"
cp -v "limine/BOOTIA32.EFI" "iso_root/EFI/BOOT/"
xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label iso_root -o "${IMAGE_NAME}.iso"
./limine/limine bios-install "${IMAGE_NAME}.iso"
rm -rf "iso_root"
}
create_hdd() {
IMAGE_NAME=$1
rm -f "${IMAGE_NAME}.hdd"
dd if=/dev/zero bs=1M count=0 seek=64 of="${IMAGE_NAME}.hdd"
sgdisk "${IMAGE_NAME}.hdd" -n 1:2048 -t 1:ef00
./limine/limine bios-install "${IMAGE_NAME}.hdd"
mformat -i "${IMAGE_NAME}.hdd@@1M"
mmd -i "${IMAGE_NAME}.hdd@@1M" "::/EFI" "::/EFI/BOOT"
mcopy -i "${IMAGE_NAME}.hdd@@1M" "kernel.elf" "configs/limine.cfg" "boot/CYRILL2.F16" "limine/limine-bios.sys" "::/"
mcopy -i "${IMAGE_NAME}.hdd@@1M" "limine/BOOTX64.EFI" "limine/BOOTIA32.EFI" "::/EFI/BOOT"
}
check_limine
check_tools
compile_all
create_iso "MSEOS"
create_hdd "MSEOS"

View File

@ -1,6 +1,6 @@
TIMEOUT=5
DEFAULT_ENTRY=0
INTERFACE_BRANDING=By Aren Elchinyan [Арен Елчинян]1234
INTERFACE_BRANDING=By Aren Elchinyan
TERM_FONT=boot:///CYRILL2.F16
TERM_FONT_SIZE=8x16