Test implicitly dependent modules
authorMitch Watrous <watrous@u.washington.edu>
Mon, 21 Mar 2011 11:26:56 -0700
changeset 6925 43d9c7eedf7b
parent 6924 1a26f3cd6f5f
child 6930 8406f75b430e
Test implicitly dependent modules
src/wscript
wscript
--- a/src/wscript	Sun Mar 20 16:32:46 2011 -0700
+++ b/src/wscript	Mon Mar 21 11:26:56 2011 -0700
@@ -143,11 +143,8 @@
     library.is_ns3_module_test_library = True
     library.module_name = 'ns3-' + name
 
-    # Add this test library and module to the lists if the module is
-    # enabled.
-    if library.module_name in bld.env['NS3_ENABLED_MODULES']:
-        bld.env.append_value('NS3_ENABLED_MODULES_WITH_TEST_LIBRARIES', library.module_name)
-        bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', library.name)
+    # Add this module and test library to the list.
+    bld.env.append_value('NS3_MODULES_WITH_TEST_LIBRARIES', (library.module_name, library.name))
 
     # Set the include path from the build directory to modules. 
     relative_path_from_build_to_here = bld.path.relpath_gen(bld.bldnode)
--- a/wscript	Sun Mar 20 16:32:46 2011 -0700
+++ b/wscript	Mon Mar 21 11:26:56 2011 -0700
@@ -537,7 +537,7 @@
 
 
 def build(bld):
-    bld.env['NS3_ENABLED_MODULES_WITH_TEST_LIBRARIES'] = []
+    bld.env['NS3_MODULES_WITH_TEST_LIBRARIES'] = []
     bld.env['NS3_ENABLED_MODULE_TEST_LIBRARIES'] = []
 
     wutils.bld = bld
@@ -559,22 +559,11 @@
     # process subfolders from here
     bld.add_subdirs('src')
     bld.add_subdirs('samples')
-    bld.add_subdirs('utils')
 
-    add_examples_programs(bld)
-    add_scratch_programs(bld)
-
-    ## if --enabled-modules option was given, we disable building the
-    ## modules that were not enabled, and programs that depend on
-    ## disabled modules.
     env = bld.env
 
-    if Options.options.enable_modules:
-        Logs.warn("the option --enable-modules is being applied to this build only;"
-                       " to make it permanent it needs to be given to waf configure.")
-        env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
-                                      Options.options.enable_modules.split(',')]
-
+    # If modules have been enabled, then set lists of enabled modules
+    # and enabled module test libraries.
     if env['NS3_ENABLED_MODULES']:
         modules = env['NS3_ENABLED_MODULES']
 
@@ -598,7 +587,30 @@
         env['NS3_ENABLED_MODULES'] = modules
         print "Modules to build:", modules
 
-        print "Modules to test:", env['NS3_ENABLED_MODULES_WITH_TEST_LIBRARIES']
+        # Set the list of the enabled module test libraries.
+        for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
+            if mod in bld.env['NS3_ENABLED_MODULES']:
+                bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', testlib)
+
+    # Process this subfolder here after the lists of enabled modules
+    # and module test libraries have been set.
+    bld.add_subdirs('utils')
+
+    add_examples_programs(bld)
+    add_scratch_programs(bld)
+
+    ## if --enabled-modules option was given, we disable building the
+    ## modules that were not enabled, and programs that depend on
+    ## disabled modules.
+
+    if Options.options.enable_modules:
+        Logs.warn("the option --enable-modules is being applied to this build only;"
+                       " to make it permanent it needs to be given to waf configure.")
+        env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
+                                      Options.options.enable_modules.split(',')]
+
+    if env['NS3_ENABLED_MODULES']:
+        modules = env['NS3_ENABLED_MODULES']
 
         def exclude_taskgen(bld, taskgen):
             # ok, so WAF does not provide an API to prevent an