bad_apple_os/SConstruct

39 lines
1.1 KiB
Python

import os
import subprocess
AddOption(
'--target',
dest = 'target',
type = 'choice',
choices = ('i686', 'x86_64'),
nargs = 1,
action = 'store',
default = 'x86_64'
)
AddOption(
'--stdlib',
dest = 'stdlib',
action = 'store_true'
)
target = GetOption('target')
stdlib = GetOption('stdlib')
env = Environment(tools = ['default', 'compilation_db'])
env.Append(CCFLAGS = ['-g', '-O0', '-fno-stack-protector'])
env.Append(CPPDEFINES = ['BASTL_EXTENSIONS=1'])
# env.Append(CCFLAGS = ['-O2'])
env['ISO_FILES'] = []
env = SConscript('targets/_any/SConscript', exports = 'env', ENV = os.environ) # TODO inheriting the environment is not a best practice
if not stdlib:
env = SConscript(f'targets/{target}/SConscript', exports = 'env')
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"')