project('nrvn', ['c', 'nasm'], version : '0.1', default_options : [ 'warning_level=3', 'b_pie=false', 'b_staticpic=false' ]) if not meson.is_cross_build() error('must be invoked with "meson setup --cross-file=toolchain.txt"') endif fs = import('fs') linker_script = fs.copyfile('util/linker.ld') drive = custom_target(output: 'drive', command: ['util/build_disk.sh', meson.current_source_dir() / 'disk', '@OUTPUT@', '@PRIVATE_DIR@']) files = [ 'src/asm/boot.asm', 'src/asm/long.asm', 'src/nrvn.c', 'src/acpi.c', 'src/idt.c', 'src/mem.c', 'src/memory.c', 'src/pci.c', 'src/pic.c', 'src/ps2.c', 'src/ahci.c', 'src/vga.c', 'src/fs/gpt.c', linker_script, drive ] ld_args = [ '-ffreestanding', '-nostdlib', '-T', linker_script.full_path() ] kernel = executable('nrvn', files, c_args: ['-ffreestanding'], nasm_args: ['-felf64'], link_args: ld_args, include_directories: 'include/') iso = custom_target('iso', input: [fs.copyfile('util/grub.cfg'), kernel], output: 'nrvn.iso', command: ['util/build_iso.sh', '@PRIVATE_DIR@', '@INPUT@', '@OUTPUT@']) qemu = find_program('qemu') qemu_args = [ '-m', get_option('ram'), '-boot', 'd', '-cdrom', iso, '-drive', 'id=disk,format=raw,file=@0@,if=none'.format(drive.full_path()), '-device', 'ahci,id=ahci', '-device', 'ide-hd,drive=disk,bus=ahci.0' ] qemu_kvm = [] if get_option('kvm') qemu_kvm += '-enable-kvm' endif run_target('run', command: [qemu, qemu_args, qemu_kvm]) run_target('run-gdb', command: [qemu, qemu_args, '-s', '-S'])