Skip to content

Commit

Permalink
feat: provide dev mode where src files are not deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
hoelger committed Nov 19, 2024
1 parent 4ac6dc7 commit c33a31b
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions bundle/src/assembly/resources/fed/ns3/ns3_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ arg_ns3_file=""
arg_federate_file=""
arg_integration_testing=false
arg_make_parallel=""
arg_dev=false # set manually // do NOT remove src code after installation

required_programs_display=( python3 gcc unzip tar protobuf-compiler )
required_programs_test=( python3 gcc unzip tar protoc )
Expand Down Expand Up @@ -355,24 +356,28 @@ extract_premake() {
cd "$oldpwd"
}

patch_ns3()
copy_runfile()
{
### copy the run file
cp -f "./federate/run.sh" "$ns3_installation_path/run.sh"
chmod +x "$ns3_installation_path/run.sh"

if [ "$arg_dev" == "true" ]; then
sed -i -e 's|LD_LIBRARY_PATH=../ns-allinone-$ns3Version/ns-$ns3Version/build|LD_LIBRARY_PATH=../ns-allinone-$ns3Version/ns-$ns3Version/build/lib|' "$ns3_installation_path/run.sh"
fi
}

build_ns3()
{
current_dir=`pwd`
log "BUILD ns3 version ${ns3_version}"
log "Build ns3 version ${ns3_version}"
cd "${ns3_installation_path}/ns-allinone-${ns3_version}"

# ns-3 prior to 3.28.1 does not compile without warnings using g++ 10.2.0
CXXFLAGS="-Wno-error" python3 ./build.py --disable-netanim
}

build_ns3_federate()
{
log "Build ns3-federate"
cd ${current_dir}/federate
cd ${ns3_installation_path}/federate
mv src/ClientServerChannel.h .
mv src/ClientServerChannel.cc .

Expand Down Expand Up @@ -400,22 +405,27 @@ deploy_ns3()
{
if [ "$arg_deploy" == "true" ]; then
log "Deploying ns3 binaries"
cd "${ns3_installation_path}"

mkdir -p "$ns3_deploy_folder/build/scratch/"
if [ "$arg_dev" == "true" ]; then
# will copy 1.8GB instead of 470MB at beginning of each simulation run
cd "${ns3_installation_path}"
cp federate/bin/ns3-federate "$ns3_simulator_folder/build/scratch/mosaic_starter"
else
cd "${ns3_installation_path}"

mkdir -p "$ns3_deploy_folder/build/scratch/"

for i in $(find "${ns3_simulator_folder}/build/" -name "*.so"); do
cp "$i" "$ns3_deploy_folder/build/"
done

cp federate/bin/ns3-federate "$ns3_deploy_folder/build/scratch/mosaic_starter"
for i in $(find "${ns3_simulator_folder}/build/" -name "*.so"); do
cp "$i" "$ns3_deploy_folder/build/"
done

mkdir "${ns3_deploy_folder}/scratch"
cp federate/bin/ns3-federate "$ns3_deploy_folder/build/scratch/mosaic_starter"

rm -rf ${ns3_simulator_folder}
mv "${ns3_deploy_folder}" "${ns3_simulator_folder}"
mkdir "${ns3_deploy_folder}/scratch"

rm -rf ${ns3_simulator_folder}
mv "${ns3_deploy_folder}" "${ns3_simulator_folder}"
fi
fi
}

Expand Down Expand Up @@ -498,12 +508,13 @@ extract_ns3_federate

extract_premake

log "Applying patch for ns-3..."
patch_ns3
copy_runfile

log "Building ns-3..."
build_ns3
build_ns3_federate

log "Deploying ns-3..."
deploy_ns3

log "Set ns-3 debug-levels..."
Expand Down

0 comments on commit c33a31b

Please sign in to comment.