From 3c4019304adea11339e01768704ec8ac48a98924 Mon Sep 17 00:00:00 2001 From: Nakayama Kenjiro Date: Sun, 2 Jun 2024 07:46:55 +0000 Subject: [PATCH] build: Enable BSD support --- build-support/custom-modules/ns3-lock.cmake | 2 ++ build-support/custom-modules/ns3-platform-support.cmake | 6 +++++- build-support/macros-and-definitions.cmake | 6 +++++- ns3 | 4 +++- src/network/utils/ipv4-address.cc | 1 + src/network/utils/ipv6-address.cc | 1 + test.py | 8 +++++--- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/build-support/custom-modules/ns3-lock.cmake b/build-support/custom-modules/ns3-lock.cmake index e28a493e3..c4765b03d 100644 --- a/build-support/custom-modules/ns3-lock.cmake +++ b/build-support/custom-modules/ns3-lock.cmake @@ -126,6 +126,8 @@ function(write_lock) set(lock_filename .lock-ns3_darwin_build) elseif(WIN32) set(lock_filename .lock-ns3_win32_build) + elseif(BSD) + set(lock_filename .lock-ns3_bsd_build) else() message(FATAL_ERROR "Platform not supported") endif() diff --git a/build-support/custom-modules/ns3-platform-support.cmake b/build-support/custom-modules/ns3-platform-support.cmake index bc83344e5..caedd2ee4 100644 --- a/build-support/custom-modules/ns3-platform-support.cmake +++ b/build-support/custom-modules/ns3-platform-support.cmake @@ -30,7 +30,11 @@ endif() # Set Linux flag if on Linux if(UNIX AND NOT APPLE) - set(LINUX TRUE) + if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set(LINUX TRUE) + else() + set(BSD TRUE) + endif() add_definitions(-D__LINUX__) endif() diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 97797231f..c893d5b02 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -1159,7 +1159,11 @@ macro(process_options) set(PLATFORM_UNSUPPORTED_POST "features. Continuing without them.") # Remove from libs_to_build all incompatible libraries or the ones that # dependencies couldn't be installed - if(APPLE OR WSLv1 OR WIN32) + if(APPLE + OR WSLv1 + OR WIN32 + OR BSD + ) set(ENABLE_TAP OFF) set(ENABLE_EMU OFF) set(ENABLE_FDNETDEV FALSE) diff --git a/ns3 b/ns3 index 190a5fe71..7862ee990 100755 --- a/ns3 +++ b/ns3 @@ -13,7 +13,9 @@ import sys ns3_path = os.path.dirname(os.path.realpath(os.path.abspath(__file__))) append_to_ns3_path = functools.partial(os.path.join, ns3_path) out_dir = os.sep.join([ns3_path, "build"]) -lock_file = os.sep.join([ns3_path, ".lock-ns3_%s_build" % sys.platform]) +platform = sys.platform +platform = "bsd" if "bsd" in platform else platform +lock_file = os.sep.join([ns3_path, ".lock-ns3_%s_build" % platform]) max_cpu_threads = max(1, os.cpu_count() - 1) print_buffer = "" diff --git a/src/network/utils/ipv4-address.cc b/src/network/utils/ipv4-address.cc index 6bdaee213..08d23ef18 100644 --- a/src/network/utils/ipv4-address.cc +++ b/src/network/utils/ipv4-address.cc @@ -28,6 +28,7 @@ #include #else #include +#include #endif namespace ns3 diff --git a/src/network/utils/ipv6-address.cc b/src/network/utils/ipv6-address.cc index d01962f36..72abefb8d 100644 --- a/src/network/utils/ipv6-address.cc +++ b/src/network/utils/ipv6-address.cc @@ -33,6 +33,7 @@ #include #else #include +#include #endif namespace ns3 diff --git a/test.py b/test.py index 20a4ad681..65da02516 100755 --- a/test.py +++ b/test.py @@ -664,9 +664,12 @@ def sigint_hook(signal, frame): # little less hacky, we should add a command to ns3 to return this info # and use that result. # -def read_ns3_config(): - lock_filename = ".lock-ns3_%s_build" % sys.platform +platform = sys.platform +platform = "bsd" if "bsd" in platform else platform +lock_filename = ".lock-ns3_%s_build" % platform + +def read_ns3_config(): try: # sys.platform reports linux2 for python2 and linux for python3 with open(lock_filename, "rt", encoding="utf-8") as f: @@ -1260,7 +1263,6 @@ def run_tests(): # # Get the information from the build status file. # - lock_filename = ".lock-ns3_%s_build" % sys.platform if os.path.exists(lock_filename): ns3_runnable_programs = get_list_from_file(lock_filename, "ns3_runnable_programs") ns3_runnable_scripts = get_list_from_file(lock_filename, "ns3_runnable_scripts")