42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
Import('env')
|
|
|
|
env['AS'] = 'i686-elf-as'
|
|
env['CC'] = 'i686-elf-gcc'
|
|
env['CXX'] = 'i686-elf-g++'
|
|
env['LD'] = 'i686-elf-g++'
|
|
|
|
def get_crt_object(name: str) -> str:
|
|
import subprocess
|
|
|
|
cmd = [env['CXX']]
|
|
cmd.extend(env['CXXFLAGS'])
|
|
cmd.append(f'-print-file-name={name}')
|
|
result = subprocess.run(cmd, stdout=subprocess.PIPE)
|
|
return result.stdout.decode('utf-8').strip()
|
|
crtbegin_o = get_crt_object('crtbegin.o')
|
|
crtend_o = get_crt_object('crtend.o')
|
|
crti_o = env.Object('src/crt/crti.s')
|
|
crtn_o = env.Object('src/crt/crtn.s')
|
|
env['KERNEL_LINKCOM'] = env['LINKCOM'].replace('$_LIBFLAGS', f'{crti_o[0].abspath} {crtbegin_o} $_LIBFLAGS {crtend_o} {crtn_o[0].abspath}')
|
|
|
|
i686_sources = Split('''
|
|
src/kernel/boot.s
|
|
src/kernel/startup.cpp
|
|
''')
|
|
|
|
i686_iso_files = [
|
|
{
|
|
"source": env.File("boot/grub.cfg"),
|
|
"target": "boot/grub/grub.cfg"
|
|
},
|
|
{
|
|
"source": env.File("#os.bin"),
|
|
"target": "boot/os.bin"
|
|
}
|
|
]
|
|
|
|
env.Append(KERNEL_SOURCES = [env.File(f) for f in i686_sources])
|
|
env.Append(KERNEL_DEPENDENCIES = [crti_o, crtn_o])
|
|
env.Append(ISO_FILES = i686_iso_files)
|
|
|
|
Return('env') |