Search code examples
variablesdirectorycommandsconsexpansion

Scons "Dir" command doesn't work?


I've got a sub directory called "myc" containing 2 ".c" files:

$ ls myc
1.c  f.c

And my current directory has a SConstruct:

$ cat SConstruct 
myc=Dir('myc')
print myc
Program('test2',myc)

Run scons, it prints a bunch of errors:

$ scons
scons: Reading SConscript files ...
myc
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test2 myc
/usr/bin/ld: cannot find myc: File format not recognized
collect2: error: ld returned 1 exit status
scons: *** [test2] Error 1
scons: building terminated because of errors.

What is weird: I expect the "print myc" will list "1.c" and "f.c", to my disappointment it prints "myc", not the varible value, and the compiling also fails.

How to correct it?


Solution

  • Not sure why you believe that specifying a directory as the source(s) for a directory would work?

    Is there something in the docs which makes you believe this should work?

    If so, please point it out so it can be improved.

    If you did:

    gcc -o blah some_dir_name

    That wouldn't work right?

    This should do what you're asking for.

    myc=Glob('myc/*.c')
    print myc
    Program('test2',myc)