Help needed for converting a wscript file to Cmakelists file

328 views
Skip to first unread message

Shadab Mahboob

unread,
Nov 4, 2022, 8:34:07 AM11/4/22
to ns-3-users
Dear all,

I am currently working on ns 3.35 which uses waf builder for building the files. I have decided to move the latest version of ns3 , which is ns 3.36, but this uses ./ns3. I have an external module to be integrated with this for my work that has a wscript file with some pre compiler functions. As I have not worked with this before, what conversions are needed to use it in ns 3.36?

Here is the part of the wscript file I want to convert for using it the module in ns 3.36 instead of ns 3.35:

import os
import os.path
import re

def compile_generator(bld):
  base_path = 'contrib/satellite/model'
  data_path = '%s/data' % (base_path)
  cxxflags = ' '.join(str(x) for x in bld.env['CXXFLAGS'])
  cxx = bld.env['COMPILER_CXX']
  src = '%s/constants-gen.cc' % data_path
  dst = '%s/cgen' % data_path
  header = '%s/iers-data.h' % (base_path)
  source = '%s/iers-data.cc' % (base_path)

  if not os.path.isfile(dst):
    #print('%s %s %s -o %s' % (cxx, src, cxxflags, dst))
    bld.exec_command('%s %s %s -o %s' % (cxx, cxxflags, src, dst))

  bld.exec_command('./%s header %s' % (dst, base_path))
  bld.exec_command('./%s source %s' % (dst, base_path))

 bld.add_pre_fun(compile_generator)


Any help will be appreciated, thanks in advance.

Sincerely
Shadab

Tom Henderson

unread,
Nov 5, 2022, 10:28:33 AM11/5/22
to ns-3-...@googlegroups.com
Are you asking about conversions for this module?


Is there a published version of this posted anywhere for ns-3.35?

- Tom
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/0630c9cc-bd3c-4c85-b163-cbad2bca960an%40googlegroups.com.


Shadab Mahboob

unread,
Nov 5, 2022, 12:07:31 PM11/5/22
to ns-3-...@googlegroups.com
Hi Tom,

Yes, you are right. I am asking for this one. I could not find any published version of this module. It looks like this may have not been accepted in ns3 main branch or the authors did not proceed with it. 

As I am working on LEO satellite communication for my research, a mobility model based on SGP4 is needed for my case. That is why I have been using this, which works fine in ns-3.35, but not in ns-3.36.1. The issue lies in the change in build systems.

Is there any way you can help me with this?

Best regards

Shadab Mahboob

Electrical and Computer Engineering,
Virginia Tech.

You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/sF5GabRaeVo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/c064bd88-1113-cf2a-908c-9810a64c7e26%40tomh.org.

Gabriel Ferreira

unread,
Nov 5, 2022, 1:40:36 PM11/5/22
to ns-3-users
Something like this should do it:

#def compile_generator(bld):
# base_path = 'contrib/satellite/model' 
# data_path = '%s/data' % (base_path)
# cxxflags = ' '.join(str(x) for x in bld.env['CXXFLAGS']) 
# cxx = bld.env['COMPILER_CXX'] 
# src = '%s/constants-gen.cc' % data_path 
# dst = '%s/cgen' % data_path

# header = '%s/iers-data.h' % (base_path) 
# source = '%s/iers-data.cc' % (base_path) 

set(base_path ${CMAKE_CURRENT_SOURCE_DIR}/model)
set(data_path ${base_path}/data)
set(src ${data_path}/constants-gen.cc)
set(header ${base_path}/iers-data.h)
set(source ${base_path}/iers-data.cc)

 # if not os.path.isfile(dst):
 #  #print('%s %s %s -o %s' % (cxx, src, cxxflags, dst))
 # bld.exec_command('%s %s %s -o %s' % (cxx, cxxflags, src, dst))
add_executable(cgen ${src})
set_target_properties(cgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${data_path})

#  bld.exec_command('./%s header %s' % (dst, base_path))
#  bld.exec_command('./%s source %s' % (dst, base_path))
add_custom_command(OUTPUT ${header} ${source}
                                            COMMAND ${data_path}/cgen header ./
                                            COMMAND ${data_path}/cgen source ./
                                            WORKING_DIRECTORY ${base_path}
                                            DEPENDS cgen
)

Then continue with

build_lib(
LIBNAME satellite
SOURCE_FILES ${source}
                             ...
HEADER_FILES ${header}
                            ...
LIBRARIES_TO_LINK ${libcore}
                                      ${libmobility}
...
)

Shadab Mahboob

unread,
Nov 5, 2022, 3:45:20 PM11/5/22
to ns-3-users
Hi Gabriel,

Thank you so much for your help! I really appreciate the way you have helped me in this conversion. However, when I try to configure the build again, I get the following error:

CMake Error at build-support/custom-modules/ns3-module-macros.cmake:453 (add_dependencies):
  Cannot add target-level dependencies to non-existent target
  "libvisualizer".

  The add_dependencies works for top-level logical targets created by the
  add_executable, add_library, or add_custom_target commands.  If you want to
  add file-level dependencies see the DEPENDS option of the add_custom_target
  and add_custom_command commands.
Call Stack (most recent call first):
  contrib/satellite/CMakeLists.txt:41 (build_lib)

I am adding the CMakeLists.txt file with this email as I have modified as per the suggestions from you. I am also attaching the module folder with this email. Let me know if you have any insight about this issue. Thanks again for the help!

Best Regards
Shadab
CMakeLists.txt
satellite.zip

Gabriel Ferreira

unread,
Nov 5, 2022, 3:56:05 PM11/5/22
to ns-3-users
Remove libvisualizer from libraries_to_link. It gets linked automatically when enabled. 

Shadab Mahboob

unread,
Nov 5, 2022, 3:58:19 PM11/5/22
to ns-3-...@googlegroups.com
Hi Gabriel,

I just figured out that I put some unnecessary python bindings files, not sure when I put these. After removing these and also the libvisualizer, I am not getting any error. Thank you so much for your help. This was a great help.

Best Regards
Shadab


Shadab Mahboob

unread,
Nov 5, 2022, 4:41:52 PM11/5/22
to ns-3-...@googlegroups.com
Hi Gabriel,

Sorry to bother you again. After configuring the build, when I try to build the ns3 project by putting satellite folder in the src directory, the tai-utc.dat file cannot be opened. So the build is not complete. I tried giving the read, write and execute permission to the files constants-gen.cc, tai-utc.dat and finals.dat, but it did not work. Any suggestions?

Sincerely 

Shadab Mahboob

Electrical and Computer Engineering,
Virginia Tech.

Shadab Mahboob

unread,
Nov 5, 2022, 4:43:18 PM11/5/22
to ns-3-...@googlegroups.com
Here is the folder.

Sincerely 

Shadab Mahboob

Electrical and Computer Engineering,
Virginia Tech.

satellite.zip

Shadab Mahboob

unread,
Nov 5, 2022, 4:46:26 PM11/5/22
to ns-3-...@googlegroups.com
Ignore the last email. This is the actual folder where tai-utc.dat cannot be opened.

Sincerely 

Shadab Mahboob

Electrical and Computer Engineering,
Virginia Tech.

satellite.zip

Shadab Mahboob

unread,
Nov 5, 2022, 5:12:01 PM11/5/22
to ns-3-...@googlegroups.com
I think I have resolved it. I just needed to change the base path in constants-gen.cc for opening tai-utc.data and finals.data. Thank you so much.

Sincerely 

Shadab Mahboob

Electrical and Computer Engineering,
Virginia Tech.

Reply all
Reply to author
Forward
0 new messages