Bug 2884 - Regression/duplication after #2630
Regression/duplication after #2630
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: general
ns-3.27
All All
: P3 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-02-23 17:15 UTC by Alex Afanasyev
Modified: 2018-03-15 01:07 UTC (History)
1 user (show)

See Also:


Attachments
patch to remove code duplication in contrib/wscript (20.29 KB, patch)
2018-03-06 00:33 UTC, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Afanasyev 2018-02-23 17:15:32 UTC
Change #2630 (https://github.com/nsnam/ns-3-dev-git/commit/54b20047fdcbb07f5d7ce0f094a4c6b5b476c882) introduces contrib/ folder, copying a lot of code of `src/wscript` to `contrib/wscript`.  The effect of this is that most of the definitions in src/wscript (I discovered it regarding `@TaskGen.feature('ns3pcfile')`) are not effective---as they were already defined in the included contrib/wscript, definition in src/wscript is ignored.

My suggestion is to either revert the change or abstract common elements to a helper waf script, ensuring that code (and relevant changes if any) are not duplicated.
Comment 1 Tom Henderson 2018-02-24 17:18:49 UTC
I am working on a new patch to fix.
Comment 2 Alex Afanasyev 2018-02-24 18:39:07 UTC
Great. Can you also include the following patch to support export of include paths for the installed modules in .pc file:

diff --git a/src/wscript b/src/wscript
index 5e1b791b8..5c20ffa77 100644
--- a/src/wscript
+++ b/src/wscript
@@ -385,9 +385,9 @@ class ns3pcfile_task(Task.Task):
 
     def _includes(self, dep):
         includes = self.env['INCLUDES_%s' % dep]
-        return [self.env['CPPPATH_ST'] % include for include in includes]
+        return [self.env['CPPPATH_ST'] % include for include in Utils.to_list(includes)]
 
-    def _generate_pcfile(self, name, use, env, outfilename):
+    def _generate_pcfile(self, name, use, env, outfilename, module):
         outfile = open(outfilename, 'wt')
         prefix = env.PREFIX
         includedir = Utils.subst_vars('${INCLUDEDIR}/%s%s' % (wutils.APPNAME, wutils.VERSION), env)
@@ -398,6 +398,10 @@ class ns3pcfile_task(Task.Task):
         for dep in env.LIBS:
             libs += self.env['LIB_ST'] % dep
         cflags = [self.env['CPPPATH_ST'] % '${includedir}']
+
+        if getattr(module, 'export_includes', None):
+            for include in module.to_incnodes(module.export_includes):
+                cflags += [self.env['CPPPATH_ST'] % include.abspath()]
         requires = []
         for dep in use:
             cflags = cflags + self._cflags(dep) + self._cxxflags(dep) + \
@@ -424,7 +428,7 @@ Requires: %s\
         output_filename = self.outputs[0].abspath()
         self._generate_pcfile(self.module.name, 
                               self.module.to_list(self.module.use),
-                              self.env, output_filename)
+                              self.env, output_filename, self.module)
 
 
 @TaskGen.feature('ns3pcfile')
Comment 3 Tom Henderson 2018-03-06 00:30:51 UTC
I pushed the above patch to ns-3-dev in 13392:ddd44291f7b3; leaving open for the contrib/ code duplication.
Comment 4 Tom Henderson 2018-03-06 00:33:08 UTC
Created attachment 3078 [details]
patch to remove code duplication in contrib/wscript

I was able to reduce some of the duplicated code, including what I think was bothering you.  Would you mind testing this patch?
Comment 5 Alex Afanasyev 2018-03-11 12:38:55 UTC
It was creating a bit of a problem with my pcfile customization.  I checked, with the patch, everything seem to work properly.

I suggest one more small patch, that not directly related (removing \n in task description in a few places):

diff --git a/src/wscript b/src/wscript
index 5997e8038..1b004ef60 100644
--- a/src/wscript
+++ b/src/wscript
@@ -336,7 +336,7 @@ class ns3pcfile_task(Task.Task):
     def __str__(self):
         "string to display to the user"
         tgt_str = ' '.join([a.bldpath() for a in self.outputs])
-        return 'pcfile: %s\n' % (tgt_str)
+        return 'pcfile: %s' % (tgt_str)

     def runnable_status(self):
         return super(ns3pcfile_task, self).runnable_status()
diff --git a/waf-tools/command.py b/waf-tools/command.py
index e47a6043c..dcfb6af9f 100644
--- a/waf-tools/command.py
+++ b/waf-tools/command.py
@@ -31,7 +31,7 @@ class command_task(Task.Task):
                pipeline = shellcmd.Pipeline()
                pipeline.parse(self.generator.command)
                cmd = pipeline.get_abbreviated_command()
-               return 'command (%s): %s%s%s\n' % (cmd, src_str, sep, tgt_str)
+               return 'command (%s): %s%s%s' % (cmd, src_str, sep, tgt_str)

        def _subst_arg(self, arg, direction, namespace):
                """
Comment 6 Tom Henderson 2018-03-15 01:07:19 UTC
fixed in changesets 13411 and 13412:6ff8a70148e0