[Scons-users] Doing a build time Glob()

Pico Geyer picogeyer at gmail.com
Fri Nov 29 09:52:52 EST 2013


On Fri, Nov 29, 2013 at 2:10 AM, Bill Deegan <bill at baddogconsulting.com>wrote:


> Marc,

>

> In your example A install a bunch,etc.. make will not know about the

> dependencies until you run make again.

>


Hi Bill,

I don't know if this is exactly what Marc was referring to, but I'd like to
provide my own example of how Make does not require you to specify all the
dependencies explicitly.
Perhaps you can help me clear up my misunderstanding.
I'll just paste my sample code here but let me know if you'd like a tarball.
So here's the Makefile:
### Code start ###
all: test
test: myhdrs
gcc -Iinc -o test test.c
myhdrs: genhdrs
mkdir -p inc
cp build_dir/*.h inc/
genhdrs:
./genhdrs.py
clean:
rm -rf inc build_dir test test.o
.PHONY : genhdrs clean
### Code end ###

genhdrs.py is just a very simple script that generates some headers for us:
### Code start ###
import os
for i in range(10):
if not os.path.exists('build_dir'):
os.mkdir('build_dir')
f = open('build_dir/hdr{}.h'.format(i),'w')
f.write('#define num{} {}\n'.format(i,i))
f.close()
### Code end ###

And then we have our test app (test.c):
### Code start ###
#include <stdio.h>
#include "hdr1.h"
#include "hdr3.h"
int main()
{
printf("the value of num1 is %d\n", num1);
}
### Code end ###

Now when we run make, it manages to copy and install the headers without
actually knowing in advance what header files we were going to put in
build_dir:
% make
./genhdrs.py
mkdir -p inc
cp build_dir/*.h inc/
gcc -Iinc -o test test.c

So this might seem like a contrived example but this is exactly what's
going to happen when your software depends on some third party library.
Lets say for example we want to build our application with a certain
version of boost.
So we run the boost build commands in a Command builder:

env.Command('some/install/dir/.boost_built', [],
['./bootstrap.sh --prefix=some/install/dir',
'./b2 install'])

Now we might want to only Install() a subset of the libraries that get
produced in some/install/dir/lib to be packaged into your final application.
I would have thought this would be a very common thing to do with a build
system.
So is Marc correct in saying that there is no way to do that without
listing every single file that boost produces?
Is there no "pattern" on how to do this without shooting yourself in the
foot?

Regards,
Pico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20131129/b5ce4e3e/attachment.htm


More information about the Scons-users mailing list