Add meson build and run scripts

master^2
Jessica Creighton 5 years ago
parent a07c29adf4
commit 1bbcacb90e

@ -0,0 +1,94 @@
project('Syncboot', 'c')
sources = [ \
'src/main.c', 'src/gfx.c', 'src/bootloader.c', 'src/memory.c',
'gnu-efi/lib/misc.c', 'gnu-efi/lib/print.c', 'gnu-efi/lib/smbios.c',
'gnu-efi/lib/sread.c', 'gnu-efi/lib/str.c', 'gnu-efi/lib/boxdraw.c',
'gnu-efi/lib/cmdline.c', 'gnu-efi/lib/console.c', 'gnu-efi/lib/crc.c',
'gnu-efi/lib/data.c', 'gnu-efi/lib/debug.c', 'gnu-efi/lib/dpath.c',
'gnu-efi/lib/error.c', 'gnu-efi/lib/event.c', 'gnu-efi/lib/exit.c',
'gnu-efi/lib/guid.c', 'gnu-efi/lib/hand.c', 'gnu-efi/lib/hw.c',
'gnu-efi/lib/init.c', 'gnu-efi/lib/lock.c', 'gnu-efi/lib/x86_64/callwrap.c',
'gnu-efi/lib/x86_64/efi_stub.S', 'gnu-efi/lib/x86_64/initplat.c',
'gnu-efi/lib/x86_64/math.c', 'gnu-efi/lib/x86_64/setjmp.S',
'gnu-efi/lib/runtime/efirtlib.c', 'gnu-efi/lib/runtime/rtdata.c',
'gnu-efi/lib/runtime/rtlock.c', 'gnu-efi/lib/runtime/rtstr.c',
'gnu-efi/lib/runtime/vm.c'
]
include_dirs = [
'inc',
'gnu-efi/inc',
'gnu-efi/inc/x86_64',
'gnu-efi/inc/protocol',
'gnu-efi/lib'
]
c_arguments = [
'-ffreestanding', '-fpic', '-fshort-wchar', '-fno-stack-protector', '-fno-stack-check',
'-fno-strict-aliasing', '-fno-merge-all-constants', '-m64', '-mno-red-zone',
'-DGNU_EFI_USE_MS_ABI', '-maccumulate-outgoing-args', '--std=c11',
'-Og', '-g3', '-Wall', '-Wextra', '-Wdouble-promotion', '-Wpedantic', '-fmessage-length=0', '-MMD', '-MP'
]
# f'-Wa,-adghlmns={line}.out',
# f'-MT{line}.o',
link_arguments = [
'-nostdlib', '-Wl,--warn-common', '-Wl,--no-undefined', '-Wl,-dll',
'-Wl,--subsystem,10', '-e', 'efi_main', '-Wl,-Map=output.map'
]
lib = shared_library('BOOTX64',
sources,
include_directories: include_dirs,
c_args:c_arguments,
link_args: link_arguments,
name_prefix: '',
name_suffix: 'EFI',
)
meson.add_install_script('scripts/install.py')
objcopy = find_program('objcopy')
split_debug = custom_target(
'split_debug',
input: lib,
output: 'BOOTX64.debug',
build_by_default: true,
command: [
objcopy, '--only-keep-debug', '@INPUT@', '@OUTPUT@'
],
depends: [
lib
]
)
strip_debug = run_target(
'strip_debug',
command: [
objcopy, '--strip-debug', lib
]
)
link_debug = run_target(
'link_debug',
command: [
objcopy, '--add-gnu-debuglink=' + split_debug.full_path(), lib
],
depends : [
split_debug
]
)
run_target(
'run',
command: [
'scripts/run.py'
]
)

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import os
from pathlib import Path
from shutil import copyfile
build_root = Path(os.environ['MESON_BUILD_ROOT'])
source_root = Path(os.environ['MESON_SOURCE_ROOT'])
install_dir = build_root / 'sys'
target_dir = install_dir / 'image/efi/boot'
os.makedirs(target_dir, exist_ok=True)
ovmf_file = 'OVMF_X64.fd'
copyfile(source_root / ovmf_file, install_dir / ovmf_file)
efi_file = 'BOOTX64.EFI'
copyfile(build_root / efi_file, target_dir / efi_file)

@ -0,0 +1,6 @@
#!/usr/bin/env python3
import os
from pathlib import Path
os.chdir(Path(os.environ['MESON_BUILD_ROOT']) / 'sys')
os.system(r'qemu-system-x86_64 -net none -vga std -serial file:qemu.log -parallel none -L . -bios OVMF_X64.fd -hda fat:rw:image -d int')
Loading…
Cancel
Save