+import subprocess
import os
Import('env')
'-nostartfiles',
])
+libgcc_path = \
+ subprocess.check_output('{} -print-libgcc-file-name'.format(env['CC']),
+ shell=True).strip()
+
env.Append(RUSTCFLAGS = [
'-C', 'opt-level=s',
+ '-C', 'link-arg={}'.format(libgcc_path),
'--target=thumbv6m-none-eabi',
'-L', '$LIBPATH',
+ '-l', 'common',
])
env.Append(LINKFLAGS = [
SConscript('SConscript.libcommon', exports='env', duplicate=0)
-libbootloader_source_files = [
+bootloader_source_files = [
'src/bootloader/main.rs', # Must be listed first (see below).
'src/bootloader/bootloader.rs',
'src/bootloader/flash.rs',
]
-libbootloader = env.Rustc('libbootloader.a', libbootloader_source_files[0])
+for s in ['intermediate', 'final']:
+ bootloader_env = env.Clone()
+
+ bootloader_env.Append(RUSTCFLAGS = [
+ '-C', 'link-arg=-Tsrc/bootloader/bootloader-{}.ld'.format(s),
+ '--cfg',
+ 'bootloader_type=\\"{}\\"'.format(s)
+ ])
+
+ bootloader_elf = \
+ bootloader_env.Rustc('gps-watch-bootloader-{}.elf'.format(s),
+ bootloader_source_files[0])
-for f in libbootloader_source_files:
- Depends(libbootloader, f)
+ for f in bootloader_source_files:
+ Depends(bootloader_elf, f)
-Depends(libbootloader, 'libcommon.rlib')
-Depends(libbootloader, 'libcommon.a')
+ Depends(bootloader_elf, 'libcommon.rlib')
+ Depends(bootloader_elf, 'libcommon.a')
-bootloader_env = env.Clone()
+ bootloader_bin = bootloader_env.Objcopy(bootloader_elf)
-bootloader_env.Append(LINKFLAGS = [
- '-Tsrc/bootloader/bootloader.ld',
+ Default(bootloader_bin)
+
+application_source_files = [
+ 'src/application/main.rs', # Must be listed first (see below).
+ 'src/application/uart0.rs',
+]
+
+application_env = env.Clone()
+
+application_env.Append(RUSTCFLAGS = [
+ '-C', 'link-arg=-Tsrc/application/application.ld',
])
-bootloader_elf = bootloader_env.Program('gps-watch-bootloader.elf', 'src/bootloader/start.c', LIBS = ['bootloader', 'common'])
+application_elf = application_env.Rustc('gps-watch-application.elf',
+ application_source_files[0])
+
+for f in application_source_files:
+ Depends(application_elf, f)
+
+Depends(application_elf, 'libcommon.rlib')
+Depends(application_elf, 'libcommon.a')
-bootloader_bin = bootloader_env.Objcopy(bootloader_elf)
+application_bin = application_env.Objcopy(application_elf)
-Default(bootloader_bin)
+Default(application_bin)