5.3. Printing Node File Names

One of the most common things you can do with a Node is use it to print the file name that the node represents. For example, the following SConstruct file:


      hello_c = File('hello.c')
      Program(hello_c)

      classes = Dir('classes')
      Java(classes, 'src')

      object_list = Object('hello.c')
      program_list = Program(object_list)
      print "The object file is:", object_list[0]
      print "The program file is:", program_list[0]
    

Would print the following file names on a POSIX system:


      % scons -Q
      The object file is: hello.o
      The program file is: hello
      cc -o hello.o -c hello.c
      cc -o hello hello.o
    

And the following file names on a Windows system:


      C:\>scons -Q
      The object file is: hello.obj
      The program file is: hello.exe
      cl /nologo /c hello.c /Fohello.obj
      link /nologo /OUT:hello.exe hello.obj