what to to if Scons required?

EdorFaus edorfaus at xepher.net
Thu Nov 10 19:10:44 EST 2011


On 11/10/2011 07:36 AM, cenobyte at dragoncrypt.com wrote:
> 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

Hmm, so you're just allowed one file, and that's the Makefile? I see.

That does complicate things a little bit, but it is still doable.

For simplicity, I'll assume you already know how to make it download the 
original source file etc., and how to integrate this with the rest of 
the makefile, seeing as you're more familiar with the build system than 
I am.

I've attached a Makefile that prepends the text I gave earlier to the 
SConstruct file before calling scons, and restores the original on 
clean. It seems to work for my test project, and should hopefully still 
work in a more complex environment.

I believe the same approach can also be used for more complex patches 
(assuming the patch command is available on the buildhost), as we could 
then define the text on patch format and pipe it to the patch command 
instead of directly to file like this does.

-- 
Regards,
Frode Austvik
-------------- next part --------------
all:
	[ -f SConstruct.original ] || mv SConstruct SConstruct.original
	echo "$$SCONSTRUCT_TOP_TEXT" > SConstruct
	cat SConstruct.original >> SConstruct
	scons

clean:
	scons -c
	[ -f SConstruct.original ] && mv SConstruct.original SConstruct || true

.PHONY: all clean

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

endef
export SCONSTRUCT_TOP_TEXT


More information about the discussion mailing list


interactive