I'm porting a reasonably sized C++ application to the zig build system. The source tree is laid out like this:
├── src
│ ├── Common
│ │ └── include
│ ├── Core
│ │ ├── include
│ │ └── ...
│ ├── Plugins.Win32.Etc
│ │ └── ...
│ ├── Views.Win32
│ │ ├── include
│ │ └── ...
├── vendor
┆ ┆── ...
Core depends on Common, Views.Win32 depends on Common, and the plugins depend on Views.Win32, and all the vendored libs which are whatever
I thought it would be a good idea to have a separate build.zig for each submodule. Instead of using addLibrary or addExecutable, I use addModule to deal with the source files and addNamedLazyPath to add the include path, and consolidate everything at the root.
exe.root_module.addIncludePath(common_dep.namedLazyPath("include"));
exe.root_module.addIncludePath(core_dep.namedLazyPath("include"));
exe.root_module.addIncludePath(views_win32_dep.namedLazyPath("include"));
exe.root_module.addImport("", core_dep.module("Core"));
exe.root_module.addImport("", views_win32_dep.module("Views.Win32"));
It works, but is this a stupid idea??? Is there something less stupid I should be doing instead of this???