X-Git-Url: http://git.code-monkey.de/?p=gps-watch.git;a=blobdiff_plain;f=SConscript.target;h=a927dd7292259df9195a792a06735dd65558e6ea;hp=6dd2f413d66fa60b2684d3c648c21b1ec11bdda1;hb=HEAD;hpb=d899a72babb4c2d80fe6e46a77e570864218b46f diff --git a/SConscript.target b/SConscript.target index 6dd2f41..a927dd7 100644 --- a/SConscript.target +++ b/SConscript.target @@ -1,3 +1,4 @@ +import subprocess import os Import('env') @@ -33,38 +34,86 @@ env.Append(LINKFLAGS = [ '-nostartfiles', ]) +libgcc_path = \ + subprocess.check_output('{} -print-libgcc-file-name'.format(env['CC']), + shell=True).strip().decode('utf-8') + env.Append(RUSTCFLAGS = [ '-C', 'opt-level=s', + '-C', 'link-arg={}'.format(libgcc_path), '--target=thumbv6m-none-eabi', '-L', '$LIBPATH', + '-l', 'common', ]) env.Append(LINKFLAGS = [ '-Wl,--gc-sections' ]) -SConscript('SConscript.libcommon', exports='env', duplicate=0) +SConscript('SConscript.libcommon.c', exports='env', duplicate=0) +SConscript('SConscript.libcommon.rs', 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]) +bootloader_bins = [] + +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 bootloader_source_files: + Depends(bootloader_elf, f) + + Depends(bootloader_elf, 'libcommon.rlib') + Depends(bootloader_elf, 'libcommon.a') + + bootloader_bin = bootloader_env.Objcopy(bootloader_elf) -for f in libbootloader_source_files: - Depends(libbootloader, f) + Default(bootloader_bin) -Depends(libbootloader, 'libcommon.rlib') -Depends(libbootloader, 'libcommon.a') + bootloader_bins.append(bootloader_bin) -bootloader_env = env.Clone() +bootloader_intermediate_frm = \ + bootloader_env.Frm(bootloader_bins[0]) -bootloader_env.Append(LINKFLAGS = [ - '-Tsrc/bootloader/bootloader.ld', +Default(bootloader_intermediate_frm) + +application_source_files = [ + 'src/application/main.rs', # Must be listed first (see below). + 'src/application/button.rs', + 'src/application/model.rs', + 'src/application/views.rs', + '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)