Skip to content

Commit

Permalink
[#254] Initial attempt to try to build in remote directory;
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucas9 committed Nov 15, 2024
1 parent 6b4e151 commit 6f6c1d0
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 101 deletions.
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
#
BUILDTYPE ?= debug
INSTALLPREFIX ?= exe
FSWBUILDDIR ?= $(CURDIR)/fsw/build
GSWBUILDDIR ?= $(CURDIR)/gsw/build
SIMBUILDDIR ?= $(CURDIR)/sims/build
NOS3BUILDDIR ?= /tmp/nos3
FSWBUILDDIR ?= $(NOS3BUILDDIR)/fsw
GSWBUILDDIR ?= $(NOS3BUILDDIR)/gsw
SIMBUILDDIR ?= $(NOS3BUILDDIR)/sims

export CFS_APP_PATH = ../components
export MISSION_DEFS = ../cfg/build/
export MISSIONCONFIG = ../cfg/build/nos3
export MISSION_DEFS = /tmp/nos3/cfg/nos3_defs
export MISSIONCONFIG = nos3

# The "prep" step requires extra options that are specified via enviroment variables.
# Certain special ones should be passed via cache (-D) options to CMake.
# These are only needed for the "prep" target but they are computed globally anyway.
PREP_OPTS :=
PREP_OPTS := -DMISSION_DEFS=$(MISSION_DEFS)

ifneq ($(INSTALLPREFIX),)
PREP_OPTS += -DCMAKE_INSTALL_PREFIX=$(INSTALLPREFIX)
Expand Down Expand Up @@ -48,21 +49,21 @@ all:

build-cryptolib:
mkdir -p $(GSWBUILDDIR)
cd $(GSWBUILDDIR) && cmake $(PREP_OPTS) -DSUPPORT=1 ../../components/cryptolib
cd $(GSWBUILDDIR) && cmake -DSUPPORT=1 $(CURDIR)/components/cryptolib
$(MAKE) --no-print-directory -C $(GSWBUILDDIR)

build-fsw:
ifeq ($(FLIGHT_SOFTWARE), fprime)
cd fsw/fprime/fprime-nos3 && fprime-util generate && fprime-util build
else
mkdir -p $(FSWBUILDDIR)
cd $(FSWBUILDDIR) && cmake $(PREP_OPTS) ../cfe
cd $(FSWBUILDDIR) && cmake $(PREP_OPTS) $(CURDIR)/fsw/cfe
$(MAKE) --no-print-directory -C $(FSWBUILDDIR) mission-install
endif

build-sim:
mkdir -p $(SIMBUILDDIR)
cd $(SIMBUILDDIR) && cmake -DCMAKE_INSTALL_PREFIX=$(SIMBUILDDIR) ..
cd $(SIMBUILDDIR) && cmake -DCMAKE_INSTALL_PREFIX=$(SIMBUILDDIR) $(CURDIR)/sims
$(MAKE) --no-print-directory -C $(SIMBUILDDIR) install

checkout:
Expand All @@ -72,22 +73,25 @@ clean:
$(MAKE) clean-fsw
$(MAKE) clean-sim
$(MAKE) clean-gsw
rm -rf cfg/build
./scripts/clean.sh
rm -rf $(NOS3BUILDDIR)

clean-fsw:
rm -rf cfg/build/nos3_defs
rm -rf fsw/build
rm -rf fsw/fprime/fprime-nos3/build-artifacts
rm -rf fsw/fprime/fprime-nos3/build-fprime-automatic-native
rm -rf fsw/fprime/fprime-nos3/fprime-venv
rm -rf $(FSWBUILDDIR)

clean-sim:
rm -rf sims/build
rm -rf $(SIMBUILDDIR)

clean-gsw:
rm -rf gsw/build
rm -rf gsw/cosmos/build
rm -rf /tmp/nos3
rm -rf $(GSWBUILDDIR)

config:
./scripts/cfg/config.sh
Expand All @@ -96,17 +100,17 @@ debug:
./scripts/debug.sh

fsw:
./cfg/build/fsw_build.sh
$(NOS3BUILDDIR)/cfg/fsw_build.sh $(CURDIR)

gsw:
./scripts/gsw/build_cryptolib.sh
./cfg/build/gsw_build.sh
$(NOS3BUILDDIR)/cfg/gsw_build.sh $(CURDIR)

igniter:
./scripts/igniter_launch.sh

launch:
./cfg/build/launch.sh
$(NOS3BUILDDIR)/cfg/launch.sh $(CURDIR)

log:
./scripts/log.sh
Expand Down
2 changes: 1 addition & 1 deletion cfg/nos3_defs/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ list(APPEND MISSION_GLOBAL_APPLIST
fm
lc
sbn
sbn_tcp
sbn/modules/protocol/sbn_tcp
sbn_client
sc
sch
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_sim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ ! -d $USER_NOS3_DIR ]; then
fi

# Check that configure build directory exists
if [ ! -d $BASE_DIR/cfg/build ]; then
if [ ! -d $USER_NOS3_BUILD_DIR/cfg ]; then
echo ""
echo " Need to run make config first!"
echo ""
Expand All @@ -26,4 +26,4 @@ fi

chmod g+s $BASE_DIR/sims
mkdir -p $BASE_DIR/sims/build
$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR --name "nos_build_sim" -w $BASE_DIR $DBOX make -j$NUM_CPUS build-sim
$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR -v $USER_NOS3_BUILD_DIR:$USER_NOS3_BUILD_DIR --name "nos_build_sim" -w $BASE_DIR $DBOX make -j$NUM_CPUS build-sim
8 changes: 4 additions & 4 deletions scripts/cfg/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/../env.sh

# Make flight software configuration directory
mkdir -p $BASE_DIR/cfg/build
mkdir -p $USER_NOS3_BUILD_DIR/cfg

# Copy baseline configurations into build directory
cp -r $BASE_DIR/cfg/InOut $BASE_DIR/cfg/build/
cp -r $BASE_DIR/cfg/nos3_defs $BASE_DIR/cfg/build/
cp -r $BASE_DIR/cfg/sims $BASE_DIR/cfg/build/
cp -r $BASE_DIR/cfg/InOut $USER_NOS3_BUILD_DIR/cfg/
cp -r $BASE_DIR/cfg/nos3_defs $USER_NOS3_BUILD_DIR/cfg/
cp -r $BASE_DIR/cfg/sims $USER_NOS3_BUILD_DIR/cfg/

# Configure flight software
python3 $SCRIPT_DIR/cfg/configure.py
44 changes: 22 additions & 22 deletions scripts/cfg/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

if (fsw_cfg == 'fprime'):
fsw_identified = 1
os.system('cp ./scripts/fsw/fsw_fprime_build.sh ./cfg/build/fsw_build.sh')
os.system('cp ./scripts/fsw/fsw_fprime_launch.sh ./cfg/build/launch.sh')
os.system('cp ./scripts/fsw/fsw_fprime_build.sh /tmp/nos3/cfg/fsw_build.sh')
os.system('cp ./scripts/fsw/fsw_fprime_launch.sh /tmp/nos3/cfg/launch.sh')
if (fsw_cfg == 'cfs'):
fsw_identified = 1
os.system('cp ./scripts/fsw/fsw_cfs_build.sh ./cfg/build/fsw_build.sh')
os.system('cp ./scripts/fsw/fsw_cfs_launch.sh ./cfg/build/launch.sh')
os.system('cp ./scripts/fsw/fsw_cfs_build.sh /tmp/nos3/cfg/fsw_build.sh')
os.system('cp ./scripts/fsw/fsw_cfs_launch.sh /tmp/nos3/cfg/launch.sh')
if (fsw_identified == 0):
print('Invalid FSW in configuration file!')
print('Exiting due to error...')
Expand All @@ -41,25 +41,25 @@

gsw_identified = 0
if (gsw_cfg == 'openc3'):
# Copy openc3 scripts into ./cfg/build
# Copy openc3 scripts into /tmp/nos3
gsw_identified = 1
os.system('cp ./scripts/gsw/gsw_openc3_build.sh ./cfg/build/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_openc3_launch.sh ./cfg/build/gsw_launch.sh')
os.system('cp ./scripts/gsw/gsw_openc3_build.sh /tmp/nos3/cfg/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_openc3_launch.sh /tmp/nos3/cfg/gsw_launch.sh')
if (gsw_cfg == 'cosmos'):
# Copy cosmos scripts into ./cfg/build
# Copy cosmos scripts into /tmp/nos3
gsw_identified = 1
os.system('cp ./scripts/gsw/gsw_cosmos_build.sh ./cfg/build/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_cosmos_launch.sh ./cfg/build/gsw_launch.sh')
os.system('cp ./scripts/gsw/gsw_cosmos_build.sh /tmp/nos3/cfg/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_cosmos_launch.sh /tmp/nos3/cfg/gsw_launch.sh')
if (gsw_cfg == 'fprime'):
# Copy fprime scripts into ./cfg/build
# Copy fprime scripts into /tmp/nos3
gsw_identified = 1
os.system('cp ./scripts/gsw/gsw_fprime_build.sh ./cfg/build/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_fprime_launch.sh ./cfg/build/gsw_launch.sh')
os.system('cp ./scripts/gsw/gsw_fprime_build.sh /tmp/nos3/cfg/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_fprime_launch.sh /tmp/nos3/cfg/gsw_launch.sh')
if (gsw_cfg == 'ait'):
# Copy ait scripts into ./cfg/build
# Copy ait scripts into /tmp/nos3
gsw_identified = 1
os.system('cp ./scripts/gsw/gsw_ait_build.sh ./cfg/build/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_ait_launch.sh ./cfg/build/gsw_launch.sh')
os.system('cp ./scripts/gsw/gsw_ait_build.sh /tmp/nos3/cfg/gsw_build.sh')
os.system('cp ./scripts/gsw/gsw_ait_launch.sh /tmp/nos3/cfg/gsw_launch.sh')
if (gsw_identified == 0):
print('Invalid GSW in configuration file!')
print('Exiting due to error...')
Expand Down Expand Up @@ -242,7 +242,7 @@
lines.insert(sc_startup_eof, cf_line)

# Write startup script file
with open('./cfg/build/nos3_defs/cpu1_cfe_es_startup.scr', 'w') as fp:
with open('/tmp/nos3/cfg/nos3_defs/cpu1_cfe_es_startup.scr', 'w') as fp:
lines = "".join(lines)
fp.write(lines)

Expand Down Expand Up @@ -273,7 +273,7 @@
lines[date_index] = mission_start_time_utc.strftime('%m %d %Y') + ' ! Date (UTC) (Month, Day, Year)\n'
lines[time_index] = mission_start_time_utc.strftime('%H %M %S') + ' ! Time (UTC) (Hr,Min,Sec)\n'

with open('./cfg/build/InOut/Inp_Sim.txt', 'w') as fp:
with open('/tmp/nos3/cfg/InOut/Inp_Sim.txt', 'w') as fp:
lines = "".join(lines)
fp.write(lines)

Expand All @@ -288,7 +288,7 @@

lines[tipoff_index] = sc_orbit_tipoff_x + ' ' + sc_orbit_tipoff_y + ' ' + sc_orbit_tipoff_z + ' ! Ang Vel (deg/sec)\n'

with open('./cfg/build/InOut/SC_NOS3.txt', 'w') as fp:
with open('/tmp/nos3/cfg/InOut/SC_NOS3.txt', 'w') as fp:
lines = "".join(lines)
fp.write(lines)

Expand Down Expand Up @@ -385,7 +385,7 @@
if (sc_thruster_en != 'true'):
lines[thruster_index] = ipc_off

with open('./cfg/build/InOut/Inp_IPC.txt', 'w') as fp:
with open('/tmp/nos3/cfg/InOut/Inp_IPC.txt', 'w') as fp:
lines = "".join(lines)
fp.write(lines)

Expand All @@ -408,7 +408,7 @@
torquer_index = 999
thruster_index = 999

with open('./cfg/build/sims/nos3-simulator.xml', 'r') as fp:
with open('/tmp/nos3/cfg/sims/nos3-simulator.xml', 'r') as fp:
lines = fp.readlines()
for line in lines:
if line.find('camsim</name>') != -1:
Expand Down Expand Up @@ -487,6 +487,6 @@
if (sc_thruster_en != 'true'):
lines[thruster_index] = sim_disabled

with open('./cfg/build/sims/nos3-simulator.xml', 'w') as fp:
with open('/tmp/nos3/cfg/sims/nos3-simulator.xml', 'w') as fp:
lines = "".join(lines)
fp.write(lines)
11 changes: 11 additions & 0 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -i
#
# Convenience script for NOS3 development
# Use with the Dockerfile in the deployment repository
# https://github.com/nasa-itc/deployment
#

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/env.sh

$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR -v $USER_NOS3_BUILD_DIR:$USER_NOS3_BUILD_DIR --name "nos_clean" -w $BASE_DIR $DBOX rm -rf $USER_NOS3_BUILD_DIR/*
2 changes: 1 addition & 1 deletion scripts/debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/env.sh

mkdir -p $BASE_DIR/fsw/build
$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR -v $USER_NOS3_DIR:$USER_NOS3_DIR -w $BASE_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice --name "nos3_debug" $DBOX bash
$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR -v $USER_NOS3_DIR:$USER_NOS3_DIR -v $USER_NOS3_BUILD_DIR:$USER_NOS3_BUILD_DIR -w $BASE_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice --name "nos3_debug" $DBOX bash
17 changes: 10 additions & 7 deletions scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BASE_DIR=$(cd `dirname $SCRIPT_DIR` && pwd)
FSW_DIR=$BASE_DIR/fsw/build/exe/cpu1

USERDIR=$(cd ~/ && pwd)
USER_NOS3_DIR=$USERDIR/.nos3
USER_NOS3_BUILD_DIR=/tmp/nos3

FSW_DIR=$USER_NOS3_BUILD_DIR/fsw/exe/cpu1
GSW_BIN=$BASE_DIR/gsw/cosmos/build/openc3-cosmos-nos3
GSW_DIR=$BASE_DIR/gsw/cosmos
SIM_DIR=$BASE_DIR/sims/build
SIM_DIR=$USER_NOS3_BUILD_DIR/sims
SIM_BIN=$SIM_DIR/bin

if [ -d $SIM_DIR/bin ]; then
SIMS=$(ls $SIM_BIN/nos3*simulator)
fi
#if [ -d $SIM_DIR/bin ]; then
# SIMS=$(ls $SIM_BIN/nos3*simulator)
#fi

DATE=$(date "+%Y%m%d%H%M")
NUM_CPUS="$( nproc )"

USERDIR=$(cd ~/ && pwd)
USER_NOS3_DIR=$(cd ~/ && pwd)/.nos3
OPENC3_DIR=$USER_NOS3_DIR/cosmos
OPENC3_PATH=$OPENC3_DIR/openc3.sh

Expand Down
12 changes: 4 additions & 8 deletions scripts/fsw/fsw_cfs_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# https://github.com/nasa-itc/deployment
#

# Note this is copied to ./cfg/build as part of `make config`
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/../../scripts/env.sh
# Note the first argument passed is expected to be the BASE_DIR of the NOS3 repository
source $1/scripts/env.sh

# Check that local NOS3 directory exists
if [ ! -d $USER_NOS3_DIR ]; then
Expand All @@ -18,15 +17,12 @@ if [ ! -d $USER_NOS3_DIR ]; then
fi

# Check that configure build directory exists
if [ ! -d $BASE_DIR/cfg/build ]; then
if [ ! -d $USER_NOS3_BUILD_DIR/cfg ]; then
echo ""
echo " Need to run make config first!"
echo ""
exit 1
fi

# Make flight software build directory
mkdir -p $BASE_DIR/fsw/build

# Build
$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR --name "nos_build_fsw" -w $BASE_DIR $DBOX make -j$NUM_CPUS -e FLIGHT_SOFTWARE=cfs build-fsw
$DFLAGS_CPUS -v $BASE_DIR:$BASE_DIR -v $USER_NOS3_BUILD_DIR:$USER_NOS3_BUILD_DIR --name "nos_build_fsw" -w $BASE_DIR $DBOX make -j$NUM_CPUS -e FLIGHT_SOFTWARE=cfs build-fsw
11 changes: 5 additions & 6 deletions scripts/fsw/fsw_cfs_launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# https://github.com/nasa-itc/deployment
#

# Note this is copied to ./cfg/build as part of `make config`
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/../../scripts/env.sh
# Note the first argument passed is expected to be the BASE_DIR of the NOS3 repository
source $1/scripts/env.sh

# Check that local NOS3 directory exists
if [ ! -d $USER_NOS3_DIR ]; then
Expand All @@ -18,7 +17,7 @@ if [ ! -d $USER_NOS3_DIR ]; then
fi

# Check that configure build directory exists
if [ ! -d $BASE_DIR/cfg/build ]; then
if [ ! -d $USER_NOS3_BUILD_DIR/cfg ]; then
echo ""
echo " Need to run make config first!"
echo ""
Expand Down Expand Up @@ -53,7 +52,7 @@ echo ""

echo "Launch GSW..."
echo ""
source $BASE_DIR/cfg/build/gsw_launch.sh
source $BASE_DIR/cfg/build/gsw_launch.sh $BASE_DIR

echo "Create NOS interfaces..."
export GND_CFG_FILE="-f nos3-simulator.xml"
Expand Down Expand Up @@ -101,7 +100,7 @@ do
cd $FSW_DIR
# Debugging
# Replace `--tab` with `--window-with-profile=KeepOpen` once you've created this gnome-terminal profile manually
gnome-terminal --title=$SC_NUM" - NOS3 Flight Software" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_nos_fsw" -h nos_fsw --network=$SC_NETNAME -w $FSW_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $DBOX $SCRIPT_DIR/fsw/fsw_respawn.sh &
gnome-terminal --title=$SC_NUM" - NOS3 Flight Software" -- $DFLAGS -v $BASE_DIR:$BASE_DIR -v $USER_NOS3_BUILD_DIR:$USER_NOS3_BUILD_DIR --name $SC_NUM"_nos_fsw" -h nos_fsw --network=$SC_NETNAME -w $FSW_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $DBOX $SCRIPT_DIR/fsw/fsw_respawn.sh &
#gnome-terminal --window-with-profile=KeepOpen --title=$SC_NUM" - NOS3 Flight Software" -- $DFLAGS -v $BASE_DIR:$BASE_DIR --name $SC_NUM"_nos_fsw" -h nos_fsw --network=$SC_NETNAME -w $FSW_DIR --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $DBOX $FSW_DIR/core-cpu1 -R PO &
echo ""

Expand Down
7 changes: 3 additions & 4 deletions scripts/fsw/fsw_fprime_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# https://github.com/nasa-itc/deployment
#

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[1]}" )/scripts" && pwd )
source $SCRIPT_DIR/env.sh

# Note the first argument passed is expected to be the BASE_DIR of the NOS3 repository
source $1/scripts/env.sh

# Check that local NOS3 directory exists
if [ ! -d $USER_NOS3_DIR ]; then
Expand All @@ -18,7 +17,7 @@ if [ ! -d $USER_NOS3_DIR ]; then
fi

# Check that configure build directory exists
if [ ! -d $BASE_DIR/cfg/build ]; then
if [ ! -d $USER_NOS3_BUILD_DIR/cfg ]; then
echo ""
echo " Need to run make config first!"
echo ""
Expand Down
Loading

0 comments on commit 6f6c1d0

Please sign in to comment.