Building relative to src/ directory with SCons -
i have app following (i have thought quite common) directory hierarchy:
/src subdir1/ # subdirs more source files. more.c sconscript foo.c # source files. foo.h sconscript /other # other top-level directories no source code. /stuff # however, there other assets may want build. readme # other top-level files. sconstruct
the problem when run scons
top-level directory, calls gcc
directory without cd
ing src
, this:
gcc -o src/foo.o src/foo.c
this problematic several reasons:
- within program,
#include
files giving path relativesrc
directory. example,more.c
includefoo.h
#include "foo.h"
. fails because gcc run parent directory. don't want change includes#include "src/foo.h"
. - i use
__file__
special macro things logging. when built top-level directory, gcc puts "src/
" @ front of filenames, since path given compile. may seem picky, don't want that, because think of source tree being relativesrc
directory.
(edit: should add #1 can fixed adding -isrc
flag gcc, seems more hacks around main issue.)
how can make scons cd
src
directory before calling gcc
?
- i don't want rid of
src
directory , move up, because there lots of other (non-code) files @ top level. - i don't want scons
cd
every subdirectory. shouldcd
src
, build files in hierarchy there. - i solve moving
sconscript
insidesrc
directory , running there, perhaps usingmakefile
@ top level. seems quite hacky, , want use scons build (non-code) assets in other directoriessrc
.
i've read can make custom builder
, make change directories. however, not want write whole new builder
c/c++. there way modify behaviour of existing builder without writing 1 scratch? also, on 1 forum, said changing directories within builder
break parallel builds since change directory other tasks building from. true?
this behavior how scons works, , not possible avoid/change. i've been looking supporting documentation in favor, , havent found any. ive become used to.
as mention, include paths simple fix. harder part __file__
macro. hadnt ever noticed until mentioned it. unfortunately, think way around strip path in logger, rather ugly fix.
Comments
Post a Comment