initgraph, whole lot of refactor
This commit is contained in:
+93
-52
@@ -29,22 +29,25 @@ assert(c_compiler.has_define('__GNUC__'))
|
||||
add_project_arguments(
|
||||
'-Wno-unused',
|
||||
'-Wno-unused-parameter',
|
||||
'-fno-stack-protector',
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
'-ffreestanding',
|
||||
'-fno-stack-protector',
|
||||
language: 'c',
|
||||
)
|
||||
|
||||
add_project_link_arguments(
|
||||
common_c_args = [
|
||||
'-fno-stack-protector',
|
||||
'-fno-omit-frame-pointer',
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
'-ffreestanding',
|
||||
'-nostdinc',
|
||||
]
|
||||
|
||||
common_link_args = [
|
||||
'-ffreestanding',
|
||||
'-nostdlib',
|
||||
'-znoexecstack',
|
||||
'-Wl,--gc-sections',
|
||||
'-Wl,--build-id=none',
|
||||
language: 'c',
|
||||
)
|
||||
]
|
||||
|
||||
common_includes = [
|
||||
include_directories('include'),
|
||||
@@ -70,12 +73,14 @@ foreach k, v : kconfig
|
||||
endif
|
||||
endforeach
|
||||
|
||||
kernel_c_args = ['-DIN_KERNEL']
|
||||
kernel_c_args = ['-D__IN_KERNEL']
|
||||
|
||||
kernel_lds = meson.current_source_dir() / 'boot' / 'kernel.ld'
|
||||
kernel_link_args = [
|
||||
'-T' + kernel_lds,
|
||||
'-Wl,--export-dynamic',
|
||||
'-shared',
|
||||
'-Wl,-Bsymbolic',
|
||||
'-Wl,-soname,zinnia',
|
||||
]
|
||||
|
||||
kernel_includes = []
|
||||
@@ -92,71 +97,107 @@ subdir('syscalls')
|
||||
subdir('dev')
|
||||
subdir('fs')
|
||||
|
||||
subdir('tests')
|
||||
|
||||
configure_file(
|
||||
configuration: cfg,
|
||||
output: 'config.h',
|
||||
)
|
||||
|
||||
zinnia_datadir = get_option('datadir') / 'zinnia'
|
||||
|
||||
mod_summary = {}
|
||||
modular_modules = {}
|
||||
builtin_libs = []
|
||||
|
||||
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'],
|
||||
install_dir: get_option('datadir') / 'zinnia' / 'modules',
|
||||
#link_depends: kernel.full_path(),
|
||||
foreach dep : v.get('depends', [])
|
||||
assert(
|
||||
dep in modules,
|
||||
'Module "' + name + '" depends on unknown module "' + dep + '"',
|
||||
)
|
||||
else
|
||||
kernel_sources += mod_sources
|
||||
kernel_c_args += mod_c_args
|
||||
kernel_includes += mod_includes
|
||||
kernel_link_args += mod_link_args
|
||||
assert(
|
||||
not modules[dep].get('modular', false),
|
||||
'Module "'
|
||||
+ name
|
||||
+ '" can\'t depend on modular module "'
|
||||
+ dep
|
||||
+ '"',
|
||||
)
|
||||
endforeach
|
||||
|
||||
if v.get('modular', false)
|
||||
modular_modules += {name: v}
|
||||
mod_summary += {name: 'module'}
|
||||
continue
|
||||
endif
|
||||
|
||||
if is_modular
|
||||
mod_summary += {name: 'mod'}
|
||||
else
|
||||
mod_summary += {name: 'builtin'}
|
||||
endif
|
||||
mod_c_args = v.get('c_args', [])
|
||||
mod_includes = v.get('include_directories', [])
|
||||
builtin_libs += static_library(
|
||||
name,
|
||||
sources: v.get('sources'),
|
||||
c_args: [
|
||||
common_c_args,
|
||||
kernel_c_args,
|
||||
mod_c_args,
|
||||
'-D__MODULE_NAME="' + name + '"',
|
||||
],
|
||||
include_directories: [common_includes, kernel_includes, mod_includes],
|
||||
pic: true,
|
||||
)
|
||||
kernel_c_args += mod_c_args
|
||||
kernel_includes += mod_includes
|
||||
kernel_link_args += v.get('link_args', [])
|
||||
mod_summary += {name: 'builtin'}
|
||||
endforeach
|
||||
|
||||
# Kernel
|
||||
executable(
|
||||
kernel = executable(
|
||||
'zinnia',
|
||||
include_directories: [
|
||||
common_includes,
|
||||
kernel_includes,
|
||||
],
|
||||
c_args: [kernel_c_args],
|
||||
link_args: kernel_link_args,
|
||||
c_args: [common_c_args, kernel_c_args],
|
||||
link_args: [common_link_args, kernel_link_args],
|
||||
link_depends: kernel_lds,
|
||||
sources: kernel_sources,
|
||||
install: true,
|
||||
install_dir: get_option('datadir') / 'zinnia',
|
||||
link_whole: builtin_libs,
|
||||
pie: true,
|
||||
install: true,
|
||||
install_dir: zinnia_datadir,
|
||||
)
|
||||
|
||||
foreach name, v : modular_modules
|
||||
shared_library(
|
||||
name,
|
||||
sources: v.get('sources'),
|
||||
c_args: [
|
||||
common_c_args,
|
||||
'-fPIC',
|
||||
'-D__IN_MODULE',
|
||||
'-D__MODULE_NAME="' + name + '"',
|
||||
v.get('c_args', []),
|
||||
],
|
||||
link_args: [
|
||||
common_link_args,
|
||||
'-T' + module_lds, kernel.full_path(),
|
||||
v.get('link_args', []),
|
||||
],
|
||||
link_depends: [module_lds, kernel],
|
||||
include_directories: [
|
||||
common_includes,
|
||||
kernel_includes, # We want this, actually
|
||||
v.get('include_directories', []),
|
||||
],
|
||||
name_prefix: '',
|
||||
name_suffix: 'kso',
|
||||
link_with: v.get('link_with', []),
|
||||
install_dir: zinnia_datadir / 'modules',
|
||||
)
|
||||
endforeach
|
||||
|
||||
# Print a summary
|
||||
summary(mod_summary, section: 'Driver configuration')
|
||||
summary(kconfig, bool_yn: true, section: 'Kernel configuration')
|
||||
|
||||
Reference in New Issue
Block a user