Skip to content

Commit

Permalink
* Updating mpg.pl
Browse files Browse the repository at this point in the history
  * Adding clang support
  * Adding last_build.lst support
  * Adding noclean support
* Fixing bug in Transport::prep_send that refused to send variables that had been set to 0
  • Loading branch information
jredmondson committed Feb 22, 2019
1 parent 73953e0 commit e89142f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 19 deletions.
21 changes: 10 additions & 11 deletions include/madara/transport/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,8 @@ long Base::prep_send(const knowledge::KnowledgeMap& orig_updates,

madara_logger_log(context_.get_logger(), logger::LOG_MINOR,
"%s:"
" Applying filters before sending...\n",
print_prefix);
" Applying filters to %zu updates before sending...\n",
print_prefix, orig_updates.size());

TransportContext transport_context(TransportContext::SENDING_OPERATION,
receive_monitor_.get_bytes_per_second(),
Expand Down Expand Up @@ -948,7 +948,8 @@ long Base::prep_send(const knowledge::KnowledgeMap& orig_updates,
" Filter returned for %s.\n",
print_prefix, e.first.c_str());

if(result.exists())
// allow updates of 0. Exists probably isn't right here.
if(result.exists() || !record.exists())
{
madara_logger_log(context_.get_logger(), logger::LOG_MINOR,
"%s:"
Expand Down Expand Up @@ -996,15 +997,13 @@ long Base::prep_send(const knowledge::KnowledgeMap& orig_updates,
latest_toi = record.toi();
}

if(record)
{
madara_logger_log(context_.get_logger(), logger::LOG_MINOR,
"%s:"
" Adding record %s to update list.\n",
print_prefix, e.first.c_str());
madara_logger_log(context_.get_logger(), logger::LOG_MINOR,
"%s:"
" Adding record %s to update list.\n",
print_prefix, e.first.c_str());

filtered_updates.emplace(std::make_pair(e.first, record));

filtered_updates.emplace(std::make_pair(e.first, record));
}
// Youtube tutorial is currently throwing this. Need to check GAMS
// else
// {
Expand Down
4 changes: 2 additions & 2 deletions scripts/projects/common/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ madara::transport::QoSTransportSettings settings;
// create shortcuts to MADARA classes and namespaces
namespace utility = madara::utility;
namespace knowledge = madara::knowledge;
typedef knowledge::KnowledgeRecord Record;
typedef Record::Integer Integer;
typedef knowledge::KnowledgeRecord KnowledgeRecord;
typedef KnowledgeRecord::Integer Integer;

// periodicity and run time of app
double hertz = 1.0;
Expand Down
17 changes: 17 additions & 0 deletions scripts/projects/common/using_clang.mpb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
feature (clang) {

expand(CLANG_SUFFIX) {
$CLANG_SUFFIX
-5.0
}

specific (prop:make) {
includes += /usr/include/libcxxabi
CXX = clang++$(CLANG_SUFFIX)
CC = clang$(CLANG_SUFFIX)
}

verbatim (make, local, true) {
CPPFLAGS := -stdlib=libc++ $(CPPFLAGS)
}
}
2 changes: 1 addition & 1 deletion scripts/projects/common/using_madara.mpb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project : using_boost, using_capnp {
project : using_boost, using_capnp, using_clang {
includes += $(MADARA_ROOT)/include
libpaths += $(MADARA_ROOT)/lib

Expand Down
40 changes: 35 additions & 5 deletions scripts/projects/linux/action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@
# Build a custom project created by mpg.pl


CLANG=0
CLEAN=1
COMPILE=0
COMPILE_VREP=0
DOCS=0
PREREQS=0
RUN=0
VERBOSE=0
VREP=0
INSTALL_DIR=`pwd`
SCRIPTS_DIR=`dirname $0`

Expand All @@ -79,12 +80,25 @@ if [ -z $CORES ] ; then
export CORES=1
fi

for var in "$@"
if [ $# == 0 ]; then
echo "Loading last build with noclean..."
IFS=$'\r\n ' GLOBIGNORE='*' command eval 'ARGS=($(cat $SCRIPTS_DIR/last_build.lst))'
ARGS+=("noclean")
else
echo "Processing user arguments..."
ARGS=("$@")
fi

for var in "${ARGS[@]}"
do
if [ "$var" = "compile" ]; then
COMPILE=1
elif [ "$var" = "clang" ]; then
CLANG=1
elif [ "$var" = "docs" ]; then
DOCS=1
elif [ "$var" = "noclean" ]; then
CLEAN=0
elif [ "$var" = "prereqs" ]; then
PREREQS=1
elif [ "$var" = "run" ]; then
Expand All @@ -94,7 +108,9 @@ do
else
echo "Invalid argument: $var"
echo " args can be zero or more of the following, space delimited"
echo " clang build with clang instead of g++"
echo " compile build the custom project"
echo " noclean do not do a make clean before building"
echo " prereqs apt-get doxygen and other prereqs"
echo " verbose print verbose information during this script"
echo " help get script usage"
Expand All @@ -108,6 +124,13 @@ do
fi
done

if [ $CLANG -eq 0 ]; then
if grep -q clang "$GAMS_ROOT/last_build.lst"; then
echo "Detected clang in MADARA build. Setting clang as compiler..."
CLANG=1
fi
fi

if [ $PREREQS -eq 1 ]; then
sudo apt-get install doxygen graphviz
fi
Expand All @@ -119,7 +142,7 @@ if [ $COMPILE -eq 1 ]; then
fi

cd $SCRIPTS_DIR
$MPC_ROOT/mwc.pl -type make -features docs=1 workspace.mwc
$MPC_ROOT/mwc.pl -type make -features clang=$CLANG,docs=1 workspace.mwc


if [ $VERBOSE -eq 1 ]; then
Expand All @@ -133,10 +156,17 @@ if [ $COMPILE -eq 1 ]; then
echo "Building project..."
fi

make depend vrep=$COMPILE_VREP docs=$DOCS -j $CORES
make vrep=$COMPILE_VREP docs=$DOCS -j $CORES

fi

echo "Script finished"

# save the last feature changing build (need to fix this by flattening $@)
if [ $CLEAN -eq 1 ]; then
cd $INSTALL_DIR
echo "Saving the last build. If you want to rebuild with same arguments,"
echo "then just call action.sh with no arguments"
echo "${ARGS[@]}" > $SCRIPTS_DIR/last_build.lst
fi

echo "Script finished"
1 change: 1 addition & 0 deletions scripts/projects/mpg.pl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
copy "$script_dir/common/using_boost.mpb", "$path/";
copy "$script_dir/common/using_capnp.mpb", "$path/";
copy "$script_dir/common/using_madara.mpb", "$path/";
copy "$script_dir/common/using_clang.mpb", "$path/";
copy "$script_dir/common/using_zmq.mpb", "$path/";
copy "$script_dir/common/VERSION.txt", "$path/";
copy "$script_dir/common/workspace.mwc", "$path/";
Expand Down

0 comments on commit e89142f

Please sign in to comment.