Added --target option to compile either os or stdlib. And renamed previous --target to --arch.
This commit is contained in:
parent
3cd4fe9537
commit
debbd09b6d
23
SConstruct
23
SConstruct
@ -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)
|
||||||
|
@ -16,23 +16,24 @@ 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])
|
||||||
|
|
||||||
### Stdlib
|
if env['BUILD_TARGET'] == 'stdlib':
|
||||||
stdlib_env = env.Clone()
|
### Stdlib
|
||||||
stdlib_env['AS'] = 'x86_64-baos-elf-as'
|
stdlib_env = env.Clone()
|
||||||
stdlib_env['CC'] = 'x86_64-baos-elf-gcc'
|
stdlib_env['AS'] = 'x86_64-elf-baos-as'
|
||||||
stdlib_env['CXX'] = 'x86_64-baos-elf-g++'
|
stdlib_env['CC'] = 'x86_64-elf-baos-gcc'
|
||||||
stdlib_env['LD'] = 'x86_64-baos-elf-g++'
|
stdlib_env['CXX'] = 'x86_64-elf-baos-g++'
|
||||||
stdlib_env['OBJSUFFIX'] = f'.baos{stdlib_env["OBJSUFFIX"]}'
|
stdlib_env['LD'] = 'x86_64-elf-baos-g++'
|
||||||
stdlib_env.Append(CXXFLAGS = ['-fno-exceptions', '-fno-rtti', '-std=c++20'])
|
stdlib_env['OBJSUFFIX'] = f'.baos{stdlib_env["OBJSUFFIX"]}'
|
||||||
stdlib_env.Append(CPPPATH = ['#targets/_any/bastl/include', '#targets/_any/stdlib/include', '#targets/_any/kernel/include'])
|
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'])
|
||||||
|
|
||||||
lib_stdlib = stdlib_env.StaticLibrary(
|
lib_stdlib = stdlib_env.StaticLibrary(
|
||||||
target = stdlib_env.File('#stdlib/stdlib.a'),
|
target = stdlib_env.File('#stdlib/stdlib.a'),
|
||||||
source = stdlib_sources
|
source = stdlib_sources
|
||||||
)
|
)
|
||||||
crti_o = stdlib_env.Object(target = '#stdlib/crti.o', source = stdlib_env['CRTI_PATH'])
|
crti_o = stdlib_env.Object(target = '#stdlib/crti.o', source = stdlib_env['CRTI_PATH'])
|
||||||
crtn_o = stdlib_env.Object(target = '#stdlib/crtn.o', source = stdlib_env['CRTN_PATH'])
|
crtn_o = stdlib_env.Object(target = '#stdlib/crtn.o', source = stdlib_env['CRTN_PATH'])
|
||||||
crt0_o = stdlib_env.Object(target = '#stdlib/crt0.o', source = stdlib_env['CRT0_PATH'])
|
crt0_o = stdlib_env.Object(target = '#stdlib/crt0.o', source = stdlib_env['CRT0_PATH'])
|
||||||
stdlib_env.Default([lib_stdlib, crti_o, crtn_o, crt0_o])
|
stdlib_env.Default([lib_stdlib, crti_o, crtn_o, crt0_o])
|
||||||
|
|
||||||
Return('env')
|
Return('env')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user