summaryrefslogtreecommitdiff
path: root/build/scons_tools/tool_selectmcu.py
blob: 8d7029f07f7edbaa5c6d0fef1c633c9ef1ab3d7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from SCons.Script import *

def SelectMCU(env, mcu, variant_dir = None):

	spec = env.PlatformSpec(mcu = mcu)

	if len(spec) <= 1:
		print('Unknown MCU: %s' % mcu)
		Exit(1)

	env.SetDefault(
		TOOLCHAIN = '%s-' % spec['toolchains'][0],
	)
	
	env.Replace(
		PLATFORM_SPEC = spec,

		CC     = '${TOOLCHAIN}gcc',
		CXX    = '${TOOLCHAIN}g++',
		AS     = '${TOOLCHAIN}gcc',
		LINK   = '${TOOLCHAIN}gcc',
		AR     = '${TOOLCHAIN}ar',
		RANLIB = '${TOOLCHAIN}ranlib',
		
		CCFLAGS   = Split('-O2 -Wall -ggdb -ffunction-sections'),
		CXXFLAGS  = Split('-std=c++20 -fno-exceptions -fno-rtti -Wno-pmf-conversions'),
		ASFLAGS   = Split('-c -x assembler-with-cpp'),
		LINKFLAGS = Split('-Wall -nostartfiles -Wl,-T${LINK_SCRIPT} -Wl,--gc-sections'),
		
		CPPPATH = ['${LAKS_PATH}'],
		LIBPATH = ['${LAKS_PATH}/ld_scripts'],
		
		LIB_SOURCES = [],
	)

	env.Replace(
		LINK_SCRIPT = 'generated.ld',
	)

	env.Append(
		CCFLAGS = spec.get('cflags', []),
		LINKFLAGS = spec.get('cflags', []),
		CPPDEFINES = spec.get('define', []),
	)
	
	env.SConscript('${LAKS_PATH}/SConscript', variant_dir = variant_dir, exports = 'env')

def exists():
    return True

def generate(env):
    env.AddMethod(SelectMCU)