`meson.build` rewritten with DRY principle. `deploy.sh` added, which deploys the image on a installation USB stick borrowed from another project. Image name aligned with the installer's expectations.
175 lines
3.8 KiB
Meson
175 lines
3.8 KiB
Meson
project(
|
|
'freywaros',
|
|
'c',
|
|
default_options: [
|
|
'warning_level=2',
|
|
'c_std=c11',
|
|
],
|
|
version: '0.1.0',
|
|
)
|
|
|
|
run_target(
|
|
'compdb',
|
|
command: ['ninja', '-C', meson.project_build_root(), '-t', 'compdb'],
|
|
)
|
|
|
|
nasm = find_program('nasm')
|
|
|
|
custom_target(
|
|
'boot',
|
|
input: 'src/mbr.asm',
|
|
output: 'mbr.bin',
|
|
command: [nasm, '-f', 'bin', '-l', 'mbr.lst', '@INPUT@', '-o', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
custom_target(
|
|
'bootloader',
|
|
input: 'src/bootloader.asm',
|
|
output: 'bootloader.bin',
|
|
command: [nasm, '-f', 'bin', '-l', 'bootloader.lst', '@INPUT@', '-o', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
kernel_entry_o = custom_target(
|
|
'kernel_entry',
|
|
input: 'src/kernel/kernel_entry.asm',
|
|
output: 'kernel_entry.o',
|
|
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
|
|
)
|
|
|
|
timer_o = custom_target(
|
|
'timer',
|
|
input: 'src/kernel/timer.asm',
|
|
output: 'timer.o',
|
|
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
|
|
)
|
|
|
|
process_o = custom_target(
|
|
'process',
|
|
input: 'src/kernel/process.asm',
|
|
output: 'process.o',
|
|
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
|
|
)
|
|
|
|
syscall_o = custom_target(
|
|
'syscall',
|
|
input: 'src/kernel/syscall.asm',
|
|
output: 'syscall.o',
|
|
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
|
|
)
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
lib_sources = files([
|
|
'src/lib/memory.c',
|
|
'src/lib/string.c',
|
|
])
|
|
|
|
kernel_sources = files([
|
|
'src/kernel/ata.c',
|
|
'src/kernel/fat16.c',
|
|
'src/kernel/fs.c',
|
|
'src/kernel/gdt.c',
|
|
'src/kernel/hid-keyboard.c',
|
|
'src/kernel/idt.c',
|
|
'src/kernel/kernel.c',
|
|
'src/kernel/log.c',
|
|
'src/kernel/memory.c',
|
|
'src/kernel/nvme.c',
|
|
'src/kernel/panic.c',
|
|
'src/kernel/path.c',
|
|
'src/kernel/pci.c',
|
|
'src/kernel/pic.c',
|
|
'src/kernel/pipe.c',
|
|
'src/kernel/process.c',
|
|
'src/kernel/ps2-keyboard.c',
|
|
'src/kernel/syscall.c',
|
|
'src/kernel/timer.c',
|
|
'src/kernel/tss.c',
|
|
'src/kernel/usb.c',
|
|
'src/kernel/vga.c',
|
|
'src/kernel/xhci.c',
|
|
])
|
|
|
|
c_args = [
|
|
'-ffreestanding',
|
|
'-nostdlib',
|
|
'-nostartfiles',
|
|
'-mno-red-zone',
|
|
'-mgeneral-regs-only',
|
|
'-fno-stack-protector',
|
|
'-DVERSION="' + meson.project_version() + '"',
|
|
]
|
|
|
|
kernel_elf = executable(
|
|
'kernel.elf',
|
|
sources: [kernel_entry_o, timer_o, process_o, syscall_o, lib_sources, kernel_sources],
|
|
c_args: [
|
|
c_args,
|
|
'-mcmodel=kernel',
|
|
'-Wno-unused-command-line-argument',
|
|
'-Wconversion',
|
|
'-DKERNEL="yes"',
|
|
],
|
|
link_args: [
|
|
'-T', meson.project_source_root() / 'src/kernel/linker.ld',
|
|
'-nostdlib',
|
|
],
|
|
link_depends: 'src/kernel/linker.ld',
|
|
)
|
|
|
|
custom_target(
|
|
'kernel_bin',
|
|
input: kernel_elf,
|
|
output: 'kernel.bin',
|
|
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
foreach app : ['terminal', 'shell', 'echo', 'ls', 'cat', 'cp', 'mkdir', 'rm', 'wc']
|
|
start = custom_target(
|
|
f'@app@_start',
|
|
input: 'src/user/start.asm',
|
|
output: f'@app@_start.o',
|
|
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
|
)
|
|
|
|
syscall = custom_target(
|
|
f'@app@_syscall',
|
|
input: 'src/user/syscall.asm',
|
|
output: f'@app@_syscall.o',
|
|
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
|
)
|
|
|
|
elf = executable(
|
|
f'@app@.elf',
|
|
sources: [start, syscall, lib_sources, f'src/user/app/@app@/@app@.c'],
|
|
c_args: [
|
|
c_args,
|
|
'-mcmodel=large',
|
|
],
|
|
link_args: [
|
|
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
|
'-nostdlib',
|
|
],
|
|
link_depends: 'src/user/linker.ld',
|
|
)
|
|
|
|
elf_data = custom_target(
|
|
f'@app@_data.elf',
|
|
input: elf,
|
|
output: f'@app@_data.elf',
|
|
command: ['objcopy', '--set-section-flags', '.data=alloc,load,contents', '@INPUT@', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
custom_target(
|
|
app,
|
|
input: elf_data,
|
|
output: app,
|
|
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
endforeach
|