diff options
author | Andrii Doroshenko (Xrayez) <xrayez@gmail.com> | 2021-03-08 18:02:12 +0200 |
---|---|---|
committer | Andrii Doroshenko (Xrayez) <xrayez@gmail.com> | 2021-03-08 19:36:26 +0200 |
commit | f712d68ceb38c3a1b2c20da395c9882a2c871fb7 (patch) | |
tree | 338cf5442fc6f81c9b20a01bc07a1faa0de6ccab | |
parent | 45c6d3c5767f0ebc60ef1334aec5720680191eec (diff) |
Provide additional include paths for custom modules
Allows to use a module as a library, where an include path may start
with module's name itself.
-rw-r--r-- | SConstruct | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/SConstruct b/SConstruct index 000c918808..a7f554506b 100644 --- a/SConstruct +++ b/SConstruct @@ -242,13 +242,16 @@ for path in module_search_paths: # Built-in modules don't have nested modules, # so save the time it takes to parse directories. modules = methods.detect_modules(path, recursive=False) - else: # External. + else: # Custom. modules = methods.detect_modules(path, env_base["custom_modules_recursive"]) + # Provide default include path for both the custom module search `path` + # and the base directory containing custom modules, as it may be different + # from the built-in "modules" name (e.g. "custom_modules/summator/summator.h"), + # so it can be referenced simply as `#include "summator/summator.h"` + # independently of where a module is located on user's filesystem. + env_base.Prepend(CPPPATH=[path, os.path.dirname(path)]) # Note: custom modules can override built-in ones. modules_detected.update(modules) - include_path = os.path.dirname(path) - if include_path: - env_base.Prepend(CPPPATH=[include_path]) # Add module options. for name, path in modules_detected.items(): |