mirror of
https://github.com/drasko/codezero.git
synced 2026-01-15 04:13:16 +01:00
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
|
Import('config', 'env', 'contid')
|
|
|
|
import os, sys
|
|
|
|
arch = config.arch
|
|
|
|
sys.path.append('../../../../')
|
|
from config.lib import *
|
|
|
|
container = next((c for c in config.containers if int(c.id) == int(contid)), None)
|
|
|
|
def create_symlinks(arch):
|
|
arch_path = "include/arch"
|
|
arch_path2 ="src/arch"
|
|
if os.path.exists(arch_path):
|
|
os.system("rm %s" % (arch_path))
|
|
os.system("ln -s %s %s" % ("arch-" + arch, arch_path))
|
|
if os.path.exists(arch_path2):
|
|
os.system("rm %s" % (arch_path2))
|
|
os.system("ln -s %s %s" % ("arch-" + arch, arch_path2))
|
|
|
|
def generate_lma_lds(target, source, env):
|
|
with open(source[0].path, 'r') as lds_in:
|
|
with open(target[0].path, 'w+') as lds_out:
|
|
linker_script = lds_in.read()
|
|
assert container.pager_lma != 0
|
|
lds_out.write(linker_script % conv_hex(container.pager_lma))
|
|
|
|
lma_lds = Command('include/linker.lds', 'include/linker.lds.in', generate_lma_lds)
|
|
|
|
src = [Glob('*.c') + Glob('mm/*.c') + Glob('lib/*.c') + Glob('fs/*.c') + Glob('fs/memfs/*.c') + Glob('lib/elf/*.c') + Glob('mm/arch/*.c')]
|
|
|
|
e = env.Clone()
|
|
|
|
e.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
|
|
e.Append(LIBS = 'posix')
|
|
objs = e.Object(src)
|
|
mm0 = e.Program('mm0.elf', objs)
|
|
|
|
Depends(mm0, lma_lds)
|
|
Return('mm0')
|
|
|