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

Tomer Shalev shalev.tomer at gmail.com
Wed Jul 16 15:38:18 EDT 2014


Thanks Bill.

I have a patch to address this issue, therefore I believe it is better for
developers to review it.
I forgot to attach the patches to two of my recent post, so here it is.

Thanks,
Tomer


On Wed, Jul 16, 2014 at 10:33 PM, Bill Deegan <bill at baddogconsulting.com>
wrote:

> Tomer,
>
> Please address such message to the users mailing list.
> The dev mailing list is intended for the internal development of SCons.
>
> Thanks,
> Bill
> p.s. I'm ccing the users mailinglist
>
>
> On Mon, Jul 14, 2014 at 8:19 PM, Tomer Shalev <shalev.tomer at gmail.com>
> wrote:
>
>> 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
>>
>> _______________________________________________
>> Scons-dev mailing list
>> Scons-dev at scons.org
>> http://two.pairlist.net/mailman/listinfo/scons-dev
>>
>>
>
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> http://two.pairlist.net/mailman/listinfo/scons-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/scons-dev/attachments/20140716/fe1c73c4/attachment-0001.html>
-------------- next part --------------
--- SCons/Tool/msvs.py	Fri May 16 15:01:41 2014
+++ SCons/Tool/msvs.py	Tue Jul 01 01:26:13 2014
@@ -715,7 +715,10 @@
             # This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE,
             # so they could vary depending on the command being generated.  This code
             # assumes they don't.
-            preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', []))))
+            cpp_defines = self.env.get('CPPDEFINES', [])
+            cc_defines = filter(lambda s: s.startswith('-D'), self.env.get('CCFLAGS', []))
+            cc_defines = map(lambda s: s[2:], cc_defines)
+            preprocdefs = xmlify(';'.join(processDefines(cpp_defines + cc_defines)))
             includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None)
             includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
             


More information about the Scons-dev mailing list