modules
This commit is contained in:
+64
-20
@@ -38,57 +38,58 @@ add_project_arguments(
|
||||
'-fno-stack-protector',
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
'-ffreestanding',
|
||||
'-nostdinc', # We provide our own headers.
|
||||
'-fno-stack-protector',
|
||||
language: 'c',
|
||||
)
|
||||
|
||||
add_project_link_arguments(
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-znoexecstack',
|
||||
'-Wl,--gc-sections',
|
||||
'-Wl,--build-id=none',
|
||||
language: 'c',
|
||||
)
|
||||
|
||||
common_includes = include_directories('include')
|
||||
common_includes = [
|
||||
include_directories('include'),
|
||||
include_directories('arch' / target_machine.cpu_family() / 'include'),
|
||||
]
|
||||
|
||||
cfg = configuration_data()
|
||||
cfg.set_quoted('ZINNIA_VERSION', meson.project_version())
|
||||
cfg.set_quoted('ZINNIA_ARCH', target_machine.cpu_family())
|
||||
cfg.set_quoted('ZINNIA_COMPILER_ID', c_compiler.get_id() + ' ' + c_compiler.version())
|
||||
cfg.set_quoted('ZINNIA_LINKER_ID', c_compiler.get_linker_id())
|
||||
|
||||
#
|
||||
# Parse kernel config
|
||||
kv = import('keyval')
|
||||
kconfig = kv.load(get_option('config_path'))
|
||||
foreach k, v : kconfig
|
||||
if v == 'y'
|
||||
cfg.set10(k, true)
|
||||
elif v == 'n'
|
||||
cfg.set10(k, false)
|
||||
else
|
||||
cfg.set(k, v)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
kernel_c_args = [
|
||||
'-ffreestanding',
|
||||
'-nostdinc', # We provide our own headers.
|
||||
'-fno-stack-protector',
|
||||
'-fno-pie',
|
||||
]
|
||||
kernel_c_args = []
|
||||
|
||||
kernel_lds = meson.current_source_dir() / 'boot' / 'kernel.ld'
|
||||
|
||||
kernel_link_args = [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-static',
|
||||
'-lgcc',
|
||||
'-static-libgcc',
|
||||
'-T' + kernel_lds,
|
||||
'-Wl,--export-dynamic',
|
||||
]
|
||||
|
||||
kernel_includes = [
|
||||
include_directories('arch' / target_machine.cpu_family() / 'include'),
|
||||
]
|
||||
|
||||
kernel_includes = []
|
||||
kernel_sources = []
|
||||
modules = {}
|
||||
|
||||
# Goes first so we can add arch-specific flags to drivers.
|
||||
subdir('arch' / target_machine.cpu_family())
|
||||
@@ -104,18 +105,61 @@ configure_file(
|
||||
output: 'config.h',
|
||||
)
|
||||
|
||||
mod_summary = {}
|
||||
foreach name, v : modules
|
||||
is_modular = v.get('modular', false)
|
||||
mod_sources = v.get('sources')
|
||||
mod_c_args = v.get('c_args', [])
|
||||
mod_link_args = v.get('link_args', [])
|
||||
mod_includes = v.get('include_directories', [])
|
||||
mod_link = v.get('link_with', [])
|
||||
|
||||
if is_modular
|
||||
shared_library(
|
||||
name,
|
||||
sources: mod_sources,
|
||||
c_args: ['-fPIC', '-fPIE', '-DIN_MODULE', mod_c_args],
|
||||
link_args: [
|
||||
'-T' + module_lds, mod_link_args,
|
||||
],
|
||||
link_depends: module_lds,
|
||||
include_directories: [
|
||||
common_includes,
|
||||
kernel_includes, # We want this, actually
|
||||
mod_includes,
|
||||
],
|
||||
name_prefix: '',
|
||||
name_suffix: 'kso',
|
||||
link_with: mod_link,
|
||||
override_options: ['b_lundef=false'],
|
||||
#link_depends: kernel.full_path(),
|
||||
)
|
||||
else
|
||||
kernel_sources += mod_sources
|
||||
kernel_c_args += mod_c_args
|
||||
kernel_includes += mod_includes
|
||||
kernel_link_args += mod_link_args
|
||||
endif
|
||||
|
||||
mod_summary += {name: is_modular}
|
||||
endforeach
|
||||
|
||||
# Kernel
|
||||
executable(
|
||||
'zinnia',
|
||||
include_directories: [
|
||||
common_includes,
|
||||
kernel_includes,
|
||||
],
|
||||
c_args: kernel_c_args,
|
||||
c_args: ['-DIN_KERNEL', kernel_c_args],
|
||||
link_args: kernel_link_args,
|
||||
link_depends: kernel_lds,
|
||||
sources: [
|
||||
kernel_sources,
|
||||
],
|
||||
sources: kernel_sources,
|
||||
install: true,
|
||||
install_dir: get_option('datadir') / 'zinnia',
|
||||
pie: true,
|
||||
)
|
||||
|
||||
# Print a summary
|
||||
summary(mod_summary, section: 'Driver configuration')
|
||||
summary(kconfig, bool_yn: true, section: 'Kernel configuration')
|
||||
|
||||
Reference in New Issue
Block a user