X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=SConscript.target;h=fa4ca1775d42e3ea4d47efce8000a67bdb06e62a;hb=ed56d89bbb0692755ed06f18d227d4d1e39e6b05;hp=b5eb085628154436ba9ed7dae9d4239dc0ffd62d;hpb=69f57fcaee4e0a62192a87b21ed31142624ce009;p=gps-watch.git diff --git a/SConscript.target b/SConscript.target index b5eb085..fa4ca17 100644 --- a/SConscript.target +++ b/SConscript.target @@ -1,3 +1,4 @@ +import subprocess import os Import('env') @@ -33,53 +34,74 @@ env.Append(LINKFLAGS = [ '-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 = [ '-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', ] -start_o = env.Object('src/bootloader/start.c') - for s in ['intermediate', 'final']: - libbootloader_env = env.Clone() + bootloader_env = env.Clone() - libbootloader_env.Append(RUSTCFLAGS = [ + bootloader_env.Append(RUSTCFLAGS = [ + '-C', 'link-arg=-Tsrc/bootloader/bootloader-{}.ld'.format(s), '--cfg', 'bootloader_type=\\"{}\\"'.format(s) ]) - libbootloader = libbootloader_env.Rustc('libbootloader-{}.a'.format(s), - libbootloader_source_files[0]) + 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'.format(s), - ]) + Default(bootloader_bin) - bootloader_elf = \ - bootloader_env.Program('gps-watch-bootloader-{}.elf'.format(s), - start_o, LIBS = ['bootloader-{}'.format(s), 'common']) +application_source_files = [ + 'src/application/main.rs', # Must be listed first (see below). + 'src/application/uart0.rs', +] - bootloader_bin = bootloader_env.Objcopy(bootloader_elf) +application_env = env.Clone() - Default(bootloader_bin) +application_env.Append(RUSTCFLAGS = [ + '-C', 'link-arg=-Tsrc/application/application.ld', +]) + +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') + +application_bin = application_env.Objcopy(application_elf) + +Default(application_bin)