On Tue, 08 Nov 2011 19:47:29 +0100, EdorFaus wrote:
On 11/08/2011 08:55 AM, Xiangfu Liu wrote:
On 11/07/2011 11:15 PM, [email protected] wrote:
Hi, I am wondering how to make a makefile if the program requires
being built with Scons? By the way, I am looking at Xiangfu's
<snip>
I mark it as broken because the 'Scons' :(

we need find out how to pass the CC, CFLAGS etc to the 'Scons'
maybe add a 'custom-openwrt.py', do you have any experience on 'Scons'?

Hi,

I don't have any real experience with SCons myself, but took a look
at it now, reading some documentation and experimenting a little bit.

SCons does, by design, not automatically copy environment variables
from the original environment to the environment used to build
programs.

However, it turns out to be fairly easy to make it do so. Simply put
something like this at the top of the SConstruct file:


Here is the thing though: The build system requires you to make a Makefile that will automatically download the source code and then make the program. I cannot just edit the file by hand, I guess one would have to specify in the Makefile to put this at the beggining of the SConstruct file

import os
env = DefaultEnvironment()
if 'CC' in os.environ:
        env['CC']=os.environ['CC']
if 'CFLAGS' in os.environ:
        env.MergeFlags(os.environ['CFLAGS'])

This makes it copy the CC and CFLAGS environment variables into the
appropriate execution environment variables used by SCons to build C.

I tested this by setting CC to echo before running scons, using the
hello world example in the scons user manual. :)

Of course, if the SConstruct file already does things with the
execution environment (DefaultEnvironment() or Environment()), it
might need to be checked to ensure it doesn't overwrite these changes.

As for making a makefile, I haven't looked at the source for the
package this was about, but I'm guessing that your build host expects
to be able to just run "make" to build the program, but the project
doesn't have a Makefile already, so you need to make one.

I would guess that the solution to this is pretty obvious, but just
for completeness, the Makefile I wrote (which works for me) looks like
this:

all:
scons
clean:
scons -c
.PHONY: all clean


This, of course, assumes that SCons is installed on the computer
doing the building; if not, it would be possible to make the makefile
install it locally first (assuming Python is installed and available),
and also to clean it up (remove it) afterwards (when calling clean).


_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to