[build2] Help with build2 project with subdirectories

Boris Kolpackov boris at codesynthesis.com
Tue Aug 22 09:54:24 UTC 2023


Matheus D via users <users at build2.org> writes:

> On 23/08/21 10:03AM, Boris Kolpackov wrote:
> > Matheus D via users <users at build2.org> writes:
> > 
> > > A more accurate tree
> > > 
> > > .
> > > ├── build/
> > > │   ├── ...
> > > ├── buildfile
> > > ├── manifest
> > > ├── README.md
> > > ├── repositories.manifest
> > > └── sakyra/
> > >     ├── ds/
> > >     │   ├── list.c
> > >     │   ├── list.h
> > >     ├── external/
> > >     │   ├── miniaudio/
> > >     │   │   ├── miniaudio.h
> > >     │   ├── VulkanMemoryAllocator/
> > >     │   │   ├── vk_mem_alloc.h
> > >     │   ├── json.h
> > >     │   ├── stb_rect_pack.h
> > >     │   ├── stb_truetype.h
> > >     │   ├── stb_vorbis.h
> > >     ├── extras/
> > >     │   ├── audio.c
> > >     │   ├── audio.h
> > >     │   ├── text.c
> > >     │   ├── text.h
> > >     ├── buildfile
> > >     ├── engine.c
> > >     ├── engine.h
> > >     ├── export.h
> > >     ├── file.c
> > >     ├── file.h
> > >     └── version.h.in
> > >
>
> $src_base/external worked, thanks, I didn't know about the $src_base,
> there's $src_root, which
> is set to "src_root = /home/USER/work/sakyra-build2/sakyra/", so
> shouldn't "-I$src_root" work?

Based on the above tree, src_root should be /home/USER/work/sakyra-build2/,
that is, the root of the project (the directory where the build/
subdirectory resides).

If it's not, then there is something off about your structure that is
not shown in the above listing (or you explicitly switch scopes in
sakyra/buildfile).


> I include each header as "#include <sakyra/external/stb_rect_pack.h>",

If you include your headers as <sakyra/...> then yes, -I$src_root should
have worked. And -I$src_base/external shouldn't have helped. So perhaps
you include them both ways?


> looking at --dump, both $src_base and $src_root are the same, and the
> full path made me thing it would work regardless of the configuration.

They are only the same for the root scope of the project (which
corresponds to the root directory of the project). Based in the above
listing, the values of these variables as seen from sakyra/buildfile
should be:

src_root = /home/USER/work/sakyra-build2/
src_base = /home/USER/work/sakyra-build2/sakyra/

For background on what all this means, see:

https://build2.org/build2/doc/build2-build-system-manual.xhtml#intro-dirs-scopes



More information about the users mailing list