Improve installation process
`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.
This commit is contained in:
+52
-352
@@ -92,20 +92,25 @@ kernel_sources = files([
|
||||
'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: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-nostartfiles',
|
||||
'-mno-red-zone',
|
||||
'-mgeneral-regs-only',
|
||||
c_args,
|
||||
'-mcmodel=kernel',
|
||||
'-Wno-unused-command-line-argument',
|
||||
'-Wconversion',
|
||||
'-DKERNEL="yes"',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/kernel/linker.ld',
|
||||
@@ -122,353 +127,48 @@ custom_target(
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
terminal_start = custom_target(
|
||||
'terminal_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'terminal_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
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@'],
|
||||
)
|
||||
|
||||
terminal_syscall = custom_target(
|
||||
'terminal_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'terminal_syscall.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@'],
|
||||
)
|
||||
|
||||
terminal_elf = executable(
|
||||
'terminal.elf',
|
||||
sources: [terminal_start, terminal_syscall, lib_sources, 'src/user/app/terminal/terminal.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
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',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'terminal',
|
||||
input: terminal_elf,
|
||||
output: 'terminal',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
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,
|
||||
)
|
||||
|
||||
shell_start = custom_target(
|
||||
'shell_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'shell_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
shell_syscall = custom_target(
|
||||
'shell_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'shell_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
shell_elf = executable(
|
||||
'shell.elf',
|
||||
sources: [shell_start, shell_syscall, lib_sources, 'src/user/app/shell/shell.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'shell',
|
||||
input: shell_elf,
|
||||
output: 'shell',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
echo_start = custom_target(
|
||||
'echo_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'echo_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
echo_syscall = custom_target(
|
||||
'echo_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'echo_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
echo_elf = executable(
|
||||
'echo.elf',
|
||||
sources: [echo_start, echo_syscall, lib_sources, 'src/user/app/echo/echo.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'echo',
|
||||
input: echo_elf,
|
||||
output: 'echo',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
ls_start = custom_target(
|
||||
'ls_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'ls_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
ls_syscall = custom_target(
|
||||
'ls_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'ls_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
ls_elf = executable(
|
||||
'ls.elf',
|
||||
sources: [ls_start, ls_syscall, lib_sources, 'src/user/app/ls/ls.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'ls',
|
||||
input: ls_elf,
|
||||
output: 'ls',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
cat_start = custom_target(
|
||||
'cat_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'cat_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
cat_syscall = custom_target(
|
||||
'cat_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'cat_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
cat_elf = executable(
|
||||
'cat.elf',
|
||||
sources: [cat_start, cat_syscall, lib_sources, 'src/user/app/cat/cat.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'cat',
|
||||
input: cat_elf,
|
||||
output: 'cat',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
cp_start = custom_target(
|
||||
'cp_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'cp_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
cp_syscall = custom_target(
|
||||
'cp_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'cp_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
cp_elf = executable(
|
||||
'cp.elf',
|
||||
sources: [cp_start, cp_syscall, lib_sources, 'src/user/app/cp/cp.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'cp',
|
||||
input: cp_elf,
|
||||
output: 'cp',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
mkdir_start = custom_target(
|
||||
'mkdir_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'mkdir_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
mkdir_syscall = custom_target(
|
||||
'mkdir_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'mkdir_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
mkdir_elf = executable(
|
||||
'mkdir.elf',
|
||||
sources: [mkdir_start, mkdir_syscall, lib_sources, 'src/user/app/mkdir/mkdir.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'mkdir',
|
||||
input: mkdir_elf,
|
||||
output: 'mkdir',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
rm_start = custom_target(
|
||||
'rm_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'rm_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
rm_syscall = custom_target(
|
||||
'rm_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'rm_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
rm_elf = executable(
|
||||
'rm.elf',
|
||||
sources: [rm_start, rm_syscall, lib_sources, 'src/user/app/rm/rm.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'rm',
|
||||
input: rm_elf,
|
||||
output: 'rm',
|
||||
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
||||
build_by_default: true,
|
||||
)
|
||||
|
||||
wc_start = custom_target(
|
||||
'wc_start',
|
||||
input: 'src/user/start.asm',
|
||||
output: 'wc_start.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
wc_syscall = custom_target(
|
||||
'wc_syscall',
|
||||
input: 'src/user/syscall.asm',
|
||||
output: 'wc_syscall.o',
|
||||
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
||||
)
|
||||
|
||||
wc_elf = executable(
|
||||
'wc.elf',
|
||||
sources: [wc_start, wc_syscall, lib_sources, 'src/user/app/wc/wc.c'],
|
||||
c_args: [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-fno-stack-protector',
|
||||
'-mcmodel=large',
|
||||
'-DVERSION="' + meson.project_version() + '"',
|
||||
],
|
||||
link_args: [
|
||||
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
||||
'-nostdlib',
|
||||
],
|
||||
link_depends: 'src/user/linker.ld',
|
||||
)
|
||||
|
||||
custom_target(
|
||||
'wc',
|
||||
input: wc_elf,
|
||||
output: 'wc',
|
||||
command: ['objcopy', '-O', 'binary', '@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
|
||||
|
||||
Reference in New Issue
Block a user