import subprocess AddOption( '--target', dest = 'target', type = 'choice', choices = ('i686', 'x86_64'), nargs = 1, action = 'store', default = 'i686' ) target = GetOption('target') env = Environment(tools = ['default', 'compilation_db']) env.Append(CFLAGS = ['-ffreestanding']) env.Append(CXXFLAGS = ['-ffreestanding', '-fno-exceptions', '-fno-rtti', '-std=c++20']) env.Append(LINKFLAGS = ['-T', 'linker.ld', '-ffreestanding', '-nostdlib']) env.Append(CPPPATH = ['#targets/_any/include', '#bastl/include']) env.Append(CCFLAGS = ['-g', '-O0']) env['KERNEL_SOURCES'] = [] env['KERNEL_DEPENDENCIES'] = [] env['ISO_FILES'] = [] env = SConscript('bastl/SConscript', exports = 'env') env = SConscript('targets/_any/SConscript', exports = 'env') env = SConscript(f'targets/{target}/SConscript', exports = 'env') prog_os = env.Program( target = 'os.bin', source = env['KERNEL_SOURCES'], LIBS = ['gcc'], LINKCOM = env['KERNEL_LINKCOM'] ) env.Depends(prog_os, env['KERNEL_DEPENDENCIES']) env.Default(prog_os) comp_db = env.CompilationDatabase(target = '#compile_commands.json') env.Default(comp_db) iso_targets = [] for iso_file in env['ISO_FILES']: iso_targets.append(env.Command(f'iso/{iso_file["target"]}', iso_file["source"], Copy("$TARGET", "$SOURCE"))) env.Command('os.iso', iso_targets, 'grub-mkrescue -o "$TARGET" "iso"')