[Scons-dev] MSVS builder in combination with cross compilation

Tomer Shalev shalev.tomer at gmail.com
Mon Jul 14 23:19:48 EDT 2014


Hello there,

I work in Windows development environment. I am using the MSVS builder
(env.MSVSProject, env.MSVSSolution) to build a VS solution in which I edit
cross-platform code, and when I build the project is cross-compiles an .elf
file for Linux environment.

I define the following:

env.AppendUnique(CCFLAGS = [
    '-Wall',
    '-Werror',
    '-g',
    '-mcpu=arm7tdmi',
    '-DARM7',
    '-DXXTEST',
    '-DUSE_UART',
    '-DMENU_TESTS',
    '-DMY_TESTS',
    '-DUSE_FOO',
    ])

This setup works well, and I am able to build the VS solution and project
files, and cross-compile an .elf file from the source files I define.

However, there is a bug in the Scons builder which is rather annoying. The
VS IDE grays-out code sections that are surrounded by definitions defined
in the Sconscript, e.g. #ifdef USE_FOO.
It is merely a usability bug, since the code compiles as expected. The only
issue is with the IDE (Visual Studio 2008) showing the code grayed-out and
that there is code browsing is unavailable inside that code section.

In the VS project file, the following line should be defined in order to
remedy this issue:
PreprocessorDefinitions="ARM7;XXTEST;USE_UART;MENU_TESTS;MY_TESTS;USE_FOO"

However, the builder currently generates this definition empty. I read the
its code and noticed that the PreprocessorDefinitions line is only
populated according to CPPDEFINES value.

I tried moving the definitions accordingly:

env.AppendUnique(CCFLAGS = [
    '-Wall',
    '-Werror',
    '-g',
    '-mcpu=arm7tdmi',
    ])

env.AppendUnique(CPPDEFINES = [
    'ARM7',
    'XXTEST',
    'USE_UART',
    'MENU_TESTS',
    'MY_TESTS',
    'USE_FOO',
    ])


However, since I run the Sconscript in Windows environment, the compilation
flags set by it are not set according to POSIX (it uses /D), and result in
a compilation error when I cross-compile my code from Visual Studio (using
GNU compilers).

If I set env.Platform(’posix’) in the Sconscript then the MSVS builder
fails to create the project and solution files.

I created a patch to make the builder sensitive to CCFLAGS values which
starts with '-D' and it works for me. Please see the attach patch file.

However, I am not sure this is the right solution, and I would be happy to
hear your opinion on the subject. Any help is appreciated.

Thanks,
Tomer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/scons-dev/attachments/20140715/1fc13418/attachment-0001.html>


More information about the Scons-dev mailing list