57 lines
1.2 KiB
Python

Import('env')
def _resource(env, res, symbol):
def _generate_s(target, source, env):
with open(target[0].abspath, 'w') as f:
f.write(f'''
.section .rodata
.global {symbol}
.type {symbol} @object
.section .rodata
.global {symbol}_SIZE
.type {symbol}_SIZE @object
{symbol}:
.incbin "{res}"
{symbol}_END:
{symbol}_SIZE:
.int {symbol}_END - {symbol}
''')
with open(target[1].abspath, 'w') as f:
f.write(f'''
#pragma once
#include <stdint.h>
extern "C"
{{
extern const uint8_t {symbol}[];
extern const unsigned {symbol}_SIZE;
}}
''')
env.Command([f'{res}.s', f'{res}.hpp'.replace('src/', 'include/')], res, action = _generate_s)
env.AddMethod(_resource, 'Resource')
isr_sources = Split('''
src/drivers/pic.cpp
src/drivers/ps2.cpp
src/interrupt.cpp
''')
any_target_sources = Split('''
src/drivers/pci.cpp
src/drivers/usb.cpp
src/draw.cpp
src/memory.cpp
src/panic.cpp
src/syscall.cpp
src/tty.cpp
src/resources/lat9-08.psf.s
''')
env.Resource(env.File('src/resources/lat9-08.psf').abspath, 'LAT9_08')
env.Append(KERNEL_SOURCES = [env.File(f) for f in any_target_sources])
env.Append(KERNEL_ISR_SOURCES = [env.File(f) for f in isr_sources])
Return('env')