@@ -22,36 +22,45 @@ env.CommandNoCache(
22
22
),
23
23
)
24
24
25
- # Header to be included in `tests/test_main.cpp` to run module-specific tests.
26
- if env ["tests" ]:
27
- env .Depends ("modules_tests.gen.h" , Value (env .module_list ))
28
- env .CommandNoCache (
29
- "modules_tests.gen.h" ,
30
- Value (env .module_list ),
31
- env .Run (
32
- modules_builders .generate_modules_tests ,
33
- "Generating modules tests header." ,
34
- # NOTE: No need to run in subprocess since this is still executed serially.
35
- subprocess = False ,
36
- ),
37
- )
38
- env .AlwaysBuild ("modules_tests.gen.h" )
39
25
40
26
vs_sources = []
27
+ test_headers = []
41
28
# libmodule_<name>.a for each active module.
42
29
for name , path in env .module_list .items ():
43
30
env .modules_sources = []
44
31
45
- if not os .path .isabs (path ):
46
- SConscript (name + "/SCsub" ) # Built-in.
47
- else :
48
- SConscript (path + "/SCsub" ) # Custom.
32
+ # Name for built-in modules, (absolute) path for custom ones.
33
+ base_path = path if os .path .isabs (path ) else name
34
+ SConscript (base_path + "/SCsub" )
49
35
50
36
lib = env_modules .add_library ("module_%s" % name , env .modules_sources )
51
37
env .Prepend (LIBS = [lib ])
52
38
if env ["vsproj" ]:
53
39
vs_sources += env .modules_sources
54
40
41
+ if env ["tests" ]:
42
+ # Lookup potential headers in `tests` subfolder.
43
+ import glob
44
+
45
+ module_tests = sorted (glob .glob (os .path .join (base_path , "tests" , "*.h" )))
46
+ if module_tests != []:
47
+ test_headers += module_tests
48
+
49
+
50
+ # Generate header to be included in `tests/test_main.cpp` to run module-specific tests.
51
+ if env ["tests" ]:
52
+ env .Depends ("modules_tests.gen.h" , test_headers )
53
+ env .CommandNoCache (
54
+ "modules_tests.gen.h" ,
55
+ test_headers ,
56
+ env .Run (
57
+ modules_builders .generate_modules_tests ,
58
+ "Generating modules tests header." ,
59
+ # NOTE: No need to run in subprocess since this is still executed serially.
60
+ subprocess = False ,
61
+ ),
62
+ )
63
+
55
64
# libmodules.a with only register_module_types.
56
65
# Must be last so that all libmodule_<name>.a libraries are on the right side
57
66
# in the linker command.
0 commit comments