Added --target option to compile either os or stdlib. And renamed previous --target to --arch.

This commit is contained in:
Patrick 2024-02-03 00:38:47 +01:00
parent 3cd4fe9537
commit debbd09b6d
2 changed files with 33 additions and 27 deletions

View File

@ -3,8 +3,8 @@ import os
import subprocess import subprocess
AddOption( AddOption(
'--target', '--arch',
dest = 'target', dest = 'arch',
type = 'choice', type = 'choice',
choices = ('i686', 'x86_64'), choices = ('i686', 'x86_64'),
nargs = 1, nargs = 1,
@ -12,24 +12,29 @@ AddOption(
default = 'x86_64' default = 'x86_64'
) )
AddOption( AddOption(
'--stdlib', '--target',
dest = 'stdlib', dest = 'target',
action = 'store_true' type = 'choice',
choices = ('os', 'stdlib'),
nargs = 1,
action = 'store',
default = 'os'
) )
arch = GetOption('arch')
target = GetOption('target') target = GetOption('target')
stdlib = GetOption('stdlib')
env = Environment(tools = ['default', 'compilation_db'], ENV = os.environ) # TODO inheriting the environment is not a best practice env = Environment(tools = ['default', 'compilation_db'], ENV = os.environ) # TODO inheriting the environment is not a best practice
env.Append(CCFLAGS = ['-g', '-O0', '-fno-stack-protector']) env.Append(CCFLAGS = ['-g', '-O0', '-fno-stack-protector'])
env.Append(CPPDEFINES = ['BASTL_EXTENSIONS=1']) env.Append(CPPDEFINES = ['BASTL_EXTENSIONS=1'])
env['TARGET_ARCH'] = target env['BUILD_TARGET'] = target
env['TARGET_ARCH'] = arch
# env.Append(CCFLAGS = ['-O2']) # env.Append(CCFLAGS = ['-O2'])
env['ISO_FILES'] = [] env['ISO_FILES'] = []
env = SConscript('targets/_any/SConscript', exports = 'env') env = SConscript('targets/_any/SConscript', exports = 'env')
if not stdlib: if env['BUILD_TARGET'] == 'os':
env = SConscript(f'targets/{target}/SConscript', exports = 'env') env = SConscript(f'targets/{arch}/SConscript', exports = 'env')
comp_db = env.CompilationDatabase(target = '#compile_commands.json') comp_db = env.CompilationDatabase(target = '#compile_commands.json')
env.Default(comp_db) env.Default(comp_db)

View File

@ -16,12 +16,13 @@ stdlib_sources = Split(f'''
env.Append(KERNEL_SOURCES = [env.File(f) for f in stdlib_sources]) env.Append(KERNEL_SOURCES = [env.File(f) for f in stdlib_sources])
if env['BUILD_TARGET'] == 'stdlib':
### Stdlib ### Stdlib
stdlib_env = env.Clone() stdlib_env = env.Clone()
stdlib_env['AS'] = 'x86_64-baos-elf-as' stdlib_env['AS'] = 'x86_64-elf-baos-as'
stdlib_env['CC'] = 'x86_64-baos-elf-gcc' stdlib_env['CC'] = 'x86_64-elf-baos-gcc'
stdlib_env['CXX'] = 'x86_64-baos-elf-g++' stdlib_env['CXX'] = 'x86_64-elf-baos-g++'
stdlib_env['LD'] = 'x86_64-baos-elf-g++' stdlib_env['LD'] = 'x86_64-elf-baos-g++'
stdlib_env['OBJSUFFIX'] = f'.baos{stdlib_env["OBJSUFFIX"]}' stdlib_env['OBJSUFFIX'] = f'.baos{stdlib_env["OBJSUFFIX"]}'
stdlib_env.Append(CXXFLAGS = ['-fno-exceptions', '-fno-rtti', '-std=c++20']) stdlib_env.Append(CXXFLAGS = ['-fno-exceptions', '-fno-rtti', '-std=c++20'])
stdlib_env.Append(CPPPATH = ['#targets/_any/bastl/include', '#targets/_any/stdlib/include', '#targets/_any/kernel/include']) stdlib_env.Append(CPPPATH = ['#targets/_any/bastl/include', '#targets/_any/stdlib/include', '#targets/_any/kernel/include'])