Reputation: 129
The directory hierarchy is like below.
├── prog_1
│ ├── hello.c
│ └── SConscript
└── folder
└── SConstruct
I tried to use the SConstruct to build the hello.c under prog_1, the SConstruct is as below:
SConscript('../prog_1/SConscript')
And the SConscript under prog_1 is as below:
Program('hello.c')
Whatever the absolute path or relative path to hello.c, I have tried but the scons will not recognize the path, it just ignored the SConscript specified under prog_1 and finished the build process. Is there any solution to make scons to enter other directory like this(non-subdirectory of SConstruct)?
Upvotes: 3
Views: 2170
Reputation: 3511
SConscript('../prog_1/SConscript')
Change the SConscript under prog_1 is as below:
Default(Program('hello.c'))
Assuming you run scons in directory "folder", SCons will only try to build targets in the current directory or a subdirectory by default.
If you wish to have targets outside (in sibling or other directory trees), you need to either indicate in their SConscripts (Or in the SConstruct) that those targets should be built by default or run scons as
scons ../prog_1
Upvotes: 0
Reputation: 4052
SCons stays in the top-level folder of your build project by default. It doesn't "dive" into the single subfolders like make would do for example. Instead, all commands get constructed such that the folder-relative paths of source and target files you specify in a SConscript
, are expanded to be valid from the top-level SConstruct
. The background for this is, that SCons tries to avoid "chdir
"s as much as possible such that builds can run fully in parallel.
Also by default, SCons will only build the files in the top-level folder or below, see #2 of our most frequently-asked frequently asked questions. In your case this is the folder "folder
", where the SConstruct
resides. The targets "prog_1
" and "hello
" are "outside the build tree" in this moment.
You can either explicitly specify a target each time you're calling SCons:
scons ../prog_1
, or move the "prog_1
" folder down into the "folder
" directory.
Please also read up on hierarchical and variant builds in chapters 14 and 15 of our User Guide.
Upvotes: 3