60 lines
1.3 KiB
Python
60 lines
1.3 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')
|
|
|
|
irs_sources = Split('''
|
|
src/drivers/pic.cpp
|
|
src/drivers/ps2.cpp
|
|
''')
|
|
any_target_sources = Split('''
|
|
src/app/main.cpp
|
|
|
|
src/libs/psf.cpp
|
|
|
|
src/os/draw.cpp
|
|
src/os/panic.cpp
|
|
src/os/tty.cpp
|
|
src/os/resources/lat9-08.psf.s
|
|
|
|
src/cstdlib/assert.cpp
|
|
src/cstdlib/stdio.cpp
|
|
src/cstdlib/stdlib.cpp
|
|
src/cstdlib/string.cpp
|
|
''')
|
|
env.Resource(env.File('src/os/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 irs_sources])
|
|
|
|
Return('env') |