2 # This script includes arduino specific config
7 Import('env', 'RELEASE_BUILD', 'TARGET_CPU_ARCH', 'ARDUINO_HOME')
11 ************************************* Error ***********************************
12 * Arduino root directory (ARDUINO_HOME) isn't set, you can set enviornment *
13 * variable ARDUINO_HOME or add it in command line as: *
14 * # scons ARDUINO_HOME=<path to arduino root directory> ... *
15 *******************************************************************************
19 # Overwrite suffixes and prefixes
20 if env['HOST_OS'] == 'win32':
21 env['OBJSUFFIX'] = '.o'
22 env['SHOBJSUFFIX'] = '.os'
23 env['LIBPREFIX'] = 'lib'
24 env['LIBSUFFIX'] = '.a'
25 env['SHLIBPREFIX'] = 'lib'
26 env['SHLIBSUFFIX'] = '.so'
27 env['LIBPREFIXES'] = ['lib']
28 env['LIBSUFFIXES'] = ['.a', '.so']
29 env['PROGSUFFIX'] = ''
30 elif platform.system().lower() == 'darwin':
31 env['SHLIBSUFFIX'] = '.so'
32 env['LIBSUFFIXES'] = ['.a', '.so']
33 env['PROGSUFFIX'] = ''
36 def find_toolchain(dir, tc):
37 for root, dirs, files in os.walk(dir, True, None, False):
44 if TARGET_CPU_ARCH == 'arm':
45 prefix = 'arm-none-eabi-'
49 tc_path = find_toolchain(ARDUINO_HOME + '/hardware/tools/', prefix + 'g++')
52 ************************************* Error ***********************************
53 * Arduino toolchain isn't detected. Please specify the toolchain prefix and *
54 * path, you can do it by setting enviornment variable TC_PREFIX and TC_PATH or*
55 * add it in command line as: *
56 * # scons TC_PREFIX=<prefix> TC_PATH=<path to toolchain> ... *
57 * e.g. scons TC_PREFIX=avr- TC_PATH=/opt/arduino-1.5.7/hardware/tools/avr/bin * *
58 * Note: TC_PREFIX shouldn't include path *
59 *******************************************************************************
63 env.PrependENVPath('PATH', tc_path)
64 env.Replace(CC = prefix + 'gcc')
65 env.Replace(CXX = prefix + 'g++')
66 env.Replace(AR = prefix + 'ar')
67 env.Replace(AS = prefix + 'as')
68 env.Replace(LINK = prefix + 'ld')
69 env.Replace(RANLIB = prefix + 'ranlib')
71 sys_root = os.path.abspath(os.path.join(tc_path, '..'))
72 env.AppendUnique(CFLAGS = ['--sysroot=' + sys_root])
73 env.AppendUnique(CXXFLAGS = ['--sysroot=' + sys_root])
74 env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
76 # Debug/release relative flags
78 env.AppendUnique(CFLAGS = ['-Os'])
79 env.AppendUnique(CXXFLAGS = ['-Os'])
80 env.AppendUnique(CPPDEFINES = ['NDEBUG'])
81 env.AppendUnique(LINKFLAGS = ['-s'])
83 env.AppendUnique(CFLAGS = ['-g'])
84 env.AppendUnique(CXXFLAGS = ['-g'])